Convert more code to use new backend. Add some more sentinel strings

for enter and backspace keys in case their control key alternates get
rebound.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4223 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2008-03-12 04:44:14 +00:00
parent c0b7872e26
commit eb64314f8b
6 changed files with 187 additions and 177 deletions

View File

@ -700,7 +700,8 @@ void do_insertfile(
filestruct *edittop_save = openfile->edittop;
size_t current_x_save = openfile->current_x;
ssize_t current_y_save = openfile->current_y;
bool edittop_inside = FALSE;
bool edittop_inside = FALSE, meta_key = FALSE, func_key = FALSE;
const sc *s;
#ifndef NANO_TINY
bool right_side_up = FALSE, single_line = FALSE;
#endif
@ -762,14 +763,16 @@ void do_insertfile(
#ifndef NANO_TINY
#ifdef ENABLE_MULTIBUFFER
if (i == TOGGLE_MULTIBUFFER_KEY) {
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
if (s && s->scfunc == (void *) do_toggle && s->toggle == MULTIBUFFER) {
/* Don't allow toggling if we're in view mode. */
if (!ISSET(VIEW_MODE))
TOGGLE(MULTIBUFFER);
continue;
} else
#endif
if (i == NANO_TOOTHERINSERT_KEY) {
if (s && s->scfunc == (void *) ext_cmd_msg) {
execute = !execute;
continue;
}
@ -779,7 +782,7 @@ void do_insertfile(
#endif /* !NANO_TINY */
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
if (s && s->scfunc == (void *) to_files_msg) {
char *tmp = do_browse_from(answer);
if (tmp == NULL)
@ -1812,7 +1815,8 @@ bool do_writeout(bool exiting)
#ifdef NANO_EXTRA
static bool did_credits = FALSE;
#endif
bool retval = FALSE;
bool retval = FALSE, meta_key = FALSE, func_key = FALSE;
const sc *s;
currmenu = MWRITEFILE;
@ -1885,9 +1889,10 @@ bool do_writeout(bool exiting)
break;
} else {
ans = mallocstrcpy(ans, answer);
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
if (s && s->scfunc == (void *) to_files_msg) {
char *tmp = do_browse_from(answer);
if (tmp == NULL)
@ -1899,23 +1904,23 @@ bool do_writeout(bool exiting)
} else
#endif /* !DISABLE_BROWSER */
#ifndef NANO_TINY
if (i == TOGGLE_DOS_KEY) {
if (s && s->scfunc == (void *) dos_format_msg) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
DOS_FILE;
continue;
} else if (i == TOGGLE_MAC_KEY) {
} else if (s && s->scfunc == (void *) mac_format_msg) {
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE :
MAC_FILE;
continue;
} else if (i == TOGGLE_BACKUP_KEY) {
} else if (s && s->scfunc == (void *) backup_file_msg) {
TOGGLE(BACKUP_FILE);
continue;
} else
#endif /* !NANO_TINY */
if (i == NANO_PREPEND_KEY) {
if (s && s->scfunc == (void *) prepend_msg) {
append = (append == PREPEND) ? OVERWRITE : PREPEND;
continue;
} else if (i == NANO_APPEND_KEY) {
} else if (s && s->scfunc == (void *) append_msg) {
append = (append == APPEND) ? OVERWRITE : APPEND;
continue;
}

View File

@ -23,6 +23,7 @@
**************************************************************************/
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "assert.h"
#include "proto.h"
@ -196,7 +197,7 @@ size_t length_of_list(int menu)
size_t i = 0;
for (f = allfuncs; f != NULL; f = f->next)
if ((f->menus & menu) != 0) {
if ((f->menus & menu) != 0 && strlen(f->help) > 0) {
i++;
}
return i;
@ -363,6 +364,10 @@ void assign_keyinfo(sc *s)
s->seq = KEY_IC;
else if (s->type == RAW && (!strcasecmp(s->keystr, "kdel")))
s->seq = KEY_DC;
else if (s->type == RAW && (!strcasecmp(s->keystr, "kbsp")))
s->seq = KEY_BACKSPACE;
else if (s->type == RAW && (!strcasecmp(s->keystr, "kenter")))
s->seq = KEY_ENTER;
else if (s->type == RAW && (!strcasecmp(s->keystr, "kpup")))
s->seq = KEY_PPAGE;
else if (s->type == RAW && (!strcasecmp(s->keystr, "kpdown")))
@ -454,6 +459,7 @@ const char *whereis_next_msg = "";
const char *last_file_msg = "";
const char *new_buffer_msg = "";
const char *goto_dir_msg;
const char *ext_cmd_msg = = "";
#else
/* TRANSLATORS: Try to keep this and previous strings at most 10
@ -483,6 +489,7 @@ const char *append_msg = N_("Append");
const char *prepend_msg = N_("Prepend");
/* TRANSLATORS: Try to keep this at most 16 characters. */
const char *backup_file_msg = N_("Backup File");
const char *ext_cmd_msg = N_("Execute Command");
#ifdef ENABLE_MULTIBUFFER
/* TRANSLATORS: Try to keep this at most 16 characters. */
@ -516,7 +523,6 @@ void shortcut_init(bool unjustify)
#endif
const char *refresh_msg = N_("Refresh");
const char *insert_file_msg = N_("Insert File");
const char *ext_cmd_msg = N_("Execute Command");
const char *go_to_line_msg = N_("Go To Line");
#ifndef DISABLE_HELP
@ -804,9 +810,11 @@ void shortcut_init(bool unjustify)
add_to_funcs(do_right, (MMAIN|MBROWSER), N_("Forward"), nano_forward_msg,
FALSE, VIEW);
add_to_funcs(do_right, MALL, "", "", FALSE, VIEW);
add_to_funcs(do_left, (MMAIN|MBROWSER), N_("Back"), nano_back_msg,
FALSE, VIEW);
add_to_funcs(do_left, MALL, "", "", FALSE, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_next_word_void, MMAIN, N_("Next Word"),
@ -858,17 +866,28 @@ void shortcut_init(bool unjustify)
nano_verbatim_msg, FALSE, NOVIEW);
add_to_funcs(do_tab, MMAIN, N_("Tab"), nano_tab_msg,
FALSE, NOVIEW);
add_to_funcs(do_tab, MALL, "", "", FALSE, NOVIEW);
add_to_funcs(do_enter, MMAIN, N_("Enter"), nano_enter_msg,
FALSE, NOVIEW);
add_to_funcs(do_enter, MALL, "", "", FALSE, NOVIEW);
add_to_funcs(do_delete, MMAIN, N_("Delete"), nano_delete_msg,
FALSE, NOVIEW);
add_to_funcs(do_delete, MALL, "", "", FALSE, NOVIEW);
add_to_funcs(do_backspace, MMAIN, N_("Backspace"), nano_backspace_msg,
#ifndef NANO_TINY
FALSE,
#else
TRUE,
#endif
VIEW);
NOVIEW);
add_to_funcs(do_backspace, MALL, "", "",
#ifndef NANO_TINY
FALSE,
#else
TRUE,
#endif
NOVIEW);
#ifndef NANO_TINY
add_to_funcs(do_cut_till_end, MMAIN, N_("CutTillEnd"),
@ -1062,15 +1081,15 @@ void shortcut_init(bool unjustify)
add_to_sclist(MMAIN, "M-6", do_copy_text, 0, TRUE);
add_to_sclist(MMAIN, "M-}", do_indent_void, 0, TRUE);
add_to_sclist(MMAIN, "M-{", do_unindent, 0, TRUE);
add_to_sclist(MMAIN|MBROWSER|MHELP, "^F", do_right, 0, TRUE);
add_to_sclist(MMAIN|MBROWSER|MHELP, "kright", do_right, 0, TRUE);
add_to_sclist(MMAIN|MBROWSER|MHELP, "^B", do_left, 0, TRUE);
add_to_sclist(MMAIN|MBROWSER|MHELP, "kleft", do_left, 0, TRUE);
add_to_sclist(MALL, "^F", do_right, 0, TRUE);
add_to_sclist(MALL, "kright", do_right, 0, TRUE);
add_to_sclist(MALL, "^B", do_left, 0, TRUE);
add_to_sclist(MALL, "kleft", do_left, 0, TRUE);
add_to_sclist(MMAIN, "^Space", do_next_word_void, 0, TRUE);
add_to_sclist(MMAIN, "M-Space", do_prev_word_void, 0, TRUE);
#endif
add_to_sclist(MALL, "^Q", xon_complaint, 0, TRUE);
add_to_sclist(MALL, "^X", xoff_complaint, 0, TRUE);
add_to_sclist(MMAIN, "^Q", xon_complaint, 0, TRUE);
add_to_sclist(MMAIN, "^S", xoff_complaint, 0, TRUE);
add_to_sclist(MALL, "^P", do_up_void, 0, TRUE);
add_to_sclist(MALL, "kup", do_up_void, 0, TRUE);
add_to_sclist(MALL, "^N", do_down_void, 0, TRUE);
@ -1130,9 +1149,11 @@ void shortcut_init(bool unjustify)
add_to_sclist(MMAIN, "M-V", do_verbatim_input, 0, TRUE);
add_to_sclist(MALL, "^I", do_tab, 0, TRUE);
add_to_sclist(MALL, "^M", do_enter, 0, TRUE);
add_to_sclist(MALL, "kenter", do_enter, 0, TRUE);
add_to_sclist(MALL, "^D", do_delete, 0, TRUE);
add_to_sclist(MALL, "kdel", do_delete, 0, TRUE);
add_to_sclist(MALL, "^H", do_backspace, 0, TRUE);
add_to_sclist(MALL, "kbsp", do_backspace, 0, TRUE);
#ifndef NANO_TINY
add_to_sclist(MALL, "M-T", do_cut_till_end, 0, TRUE);
add_to_sclist(MALL, "M-J", do_full_justify, 0, TRUE);

View File

@ -513,16 +513,15 @@ void parse_help_input(int *kbinput, bool *meta_key, bool *func_key)
switch (*kbinput) {
/* For consistency with the file browser. */
case ' ':
*kbinput = NANO_NEXTPAGE_KEY;
*kbinput = sc_seq_or(do_page_up, 0);
break;
case '-':
*kbinput = NANO_PREVPAGE_KEY;
*kbinput = sc_seq_or(do_page_down, 0);;
break;
/* Cancel is equivalent to Exit here. */
case NANO_CANCEL_KEY:
case 'E':
case 'e':
*kbinput = NANO_EXIT_KEY;
*kbinput = sc_seq_or(do_exit, 0);;
break;
}
}

View File

@ -44,14 +44,14 @@ static bool reset_statusbar_x = FALSE;
/* 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
* meta sequence, set func_key to TRUE if the character is a function
* key, set s_or_t to TRUE if the character is a shortcut or toggle
* 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
* 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
* allow_funcs is FALSE, don't actually run any functions associated
* with shortcut keys. refresh_func is the function we will call to
* refresh the edit window. */
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
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))
{
@ -63,9 +63,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
/* The length of the input buffer. */
const sc *s;
const subnfunc *f;
bool have_shortcut;
*s_or_t = FALSE;
*have_shortcut = FALSE;
*ran_func = FALSE;
*finished = FALSE;
@ -93,27 +92,11 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
/* If we got a shortcut from the current list, or a "universal"
* statusbar prompt shortcut, set have_shortcut to TRUE. */
have_shortcut = (s != NULL || input == NANO_TAB_KEY || input ==
NANO_ENTER_KEY || input == NANO_REFRESH_KEY || input ==
NANO_HOME_KEY || input == NANO_END_KEY || input ==
NANO_BACK_KEY || input == NANO_FORWARD_KEY || input ==
NANO_BACKSPACE_KEY || input == NANO_DELETE_KEY || input ==
NANO_CUT_KEY ||
#ifndef NANO_TINY
input == NANO_NEXTWORD_KEY ||
#endif
(*meta_key && (
#ifndef NANO_TINY
input == NANO_PREVWORD_KEY || input == NANO_BRACKET_KEY ||
#endif
input == NANO_VERBATIM_KEY)));
/* Set s_or_t to TRUE if we got a shortcut. */
*s_or_t = have_shortcut;
*have_shortcut = (s != NULL);
/* 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. */
if (!*s_or_t) {
if (!*have_shortcut) {
if (is_ascii_cntrl_char(input) || *meta_key || *func_key) {
beep();
*meta_key = FALSE;
@ -127,7 +110,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
* it's a normal text character. Display the warning if we're
* in view mode, or add the character to the input buffer if
* we're not. */
if (input != ERR && !*s_or_t) {
if (input != ERR && !*have_shortcut) {
/* If we're using restricted mode, the filename isn't blank,
* and we're at the "Write File" prompt, disable text
* input. */
@ -143,7 +126,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
/* 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
* characters in the input buffer if it isn't empty. */
if (*s_or_t || get_key_buffer_len() == 0) {
if (*have_shortcut || get_key_buffer_len() == 0) {
if (kbinput != NULL) {
/* Display all the characters in the input buffer at
* once, filtering out control characters. */
@ -168,60 +151,47 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
}
}
if (have_shortcut) {
switch (input) {
/* Handle the "universal" statusbar prompt shortcuts. */
case NANO_TAB_KEY:
case NANO_ENTER_KEY:
break;
case NANO_REFRESH_KEY:
total_statusbar_refresh(refresh_func);
break;
case NANO_CUT_KEY:
if (*have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter)
;
else if (s->scfunc == total_refresh)
total_statusbar_refresh(refresh_func);
else if (s->scfunc == (void *) do_cut_text) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Cut. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_cut_text();
} else if (s->scfunc == do_right)
do_statusbar_right();
else if (s->scfunc == do_left)
do_statusbar_left();
#ifndef NANO_TINY
else if (s->scfunc == (void *) do_next_word)
do_statusbar_next_word(FALSE);
else if (s->scfunc == (void *) do_prev_word)
do_statusbar_prev_word(FALSE);
#endif
else if (s->scfunc == do_home)
do_statusbar_home();
else if (s->scfunc == do_end)
do_statusbar_end();
#ifndef NANO_TINY
else if (s->scfunc == do_find_bracket)
do_statusbar_find_bracket();
#endif
else if (s->scfunc == do_verbatim_input) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Cut. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_cut_text();
break;
case NANO_FORWARD_KEY:
do_statusbar_right();
break;
case NANO_BACK_KEY:
do_statusbar_left();
break;
#ifndef NANO_TINY
case NANO_NEXTWORD_KEY:
do_statusbar_next_word(FALSE);
break;
case NANO_PREVWORD_KEY:
if (*meta_key)
do_statusbar_prev_word(FALSE);
break;
#endif
case NANO_HOME_KEY:
do_statusbar_home();
break;
case NANO_END_KEY:
do_statusbar_end();
break;
#ifndef NANO_TINY
case NANO_BRACKET_KEY:
if (*meta_key)
do_statusbar_find_bracket();
break;
#endif
case NANO_VERBATIM_KEY:
if (*meta_key) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable verbatim input. */
if (!ISSET(RESTRICTED) ||
openfile->filename[0] == '\0' ||
currmenu != MWRITEFILE) {
* prompt, disable verbatim input. */
if (!ISSET(RESTRICTED) ||
openfile->filename[0] == '\0' ||
currmenu != MWRITEFILE) {
bool got_enter;
/* Whether we got the Enter key. */
/* Whether we got the Enter key. */
do_statusbar_verbatim_input(&got_enter);
@ -231,41 +201,38 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
* to indicate that we're done. */
if (got_enter) {
get_input(NULL, 1);
input = NANO_ENTER_KEY;
input = sc_seq_or(do_enter, 0);
*finished = TRUE;
}
}
}
break;
case NANO_DELETE_KEY:
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Delete. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
} else if (s->scfunc == do_delete) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Delete. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_delete();
break;
case NANO_BACKSPACE_KEY:
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Backspace. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
do_statusbar_delete();
} else if (s->scfunc == do_backspace) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Backspace. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_backspace();
break;
/* Handle the normal statusbar prompt shortcuts, setting
* ran_func to TRUE if we try to run their associated
* functions and setting finished to TRUE to indicate
* that we're done after running or trying to run their
* associated functions. */
default:
f = sctofunc((sc *) s);
if (s->scfunc != NULL && s->execute == TRUE) {
do_statusbar_backspace();
} else {
/* Handle the normal statusbar prompt shortcuts, setting
* ran_func to TRUE if we try to run their associated
* functions and setting finished to TRUE to indicate
* that we're done after running or trying to run their
* associated functions. */
f = sctofunc((sc *) s);
if (s->scfunc != NULL && s->execute == TRUE) {
*ran_func = TRUE;
if (!ISSET(VIEW_MODE) || f->viewok)
f->scfunc();
}
*finished = TRUE;
if (!ISSET(VIEW_MODE) || f->viewok)
f->scfunc();
}
*finished = TRUE;
}
}
}
@ -927,7 +894,7 @@ void total_statusbar_refresh(void (*refresh_func)(void))
/* Get a string of input at the statusbar prompt. This should only be
* called from do_prompt(). */
int get_prompt_string(bool allow_tabs,
const sc *get_prompt_string(int *actual, bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
@ -942,8 +909,9 @@ int get_prompt_string(bool allow_tabs,
)
{
int kbinput = ERR;
bool meta_key, func_key, s_or_t, ran_func, finished;
bool meta_key, func_key, have_shortcut, ran_func, finished;
size_t curranswer_len;
const sc *s;
#ifndef DISABLE_TABCOMP
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
@ -1002,22 +970,27 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* allow writing to files not specified on the command line. In
* this case, disable all keys that would change the text if the
* filename isn't blank and we're at the "Write File" prompt. */
while ((kbinput = do_statusbar_input(&meta_key, &func_key, &s_or_t,
&ran_func, &finished, TRUE, refresh_func)) != NANO_CANCEL_KEY &&
kbinput != NANO_ENTER_KEY) {
while (1) {
kbinput = do_statusbar_input(&meta_key, &func_key, &have_shortcut,
&ran_func, &finished, TRUE, refresh_func);
assert(statusbar_x <= strlen(answer));
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
if (s)
if (s->scfunc == (void *) cancel_msg || s->scfunc == do_enter)
break;
#ifndef DISABLE_TABCOMP
if (kbinput != NANO_TAB_KEY)
if (s && s->scfunc != do_tab)
tabbed = FALSE;
#endif
switch (kbinput) {
#ifndef DISABLE_TABCOMP
#ifndef NANO_TINY
case NANO_TAB_KEY:
if (s && s->scfunc == do_tab) {
if (history_list != NULL) {
if (last_kbinput != NANO_TAB_KEY)
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
complete_len = strlen(answer);
if (complete_len > 0) {
@ -1033,10 +1006,10 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
&statusbar_x, &tabbed, refresh_func, list);
update_statusbar_line(answer, statusbar_x);
break;
} else
#endif /* !DISABLE_TABCOMP */
#ifndef NANO_TINY
case NANO_PREVLINE_KEY:
if (s && s->scfunc == do_up_void) {
if (history_list != NULL) {
/* If we're scrolling up at the bottom of the
* history list and answer isn't blank, save answer
@ -1064,8 +1037,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* statusbar prompt. */
finished = FALSE;
}
break;
case NANO_NEXTLINE_KEY:
} else if (s && s->scfunc == do_down_void) {
if (history_list != NULL) {
/* Get the newer search from the history list and
* save it in answer. If there is no newer search,
@ -1095,9 +1067,9 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* statusbar prompt. */
finished = FALSE;
}
break;
} else
#endif /* !NANO_TINY */
case NANO_HELP_KEY:
if (s && s->scfunc == do_help_void) {
update_statusbar_line(answer, statusbar_x);
/* This key has a shortcut list entry when it's used to
@ -1107,7 +1079,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* here, so that we aren't kicked out of the statusbar
* prompt. */
finished = FALSE;
break;
}
/* If we have a shortcut with an associated function, break out
@ -1141,20 +1112,23 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* associated function, so reset statusbar_x and statusbar_pww. If
* we've finished putting in an answer, reset the statusbar cursor
* position too. */
if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY ||
if (s) {
if (s->scfunc == (void *) cancel_msg || s->scfunc == do_enter ||
ran_func) {
statusbar_x = old_statusbar_x;
statusbar_pww = old_pww;
statusbar_x = old_statusbar_x;
statusbar_pww = old_pww;
if (!ran_func)
reset_statusbar_x = TRUE;
if (!ran_func)
reset_statusbar_x = TRUE;
/* Otherwise, we're still putting in an answer or a shortcut with
* an associated function, so leave the statusbar cursor position
* alone. */
} else
reset_statusbar_x = FALSE;
} else
reset_statusbar_x = FALSE;
}
return kbinput;
*actual = kbinput;
return s;
}
/* Ask a question on the statusbar. The prompt will be stored in the
@ -1181,6 +1155,7 @@ int do_prompt(bool allow_tabs,
{
va_list ap;
int retval;
const sc *s;
#ifndef DISABLE_TABCOMP
bool list = FALSE;
#endif
@ -1199,7 +1174,7 @@ int do_prompt(bool allow_tabs,
va_end(ap);
null_at(&prompt, actual_x(prompt, COLS - 4));
retval = get_prompt_string(allow_tabs,
s = get_prompt_string(&retval, allow_tabs,
#ifndef DISABLE_TABCOMP
allow_files,
#endif
@ -1223,15 +1198,10 @@ int do_prompt(bool allow_tabs,
/* If we left the prompt via Cancel or Enter, set the return value
* properly. */
switch (retval) {
case NANO_CANCEL_KEY:
retval = -1;
break;
case NANO_ENTER_KEY:
retval = (*answer == '\0') ? -2 : 0;
break;
}
if (s && s->scfunc == (void *) cancel_msg)
retval = -1;
else if (s && s->scfunc == do_enter)
retval = (*answer == '\0') ? -2 : 0;
blank_statusbar();
wnoutrefresh(bottomwin);
@ -1271,6 +1241,7 @@ int do_yesno_prompt(bool all, const char *msg)
const char *yesstr; /* String of Yes characters accepted. */
const char *nostr; /* Same for No. */
const char *allstr; /* And All, surprise! */
const sc *s;
assert(msg != NULL);
@ -1318,7 +1289,7 @@ int do_yesno_prompt(bool all, const char *msg)
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, reverse_attr);
wattroff(bottomwin, reverse_attr);
/* Refresh the edit window and the statusbar before getting
* input. */
@ -1333,13 +1304,12 @@ int do_yesno_prompt(bool all, const char *msg)
#endif
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
switch (kbinput) {
case NANO_CANCEL_KEY:
ok = -1;
break;
if (s && s->scfunc == (void *) cancel_msg)
ok = -1;
#ifndef DISABLE_MOUSE
case KEY_MOUSE:
else if (kbinput == KEY_MOUSE) {
/* We can click on the Yes/No/All shortcut list to
* select an answer. */
if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
@ -1366,12 +1336,11 @@ int do_yesno_prompt(bool all, const char *msg)
if (ok == 2 && !all)
ok = -2;
}
break;
#endif /* !DISABLE_MOUSE */
case NANO_REFRESH_KEY:
total_redraw();
continue;
default:
} else if (s && s->scfunc == total_refresh) {
total_redraw();
continue;
} else {
/* Look for the kbinput in the Yes, No and (optionally)
* All strings. */
if (strchr(yesstr, kbinput) != NULL)

View File

@ -465,7 +465,7 @@ void enable_signals(void);
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
int do_input(bool *meta_key, bool *func_key, bool *have_shortcut, bool
*ran_func, bool *finished, bool allow_funcs);
#ifndef DISABLE_MOUSE
int do_mouse(void);
@ -473,7 +473,7 @@ int do_mouse(void);
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* All functions in prompt.c. */
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
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));
#ifndef DISABLE_MOUSE
@ -504,7 +504,7 @@ void reset_statusbar_cursor(void);
void update_statusbar_line(const char *curranswer, size_t index);
bool need_statusbar_horizontal_update(size_t pww_save);
void total_statusbar_refresh(void (*refresh_func)(void));
int get_prompt_string(bool allow_tabs,
const sc *get_prompt_string(int *value, bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
@ -794,6 +794,19 @@ const char *whereis_next_msg;
const char *first_file_msg;
const char *last_file_msg;
const char *goto_dir_msg;
const char *ext_cmd_msg;
const char *to_files_msg;
const char *dos_format_msg;
const char *mac_format_msg;
const char *append_msg;
const char *prepend_msg;
const char *backup_file_msg;
const char *dos_format_msg;
const char *mac_format_msg;
const char *append_msg;
const char *prepend_msg;
const char *backup_file_msg;
#ifdef HAVE_REGEX_H
const char *regexp_msg;

View File

@ -1698,7 +1698,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
for (; j > 0; j--) {
if (f->next != NULL)
f = f->next;
while (f->next != NULL && (f->menus & currmenu) == 0)
while (f->next != NULL && ((f->menus & currmenu) == 0 || strlen(f->help) == 0))
f = f->next;
}
@ -2356,6 +2356,9 @@ void bottombars(int menu)
if ((f->menus & menu) == 0)
continue;
if (strlen(f->desc) == 0)
continue;
#ifdef DEBUG
fprintf(stderr, "found one! f->menus = %d, desc = \"%s\"\n", f->menus, f->desc);
#endif