tweaks: elide a parameter by moving the general case one level up

This commit is contained in:
Benno Schulenberg 2022-08-19 11:51:16 +02:00
parent 5a3bd329d6
commit 2f25b6a650

View File

@ -250,10 +250,8 @@ void do_statusbar_verbatim_input(void)
free(bytes); free(bytes);
} }
/* Read in a keystroke, interpret it if it is a shortcut or toggle, and /* Read in a keystroke, handle some shortcuts, and return the keycode. */
* return it. Set finished to TRUE if we're done after running int do_statusbar_input(void)
* or trying to run a function associated with a shortcut key. */
int do_statusbar_input(bool *finished)
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
@ -264,8 +262,6 @@ int do_statusbar_input(bool *finished)
const keystruct *shortcut; const keystruct *shortcut;
functionptrtype function; functionptrtype function;
*finished = FALSE;
/* Read in a character. */ /* Read in a character. */
input = get_kbinput(footwin, VISIBLE); input = get_kbinput(footwin, VISIBLE);
@ -317,10 +313,10 @@ int do_statusbar_input(bool *finished)
if (shortcut) { if (shortcut) {
if (function == do_tab || function == do_enter) if (function == do_tab || function == do_enter)
; return input;
#ifdef ENABLE_HISTORIES #ifdef ENABLE_HISTORIES
else if (function == get_older_item || function == get_newer_item) else if (function == get_older_item || function == get_newer_item)
; return input;
#endif #endif
else if (function == do_left) else if (function == do_left)
do_statusbar_left(); do_statusbar_left();
@ -364,16 +360,11 @@ int do_statusbar_input(bool *finished)
else if (function == paste_text) { else if (function == paste_text) {
if (cutbuffer != NULL) if (cutbuffer != NULL)
paste_into_answer(); paste_into_answer();
} } else
return input;
#endif #endif
else { /* Don't handle the handled functions again. */
/* Handle any other permissible shortcut, and stamp as done. */ return ERR;
if (!ISSET(VIEW_MODE) || !changes_something(function)) {
function();
*finished = TRUE;
} else
beep();
}
} }
return input; return input;
@ -462,7 +453,6 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
linestruct **history_list, void (*refresh_func)(void)) linestruct **history_list, void (*refresh_func)(void))
{ {
int kbinput = ERR; int kbinput = ERR;
bool finished;
functionptrtype func; functionptrtype func;
#ifdef ENABLE_HISTORIES #ifdef ENABLE_HISTORIES
char *stored_string = NULL; char *stored_string = NULL;
@ -481,7 +471,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
while (TRUE) { while (TRUE) {
draw_the_promptbar(); draw_the_promptbar();
kbinput = do_statusbar_input(&finished); kbinput = do_statusbar_input();
#ifndef NANO_TINY #ifndef NANO_TINY
/* If the window size changed, go reformat the prompt string. */ /* If the window size changed, go reformat the prompt string. */
@ -552,24 +542,26 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
#endif /* ENABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */
/* If we ran a function that should not exit from the prompt... */ /* If we ran a function that should not exit from the prompt... */
if (func == do_help || func == full_refresh) if (func == do_help || func == full_refresh)
finished = FALSE; func();
#ifndef NANO_TINY #ifndef NANO_TINY
else if (func == do_nothing) else if (func == do_nothing)
finished = FALSE; ;
else if (func == do_toggle) { else if (func == do_toggle) {
TOGGLE(NO_HELP); TOGGLE(NO_HELP);
window_init(); window_init();
focusing = FALSE; focusing = FALSE;
refresh_func(); refresh_func();
bottombars(currmenu); bottombars(currmenu);
finished = FALSE;
} }
#endif #endif
else if (func) {
/* If we have a shortcut with an associated function, break out if /* When it's a permissible shortcut, run it and done. */
* we're finished after running or trying to run the function. */ if (!ISSET(VIEW_MODE) || !changes_something(func)) {
if (finished) func();
break; break;
} else
beep();
}
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP) #if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
previous_was_tab = (func == do_tab); previous_was_tab = (func == do_tab);