Rename keys_getch() to keys_get()

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2017-08-30 16:24:04 +02:00
parent 273e32d43d
commit 8544e4a570
5 changed files with 29 additions and 34 deletions

View File

@ -658,7 +658,7 @@ int main(int argc, char **argv)
key_generic_reload(); key_generic_reload();
} }
key = keys_getch(win[KEY].p, &count, &reg); key = keys_get(win[KEY].p, &count, &reg);
switch (key) { switch (key) {
HANDLE_KEY(KEY_GENERIC_CHANGE_VIEW, key_generic_change_view); HANDLE_KEY(KEY_GENERIC_CHANGE_VIEW, key_generic_change_view);
HANDLE_KEY(KEY_GENERIC_OTHER_CMD, key_generic_other_cmd); HANDLE_KEY(KEY_GENERIC_OTHER_CMD, key_generic_other_cmd);

View File

@ -871,7 +871,7 @@ void keys_free(void);
void keys_dump_defaults(char *); void keys_dump_defaults(char *);
const char *keys_get_label(enum key); const char *keys_get_label(enum key);
enum key keys_get_action(int); enum key keys_get_action(int);
enum key keys_getch(WINDOW * win, int *, int *); enum key keys_get(WINDOW *, int *, int *);
int keys_assign_binding(int, enum key); int keys_assign_binding(int, enum key);
void keys_remove_binding(int, enum key); void keys_remove_binding(int, enum key);
int keys_str2int(const char *); int keys_str2int(const char *);

View File

@ -173,7 +173,7 @@ static void display_layout_config(struct window *lwin, int mark,
void custom_layout_config(void) void custom_layout_config(void)
{ {
struct window conf_win; struct window conf_win;
int ch, mark, cursor, need_reset; int key, mark, cursor, need_reset;
const char *label = _("layout configuration"); const char *label = _("layout configuration");
conf_win.p = NULL; conf_win.p = NULL;
@ -182,10 +182,9 @@ void custom_layout_config(void)
display_layout_config(&conf_win, mark, cursor); display_layout_config(&conf_win, mark, cursor);
clear(); clear();
while ((ch = while ((key = keys_get(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
need_reset = 0; need_reset = 0;
switch (ch) { switch (key) {
case KEY_GENERIC_SELECT: case KEY_GENERIC_SELECT:
mark = cursor; mark = cursor;
break; break;
@ -236,15 +235,14 @@ void custom_sidebar_config(void)
static int bindings[] = { static int bindings[] = {
KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_GENERIC_HELP KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_GENERIC_HELP
}; };
int ch, bindings_size = ARRAY_SIZE(bindings); int key, bindings_size = ARRAY_SIZE(bindings);
keys_display_bindings_bar(win[STA].p, bindings, bindings_size, 0, keys_display_bindings_bar(win[STA].p, bindings, bindings_size, 0,
bindings_size); bindings_size);
wins_doupdate(); wins_doupdate();
while ((ch = while ((key = keys_get(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) { switch (key) {
switch (ch) {
case KEY_MOVE_UP: case KEY_MOVE_UP:
wins_sbar_winc(); wins_sbar_winc();
break; break;
@ -445,7 +443,7 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
void custom_color_config(void) void custom_color_config(void)
{ {
struct window conf_win; struct window conf_win;
int ch, cursor, need_reset, theme_changed; int key, cursor, need_reset, theme_changed;
int mark_fore, mark_back; int mark_fore, mark_back;
const char *label = _("color theme"); const char *label = _("color theme");
@ -459,12 +457,11 @@ void custom_color_config(void)
theme_changed); theme_changed);
clear(); clear();
while ((ch = while ((key = keys_get(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
need_reset = 0; need_reset = 0;
theme_changed = 0; theme_changed = 0;
switch (ch) { switch (key) {
case KEY_GENERIC_SELECT: case KEY_GENERIC_SELECT:
colorize = 1; colorize = 1;
need_reset = 1; need_reset = 1;
@ -775,7 +772,7 @@ void custom_general_config(void)
KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_EDIT_ITEM KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_EDIT_ITEM
}; };
struct listbox lb; struct listbox lb;
int ch; int key;
clear(); clear();
listbox_init(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col, listbox_init(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col,
@ -790,8 +787,8 @@ void custom_general_config(void)
wmove(win[STA].p, 0, 0); wmove(win[STA].p, 0, 0);
wins_doupdate(); wins_doupdate();
while ((ch = keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) { while ((key = keys_get(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
switch (ch) { switch (key) {
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
listbox_sel_move(&lb, 1); listbox_sel_move(&lb, 1);
break; break;
@ -908,7 +905,7 @@ void custom_keys_config(void)
{ {
struct scrollwin kwin; struct scrollwin kwin;
int selrow, selelm, firstrow, lastrow, nbrowelm, nbdisplayed; int selrow, selelm, firstrow, lastrow, nbrowelm, nbdisplayed;
int keyval, used, not_recognized; int ch, used, not_recognized;
const char *keystr; const char *keystr;
WINDOW *grabwin; WINDOW *grabwin;
const int LINESPERKEY = 2; const int LINESPERKEY = 2;
@ -926,10 +923,9 @@ void custom_keys_config(void)
firstrow = 0; firstrow = 0;
lastrow = firstrow + nbdisplayed - 1; lastrow = firstrow + nbdisplayed - 1;
for (;;) { for (;;) {
int ch; int key = keys_get(win[KEY].p, NULL, NULL);
ch = keys_getch(win[KEY].p, NULL, NULL); switch (key) {
switch (ch) {
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (selrow > 0) { if (selrow > 0) {
selrow--; selrow--;
@ -976,11 +972,10 @@ void custom_keys_config(void)
(col - WINCOL) / 2, (col - WINCOL) / 2,
_("Press the key you want to assign to:"), _("Press the key you want to assign to:"),
keys_get_label(selrow), 0); keys_get_label(selrow), 0);
keyval = wgetch(grabwin); ch = wgetch(grabwin);
/* First check if this key would be recognized by calcurse. */ /* First check if this key would be recognized by calcurse. */
if (keys_str2int(keys_int2str(keyval)) == if (keys_str2int(keys_int2str(ch)) == -1) {
-1) {
not_recognized = 1; not_recognized = 1;
WARN_MSG(_("This key is not yet recognized by calcurse, " WARN_MSG(_("This key is not yet recognized by calcurse, "
"please choose another one.")); "please choose another one."));
@ -997,16 +992,16 @@ void custom_keys_config(void)
} }
/* Is the binding used by this action already? If so, just end the reassignment */ /* Is the binding used by this action already? If so, just end the reassignment */
if (selrow == keys_get_action(keyval)) { if (selrow == keys_get_action(ch)) {
delwin(grabwin); delwin(grabwin);
break; break;
} }
used = keys_assign_binding(keyval, selrow); used = keys_assign_binding(ch, selrow);
if (used) { if (used) {
enum key action; enum key action;
action = keys_get_action(keyval); action = keys_get_action(ch);
WARN_MSG(_("This key is already in use for %s, " WARN_MSG(_("This key is already in use for %s, "
"please choose another one."), "please choose another one."),
keys_get_label(action)); keys_get_label(action));
@ -1029,8 +1024,8 @@ void custom_keys_config(void)
break; break;
case KEY_DEL_ITEM: case KEY_DEL_ITEM:
keystr = keys_action_nkey(selrow, selelm); keystr = keys_action_nkey(selrow, selelm);
keyval = keys_str2int(keystr); ch = keys_str2int(keystr);
keys_remove_binding(keyval, selrow); keys_remove_binding(ch, selrow);
nbrowelm--; nbrowelm--;
if (selelm > 0 && selelm <= nbrowelm) if (selelm > 0 && selelm <= nbrowelm)
selelm--; selelm--;

View File

@ -187,7 +187,7 @@ enum key keys_get_action(int pressed)
return actions[pressed]; return actions[pressed];
} }
enum key keys_getch(WINDOW * win, int *count, int *reg) enum key keys_get(WINDOW *win, int *count, int *reg)
{ {
int ch = '0'; int ch = '0';
@ -582,7 +582,7 @@ void keys_popup_info(enum key key)
infowin = infowin =
popup(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2, popup(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
keydef[key].label, info[key], 1); keydef[key].label, info[key], 1);
keys_getch(infowin, NULL, NULL); keys_get(infowin, NULL, NULL);
delwin(infowin); delwin(infowin);
#undef WINROW #undef WINROW
#undef WINCOL #undef WINCOL

View File

@ -778,7 +778,7 @@ void notify_config_bar(void)
KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_EDIT_ITEM KEY_GENERIC_QUIT, KEY_MOVE_UP, KEY_MOVE_DOWN, KEY_EDIT_ITEM
}; };
struct listbox lb; struct listbox lb;
int ch; int key;
clear(); clear();
listbox_init(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col, listbox_init(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col,
@ -793,8 +793,8 @@ void notify_config_bar(void)
wmove(win[STA].p, 0, 0); wmove(win[STA].p, 0, 0);
wins_doupdate(); wins_doupdate();
while ((ch = keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) { while ((key = keys_get(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
switch (ch) { switch (key) {
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
listbox_sel_move(&lb, 1); listbox_sel_move(&lb, 1);
break; break;