Removing the useless parameters 'have_shortcut and 'allow_funcs'.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5028 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-06-28 08:29:18 +00:00
parent 4868f83874
commit b5895f0a51
3 changed files with 65 additions and 73 deletions

View File

@ -1,3 +1,7 @@
2014-06-28 Benno Schulenberg <bensberg@justemail.net>
* src/prompt.c (do_statusbar_input): Remove the useless parameters
'have_shortcut and 'allow_funcs'; the latter is only ever TRUE.
2014-06-27 Benno Schulenberg <bensberg@justemail.net> 2014-06-27 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init): Add default keybindings for Cut, * src/global.c (shortcut_init): Add default keybindings for Cut,
PrevWord and NextWord in the prompt input lines; the code for those PrevWord and NextWord in the prompt input lines; the code for those

View File

@ -44,16 +44,12 @@ static bool reset_statusbar_x = FALSE;
/* Read in a character, interpret it as a shortcut or toggle if /* Read in a character, interpret it as a shortcut or toggle if
* necessary, and return it. Set meta_key to TRUE if the character is a * necessary, and return it. Set meta_key to TRUE if the character is a
* meta sequence, set func_key to TRUE if the character is a function * meta sequence, set func_key to TRUE if the character is a function
* key, set have_shortcut to TRUE if the character is a shortcut
* key, set ran_func to TRUE if we ran a function associated with a * key, set ran_func to TRUE if we ran a function associated with a
* shortcut key, and set finished to TRUE if we're done after running * shortcut key, and set finished to TRUE if we're done after running
* or trying to run a function associated with a shortcut key. If * or trying to run a function associated with a shortcut key.
* allow_funcs is FALSE, don't actually run any functions associated * refresh_func is the function we will call to refresh the edit window. */
* with shortcut keys. refresh_func is the function we will call to int do_statusbar_input(bool *meta_key, bool *func_key,
* refresh the edit window. */ bool *ran_func, bool *finished, void (*refresh_func)(void))
int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
bool *ran_func, bool *finished, bool allow_funcs, void
(*refresh_func)(void))
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
@ -62,9 +58,9 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
static size_t kbinput_len = 0; static size_t kbinput_len = 0;
/* The length of the input buffer. */ /* The length of the input buffer. */
const sc *s; const sc *s;
bool have_shortcut = FALSE;
const subnfunc *f; const subnfunc *f;
*have_shortcut = FALSE;
*ran_func = FALSE; *ran_func = FALSE;
*finished = FALSE; *finished = FALSE;
@ -72,7 +68,6 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
input = get_kbinput(bottomwin, meta_key, func_key); input = get_kbinput(bottomwin, meta_key, func_key);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (allow_funcs) {
/* If we got a mouse click and it was on a shortcut, read in the /* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */ * shortcut character. */
if (*func_key && input == KEY_MOUSE) { if (*func_key && input == KEY_MOUSE) {
@ -84,7 +79,6 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
input = ERR; input = ERR;
} }
} }
}
#endif #endif
/* Check for a shortcut in the current list. */ /* Check for a shortcut in the current list. */
@ -92,11 +86,11 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
/* If we got a shortcut from the current list, or a "universal" /* If we got a shortcut from the current list, or a "universal"
* statusbar prompt shortcut, set have_shortcut to TRUE. */ * statusbar prompt shortcut, set have_shortcut to TRUE. */
*have_shortcut = (s != NULL); have_shortcut = (s != NULL);
/* If we got a non-high-bit control key, a meta key sequence, or a /* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */ * function key, and it's not a shortcut or toggle, throw it out. */
if (!*have_shortcut) { if (!have_shortcut) {
if (is_ascii_cntrl_char(input) || *meta_key || *func_key) { if (is_ascii_cntrl_char(input) || *meta_key || *func_key) {
beep(); beep();
*meta_key = FALSE; *meta_key = FALSE;
@ -105,20 +99,17 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
} }
} }
if (allow_funcs) {
/* If we got a character, and it isn't a shortcut or toggle, /* If we got a character, and it isn't a shortcut or toggle,
* it's a normal text character. Display the warning if we're * it's a normal text character. Display the warning if we're
* in view mode, or add the character to the input buffer if * in view mode, or add the character to the input buffer if
* we're not. */ * we're not. */
if (input != ERR && !*have_shortcut) { if (input != ERR && !have_shortcut) {
/* If we're using restricted mode, the filename isn't blank, /* If we're using restricted mode, the filename isn't blank,
* and we're at the "Write File" prompt, disable text * and we're at the "Write File" prompt, disable text input. */
* input. */
if (!ISSET(RESTRICTED) || openfile->filename[0] == '\0' || if (!ISSET(RESTRICTED) || openfile->filename[0] == '\0' ||
currmenu != MWRITEFILE) { currmenu != MWRITEFILE) {
kbinput_len++; kbinput_len++;
kbinput = (int *)nrealloc(kbinput, kbinput_len * kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
sizeof(int));
kbinput[kbinput_len - 1] = input; kbinput[kbinput_len - 1] = input;
} }
} }
@ -126,7 +117,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
/* If we got a shortcut, or if there aren't any other characters /* If we got a shortcut, or if there aren't any other characters
* waiting after the one we read in, we need to display all the * waiting after the one we read in, we need to display all the
* characters in the input buffer if it isn't empty. */ * characters in the input buffer if it isn't empty. */
if (*have_shortcut || get_key_buffer_len() == 0) { if (have_shortcut || get_key_buffer_len() == 0) {
if (kbinput != NULL) { if (kbinput != NULL) {
/* Display all the characters in the input buffer at /* Display all the characters in the input buffer at
* once, filtering out control characters. */ * once, filtering out control characters. */
@ -139,8 +130,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
output[i] = (char)kbinput[i]; output[i] = (char)kbinput[i];
output[i] = '\0'; output[i] = '\0';
do_statusbar_output(output, kbinput_len, &got_enter, do_statusbar_output(output, kbinput_len, &got_enter, FALSE);
FALSE);
free(output); free(output);
@ -149,9 +139,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
free(kbinput); free(kbinput);
kbinput = NULL; kbinput = NULL;
} }
}
if (*have_shortcut) { if (have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter_void) if (s->scfunc == do_tab || s->scfunc == do_enter_void)
; ;
else if (s->scfunc == total_refresh) else if (s->scfunc == total_refresh)
@ -748,7 +737,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
) )
{ {
int kbinput = ERR; int kbinput = ERR;
bool have_shortcut, ran_func, finished; bool ran_func, finished;
size_t curranswer_len; size_t curranswer_len;
const sc *s; const sc *s;
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
@ -809,9 +798,9 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
* allow writing to files not specified on the command line. In * allow writing to files not specified on the command line. In
* this case, disable all keys that would change the text if the * this case, disable all keys that would change the text if the
* filename isn't blank and we're at the "Write File" prompt. */ * filename isn't blank and we're at the "Write File" prompt. */
while (1) { while (TRUE) {
kbinput = do_statusbar_input(meta_key, func_key, &have_shortcut, kbinput = do_statusbar_input(meta_key, func_key,
&ran_func, &finished, TRUE, refresh_func); &ran_func, &finished, refresh_func);
assert(statusbar_x <= strlen(answer)); assert(statusbar_x <= strlen(answer));
s = get_shortcut(currmenu, &kbinput, meta_key); s = get_shortcut(currmenu, &kbinput, meta_key);

View File

@ -494,9 +494,8 @@ int do_mouse(void);
void do_output(char *output, size_t output_len, bool allow_cntrls); void do_output(char *output, size_t output_len, bool allow_cntrls);
/* All functions in prompt.c. */ /* All functions in prompt.c. */
int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut, int do_statusbar_input(bool *meta_key, bool *func_key,
bool *ran_func, bool *finished, bool allow_funcs, void bool *ran_func, bool *finished, void (*refresh_func)(void));
(*refresh_func)(void));
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int do_statusbar_mouse(void); int do_statusbar_mouse(void);
#endif #endif