ui: close modal on pressing escape (not everywhere)
This commit is contained in:
-29
@@ -1,29 +0,0 @@
|
||||
client.o: src/client.c src/file_processor.h src/main.h src/types.h \
|
||||
src/ui/widget/file_list.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../main.h src/client.h
|
||||
connection.o: src/connection.c src/main.h src/types.h src/ui/app.h \
|
||||
src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h
|
||||
file_processor.o: src/file_processor.c src/client.h src/main.h \
|
||||
src/types.h src/file_processor.h src/ui/widget/file_list.h \
|
||||
src/ui/widget/../widget.h src/ui/widget/../../main.h src/query.h \
|
||||
src/ui/app.h src/ui/../common.h src/ui/widget.h src/ui/widget/dialogue.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/progress_bar.h
|
||||
fs.o: src/fs.c
|
||||
main.o: src/main.c src/connection.h src/main.h src/types.h src/ui/app.h \
|
||||
src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h src/query.h \
|
||||
src/ui/widget.h src/ui/widget/file_list.h
|
||||
query.o: src/query.c src/client.h src/main.h src/types.h src/connection.h \
|
||||
src/ui/app.h src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h src/file_processor.h \
|
||||
src/ui/widget/file_list.h src/server.h src/ui/widget/dialogue.h
|
||||
server.o: src/server.c src/main.h src/types.h
|
||||
|
||||
+2
-2
@@ -76,8 +76,8 @@ int32_t process_user_input(app_t *app, callback_args_t *d_args) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
d_args->data = (void *)&c;
|
||||
app->active_callback(d_args);
|
||||
d_args->data = (void *)&c;
|
||||
app->active_callback(d_args);
|
||||
break;
|
||||
}
|
||||
return OK;
|
||||
|
||||
@@ -45,9 +45,6 @@ void query_loop(app_t *app) {
|
||||
|
||||
for (;;) {
|
||||
/* update screen */
|
||||
if (query_args->state == S_WAIT_SERVER && app->modal.is_initiated) {
|
||||
destroy_dialogue(&(app->modal), app);
|
||||
}
|
||||
app_draw_modal(app);
|
||||
app_refresh(app);
|
||||
|
||||
|
||||
+3
-1
@@ -73,6 +73,7 @@ void init_nc() {
|
||||
keypad(stdscr, TRUE);
|
||||
noecho();
|
||||
curs_set(false);
|
||||
set_escdelay(50);
|
||||
|
||||
if (!has_colors()) {
|
||||
printf("Your terminal does not support color\n");
|
||||
@@ -137,7 +138,8 @@ void app_refresh(app_t *app) {
|
||||
}
|
||||
|
||||
void app_draw_modal(app_t *app) {
|
||||
if (app->modal.needs_destroy) {
|
||||
if (app->modal.needs_destroy ||
|
||||
(app->query_args->state == S_WAIT_SERVER && app->modal.is_initiated)) {
|
||||
destroy_dialogue(&(app->modal), app);
|
||||
}
|
||||
if (!app->modal.is_initiated) {
|
||||
|
||||
@@ -30,7 +30,7 @@ void asa_modal_dialogue_callback(callback_args_t *args) {
|
||||
case 0:
|
||||
get_ip_port(app->params, in_ip->value, in_port->value);
|
||||
connect_to_server(app);
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -37,7 +37,7 @@ void init_login_credentials_modal_cb(callback_args_t *args) {
|
||||
app->params->pass[in_pass->value_len] = 0;
|
||||
write(app->params->sd, app->params->uname, in_name->value_len);
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
print_bars(app);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -26,7 +26,7 @@ void login_modal_option_cb(callback_args_t *args) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = S_ASK_LOGIN_USER;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ void init_notification_modal_cb(callback_args_t *args) {
|
||||
dialogue_default_callback(&d_args);
|
||||
|
||||
app->query_args->state = WAIT_CLIENT;
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
}
|
||||
|
||||
dialogue_t *init_notification_modal(app_t *app) {
|
||||
|
||||
@@ -25,7 +25,7 @@ void server_message_modal_cb(callback_args_t *args) {
|
||||
if (response > -1) {
|
||||
switch (response) {
|
||||
case 0:
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
/* TODO: macros */
|
||||
free(app->query_args->server_message.text);
|
||||
app->query_args->server_message.text = NULL;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "../../file_processor.h"
|
||||
#include "../app.h"
|
||||
#include "../widget/dialogue.h"
|
||||
#include "../widget/fs_file_list.h"
|
||||
#include "../widget/group.h"
|
||||
#include "../../file_processor.h"
|
||||
#include <ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -19,18 +19,19 @@ void upload_dialogue_modal_cb(callback_args_t *args) {
|
||||
dialogue_default_callback(&d_args);
|
||||
ui_fs_file_list_t *fui =
|
||||
(ui_fs_file_list_t *)d->g_content->elements[0].element;
|
||||
if (response > -1) {
|
||||
switch (response) {
|
||||
case 0:
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
destroy_dialogue(d, app);
|
||||
break;
|
||||
case 1:
|
||||
file_upload_open(fui->d_path, fui->current->name, app->query_args);
|
||||
destroy_dialogue(d, app);
|
||||
app->query_args->state = S_UPLOAD_PARAMS;
|
||||
break;
|
||||
}
|
||||
switch (response) {
|
||||
case 0:
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
d->needs_destroy = true;
|
||||
break;
|
||||
case 1:
|
||||
file_upload_open(fui->d_path, fui->current->name, app->query_args);
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = S_UPLOAD_PARAMS;
|
||||
break;
|
||||
case -2:
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = WAIT_CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void upload_props_dialogue_modal_cb(callback_args_t *args) {
|
||||
app->query_args->file->description =
|
||||
malloc(desc_input->value_len + 9); /* reserve space for \n:END:\n */
|
||||
strcpy(app->query_args->file->description, desc_input->value);
|
||||
destroy_dialogue(d, app);
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = S_UPLOAD_REQUESTED;
|
||||
write(app->query_args->sd, query, query_len);
|
||||
break;
|
||||
|
||||
@@ -75,6 +75,9 @@ void dialogue_default_callback(callback_args_t *args) {
|
||||
}
|
||||
*resp_value = -1;
|
||||
break;
|
||||
case '\33': /* Esc key */
|
||||
*resp_value = -2;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
if (d->active.type == g_content) {
|
||||
if (d->g_content->elements[d->active.id - d->g_content->first_id].type ==
|
||||
@@ -188,7 +191,6 @@ void dialogue_init_active_id(dialogue_t *dialogue) {
|
||||
widget_t *w = (widget_t *)dialogue->g_content->elements[i].element;
|
||||
dialogue->active.id = w->id;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,7 +203,6 @@ void dialogue_init_active_id(dialogue_t *dialogue) {
|
||||
widget_t *w = (widget_t *)dialogue->g_action->elements[i].element;
|
||||
dialogue->active.id = w->id;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,6 +351,7 @@ void destroy_dialogue(dialogue_t *d, void *_app) {
|
||||
delwin(d->win);
|
||||
d->win = NULL;
|
||||
d->is_initiated = 0;
|
||||
d->needs_destroy = false;
|
||||
app->active_win_type = aw_left;
|
||||
app->active_win = app->left_win;
|
||||
app->active_callback = file_list_cb;
|
||||
|
||||
Reference in New Issue
Block a user