Commit a9b5a0e0 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename a function to something less abbrevy

Also, swap the logic around, to use less braces.
Showing with 16 additions and 17 deletions
+16 -17
...@@ -147,7 +147,7 @@ char *do_browser(char *path) ...@@ -147,7 +147,7 @@ char *do_browser(char *path)
/* If we selected the same filename as last time, fake a /* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */ * press of the Enter key so that the file is read in. */
if (old_selected == selected) if (old_selected == selected)
unget_kbinput(sc_seq_or(do_enter, 0), FALSE); unget_kbinput(the_code_for(do_enter, 0), FALSE);
} }
continue; continue;
......
...@@ -385,18 +385,17 @@ const sc *first_sc_for(int menu, void (*func)(void)) ...@@ -385,18 +385,17 @@ const sc *first_sc_for(int menu, void (*func)(void))
return NULL; return NULL;
} }
/* Return the given menu's first shortcut sequence, or the default value /* Return the first keycode that is bound to the given function in the
* (2nd arg). Assumes currmenu for the menu to check. */ * current menu, if any; otherwise, return the given default value. */
int sc_seq_or(void (*func)(void), int defaultval) int the_code_for(void (*func)(void), int defaultval)
{ {
const sc *s = first_sc_for(currmenu, func); const sc *s = first_sc_for(currmenu, func);
if (s) { if (s == NULL)
meta_key = s->meta; return defaultval;
return s->keycode;
} meta_key = s->meta;
/* else */ return s->keycode;
return defaultval;
} }
/* Return a pointer to the function that is bound to the given key. */ /* Return a pointer to the function that is bound to the given key. */
......
...@@ -148,7 +148,7 @@ int do_statusbar_input(bool *ran_func, bool *finished) ...@@ -148,7 +148,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
* fake a press of Enter, and indicate that we're done. */ * fake a press of Enter, and indicate that we're done. */
if (got_newline) { if (got_newline) {
get_input(NULL, 1); get_input(NULL, 1);
input = sc_seq_or(do_enter, 0); input = the_code_for(do_enter, 0);
*finished = TRUE; *finished = TRUE;
} }
} else if (s->scfunc == do_cut_text_void) } else if (s->scfunc == do_cut_text_void)
...@@ -531,7 +531,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, ...@@ -531,7 +531,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (func == do_tab) { if (func == do_tab) {
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
if (history_list != NULL) { if (history_list != NULL) {
if (last_kbinput != sc_seq_or(do_tab, TAB_CODE)) if (last_kbinput != the_code_for(do_tab, TAB_CODE))
complete_len = strlen(answer); complete_len = strlen(answer);
if (complete_len > 0) { if (complete_len > 0) {
......
...@@ -358,7 +358,7 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column); ...@@ -358,7 +358,7 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
/* Some functions in global.c. */ /* Some functions in global.c. */
size_t length_of_list(int menu); size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void)); const sc *first_sc_for(int menu, void (*func)(void));
int sc_seq_or(void (*func)(void), int defaultval); int the_code_for(void (*func)(void), int defaultval);
functionptrtype func_from_key(int *kbinput); functionptrtype func_from_key(int *kbinput);
void assign_keyinfo(sc *s, const char *keystring, const int keycode); void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void); void print_sclist(void);
......
...@@ -642,13 +642,13 @@ int parse_kbinput(WINDOW *win) ...@@ -642,13 +642,13 @@ int parse_kbinput(WINDOW *win)
#endif #endif
case DEL_CODE: case DEL_CODE:
if (ISSET(REBIND_DELETE)) if (ISSET(REBIND_DELETE))
return sc_seq_or(do_delete, KEY_DC); return the_code_for(do_delete, KEY_DC);
else else
return KEY_BACKSPACE; return KEY_BACKSPACE;
#ifdef KEY_SIC #ifdef KEY_SIC
/* Slang doesn't support KEY_SIC. */ /* Slang doesn't support KEY_SIC. */
case KEY_SIC: case KEY_SIC:
return sc_seq_or(do_insertfile_void, KEY_IC); return the_code_for(do_insertfile_void, KEY_IC);
#endif #endif
#ifdef KEY_SBEG #ifdef KEY_SBEG
/* Slang doesn't support KEY_SBEG. */ /* Slang doesn't support KEY_SBEG. */
...@@ -667,7 +667,7 @@ int parse_kbinput(WINDOW *win) ...@@ -667,7 +667,7 @@ int parse_kbinput(WINDOW *win)
#endif #endif
/* Slang doesn't support KEY_CANCEL. */ /* Slang doesn't support KEY_CANCEL. */
case KEY_CANCEL: case KEY_CANCEL:
return sc_seq_or(do_cancel, 0x03); return the_code_for(do_cancel, 0x03);
#endif #endif
#ifdef KEY_SUSPEND #ifdef KEY_SUSPEND
#ifdef KEY_SSUSPEND #ifdef KEY_SSUSPEND
...@@ -676,7 +676,7 @@ int parse_kbinput(WINDOW *win) ...@@ -676,7 +676,7 @@ int parse_kbinput(WINDOW *win)
#endif #endif
/* Slang doesn't support KEY_SUSPEND. */ /* Slang doesn't support KEY_SUSPEND. */
case KEY_SUSPEND: case KEY_SUSPEND:
return sc_seq_or(do_suspend_void, KEY_SUSPEND); return the_code_for(do_suspend_void, KEY_SUSPEND);
#endif #endif
#ifdef PDCURSES #ifdef PDCURSES
case KEY_SHIFT_L: case KEY_SHIFT_L:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment