File src/modes/dialogs/msg_dialog.c changed (mode: 100644) (index d5a8da45a..6cef79d06) |
... |
... |
typedef enum |
62 |
62 |
{ |
{ |
63 |
63 |
DR_OK, /* Agreed. */ |
DR_OK, /* Agreed. */ |
64 |
64 |
DR_CANCEL, /* Cancelled. */ |
DR_CANCEL, /* Cancelled. */ |
|
65 |
|
DR_CLOSE, /* Closed. */ |
65 |
66 |
DR_YES, /* Confirmed. */ |
DR_YES, /* Confirmed. */ |
66 |
67 |
DR_NO, /* Denied. */ |
DR_NO, /* Denied. */ |
67 |
68 |
DR_CUSTOM, /* One of user-specified keys. */ |
DR_CUSTOM, /* One of user-specified keys. */ |
|
... |
... |
static int def_handler(wchar_t key); |
89 |
90 |
static void cmd_ctrl_c(key_info_t key_info, keys_info_t *keys_info); |
static void cmd_ctrl_c(key_info_t key_info, keys_info_t *keys_info); |
90 |
91 |
static void cmd_ctrl_l(key_info_t key_info, keys_info_t *keys_info); |
static void cmd_ctrl_l(key_info_t key_info, keys_info_t *keys_info); |
91 |
92 |
static void cmd_ctrl_m(key_info_t key_info, keys_info_t *keys_info); |
static void cmd_ctrl_m(key_info_t key_info, keys_info_t *keys_info); |
|
93 |
|
static void cmd_esc(key_info_t key_info, keys_info_t *keys_info); |
92 |
94 |
static void cmd_n(key_info_t key_info, keys_info_t *keys_info); |
static void cmd_n(key_info_t key_info, keys_info_t *keys_info); |
93 |
95 |
static void cmd_y(key_info_t key_info, keys_info_t *keys_info); |
static void cmd_y(key_info_t key_info, keys_info_t *keys_info); |
94 |
96 |
static void handle_response(dialog_data_t *data, DialogResult dr); |
static void handle_response(dialog_data_t *data, DialogResult dr); |
|
... |
... |
static keys_add_info_t builtin_cmds[] = { |
115 |
117 |
{WK_C_c, {{&cmd_ctrl_c}, .descr = "cancel"}}, |
{WK_C_c, {{&cmd_ctrl_c}, .descr = "cancel"}}, |
116 |
118 |
{WK_C_l, {{&cmd_ctrl_l}, .descr = "redraw"}}, |
{WK_C_l, {{&cmd_ctrl_l}, .descr = "redraw"}}, |
117 |
119 |
{WK_C_m, {{&cmd_ctrl_m}, .descr = "agree to the query"}}, |
{WK_C_m, {{&cmd_ctrl_m}, .descr = "agree to the query"}}, |
118 |
|
{WK_ESC, {{&cmd_ctrl_c}, .descr = "cancel"}}, |
|
|
120 |
|
{WK_ESC, {{&cmd_esc}, .descr = "close"}}, |
119 |
121 |
{WK_n, {{&cmd_n}, .descr = "deny the query"}}, |
{WK_n, {{&cmd_n}, .descr = "deny the query"}}, |
120 |
122 |
{WK_y, {{&cmd_y}, .descr = "confirm the query"}}, |
{WK_y, {{&cmd_y}, .descr = "confirm the query"}}, |
121 |
123 |
}; |
}; |
|
... |
... |
cmd_ctrl_m(key_info_t key_info, keys_info_t *keys_info) |
183 |
185 |
handle_response(current_dialog, DR_OK); |
handle_response(current_dialog, DR_OK); |
184 |
186 |
} |
} |
185 |
187 |
|
|
|
188 |
|
/* Closes the query. */ |
|
189 |
|
static void |
|
190 |
|
cmd_esc(key_info_t key_info, keys_info_t *keys_info) |
|
191 |
|
{ |
|
192 |
|
handle_response(current_dialog, DR_CLOSE); |
|
193 |
|
} |
|
194 |
|
|
186 |
195 |
/* Denies the query. */ |
/* Denies the query. */ |
187 |
196 |
static void |
static void |
188 |
197 |
cmd_n(key_info_t key_info, keys_info_t *keys_info) |
cmd_n(key_info_t key_info, keys_info_t *keys_info) |
|
... |
... |
handle_response(dialog_data_t *data, DialogResult dr) |
205 |
214 |
/* Map result to corresponding input key to omit branching per handler. */ |
/* Map result to corresponding input key to omit branching per handler. */ |
206 |
215 |
static const char r_to_c[] = { |
static const char r_to_c[] = { |
207 |
216 |
[DR_OK] = '\r', |
[DR_OK] = '\r', |
|
217 |
|
/* DR_CLOSE used to be part of DR_CANCEL, update handlers if there is a need |
|
218 |
|
* to differentiate between them in handlers. */ |
208 |
219 |
[DR_CANCEL] = NC_C_c, |
[DR_CANCEL] = NC_C_c, |
|
220 |
|
[DR_CLOSE] = NC_C_c, |
209 |
221 |
[DR_YES] = 'y', |
[DR_YES] = 'y', |
210 |
222 |
[DR_NO] = 'n', |
[DR_NO] = 'n', |
211 |
223 |
}; |
}; |
|
224 |
|
ARRAY_GUARD(r_to_c, DR_CUSTOM); |
212 |
225 |
|
|
213 |
226 |
(void)def_handler(r_to_c[dr]); |
(void)def_handler(r_to_c[dr]); |
214 |
227 |
/* Default handler might have already requested quitting. */ |
/* Default handler might have already requested quitting. */ |