Commit cac0293b authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

miscellaneous high-level input routine fixes: in do_statusbar_input(),

indicate when we run a normal shortcut's associated function with the
ran_func parameter, reset the statusbar cursor position when we do, and
don't call print_view_warning() when we try to run a function not
allowed in view mode; also apply the first of these changes to
do_input() so that both the edit window and statusbar routines are in
sync again


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2246 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 577298a3
No related merge requests found
Showing with 29 additions and 28 deletions
+29 -28
...@@ -2717,7 +2717,7 @@ void do_justify(bool full_justify) ...@@ -2717,7 +2717,7 @@ void do_justify(bool full_justify)
size_t mark_beginx_save = mark_beginx; size_t mark_beginx_save = mark_beginx;
#endif #endif
int kbinput; int kbinput;
bool meta_key, func_key, s_or_t, finished; bool meta_key, func_key, s_or_t, ran_func, finished;
/* If we're justifying the entire file, start at the beginning. */ /* If we're justifying the entire file, start at the beginning. */
if (full_justify) if (full_justify)
...@@ -2983,7 +2983,8 @@ void do_justify(bool full_justify) ...@@ -2983,7 +2983,8 @@ void do_justify(bool full_justify)
/* Now get a keystroke and see if it's unjustify. If not, put back /* Now get a keystroke and see if it's unjustify. If not, put back
* the keystroke and return. */ * the keystroke and return. */
kbinput = do_input(&meta_key, &func_key, &s_or_t, &finished, FALSE); kbinput = do_input(&meta_key, &func_key, &s_or_t, &ran_func,
&finished, FALSE);
if (!meta_key && !func_key && s_or_t && if (!meta_key && !func_key && s_or_t &&
kbinput == NANO_UNJUSTIFY_KEY) { kbinput == NANO_UNJUSTIFY_KEY) {
...@@ -3385,7 +3386,7 @@ void terminal_init(void) ...@@ -3385,7 +3386,7 @@ 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 *s_or_t, bool
*finished, bool allow_funcs) *ran_func, bool *finished, bool allow_funcs)
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
...@@ -3401,6 +3402,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool ...@@ -3401,6 +3402,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
#endif #endif
*s_or_t = FALSE; *s_or_t = FALSE;
*ran_func = FALSE;
*finished = FALSE; *finished = FALSE;
/* Read in a character. */ /* Read in a character. */
...@@ -3492,8 +3494,9 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool ...@@ -3492,8 +3494,9 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
break; break;
#endif #endif
/* Handle the normal edit window shortcuts, setting /* Handle the normal edit window shortcuts, setting
* finished to TRUE to indicate that we're done after * ran_func to TRUE if we try to run their associated
* running or trying to run their associated * functions and setting finished to TRUE to indicate
* that we're done after trying to run their associated
* functions. */ * functions. */
default: default:
/* Blow away the text in the cutbuffer if we aren't /* Blow away the text in the cutbuffer if we aren't
...@@ -3502,6 +3505,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool ...@@ -3502,6 +3505,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
cutbuffer_reset(); cutbuffer_reset();
if (s->func != NULL) { if (s->func != NULL) {
*ran_func = TRUE;
if (ISSET(VIEW_MODE) && !s->viewok) if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning(); print_view_warning();
else else
...@@ -4219,15 +4223,7 @@ int main(int argc, char **argv) ...@@ -4219,15 +4223,7 @@ int main(int argc, char **argv)
edit_refresh(); edit_refresh();
while (TRUE) { while (TRUE) {
bool meta_key; bool meta_key, func_key, s_or_t, ran_func, finished;
/* Whether we got a meta key sequence. */
bool func_key;
/* Whether we got a function key. */
bool s_or_t;
/* Whether we got a shortcut or toggle. */
bool ran_s_or_t;
/* Whether we ran a function associated with a
* shortcut. */
/* Make sure the cursor is in the edit window. */ /* Make sure the cursor is in the edit window. */
reset_cursor(); reset_cursor();
...@@ -4240,7 +4236,8 @@ int main(int argc, char **argv) ...@@ -4240,7 +4236,8 @@ int main(int argc, char **argv)
currshortcut = main_list; currshortcut = main_list;
/* Read in and interpret characters. */ /* Read in and interpret characters. */
do_input(&meta_key, &func_key, &s_or_t, &ran_s_or_t, TRUE); do_input(&meta_key, &func_key, &s_or_t, &ran_func, &finished,
TRUE);
} }
assert(FALSE); assert(FALSE);
} }
...@@ -392,7 +392,7 @@ void disable_flow_control(void); ...@@ -392,7 +392,7 @@ void disable_flow_control(void);
void enable_flow_control(void); void enable_flow_control(void);
void terminal_init(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 *s_or_t, bool
*finished, bool allow_funcs); *ran_func, bool *finished, bool allow_funcs);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
bool do_mouse(void); bool do_mouse(void);
#endif #endif
...@@ -578,7 +578,7 @@ const shortcut *get_shortcut(const shortcut *s_list, int *kbinput, bool ...@@ -578,7 +578,7 @@ const shortcut *get_shortcut(const shortcut *s_list, int *kbinput, bool
const toggle *get_toggle(int kbinput, bool meta_key); const toggle *get_toggle(int kbinput, bool meta_key);
#endif #endif
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 *s_or_t,
bool *finished, bool allow_funcs); bool *ran_func, bool *finished, bool allow_funcs);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
bool do_statusbar_mouse(void); bool do_statusbar_mouse(void);
#endif #endif
......
...@@ -1724,7 +1724,7 @@ const toggle *get_toggle(int kbinput, bool meta_key) ...@@ -1724,7 +1724,7 @@ const toggle *get_toggle(int kbinput, bool meta_key)
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
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 *s_or_t,
bool *finished, bool allow_funcs) bool *ran_func, bool *finished, bool allow_funcs)
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
...@@ -1736,6 +1736,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, ...@@ -1736,6 +1736,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
bool have_shortcut; bool have_shortcut;
*s_or_t = FALSE; *s_or_t = FALSE;
*ran_func = FALSE;
*finished = FALSE; *finished = FALSE;
/* Read in a character. */ /* Read in a character. */
...@@ -1865,14 +1866,14 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, ...@@ -1865,14 +1866,14 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
break; break;
} }
/* Handle the normal statusbar prompt shortcuts, setting /* Handle the normal statusbar prompt shortcuts, setting
* finished to TRUE to indicate that we're done after * ran_func to TRUE if we try to run their associated
* running or trying to run their associated * functions and setting finished to TRUE to indicate
* that we're done after trying to run their associated
* functions. */ * functions. */
default: default:
if (s->func != NULL) { if (s->func != NULL) {
if (ISSET(VIEW_MODE) && !s->viewok) *ran_func = TRUE;
print_view_warning(); if (!ISSET(VIEW_MODE) || s->viewok)
else
s->func(); s->func();
} }
*finished = TRUE; *finished = TRUE;
...@@ -2422,7 +2423,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def, ...@@ -2422,7 +2423,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
) )
{ {
int kbinput; int kbinput;
bool meta_key, func_key, s_or_t, finished; bool meta_key, func_key, s_or_t, ran_func, finished;
bool tabbed = FALSE; bool tabbed = FALSE;
/* used by input_tab() */ /* used by input_tab() */
...@@ -2474,11 +2475,12 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def, ...@@ -2474,11 +2475,12 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
* disable all keys that would change the text if the filename isn't * disable all keys that would change the text if the filename isn't
* blank and we're at the "Write File" prompt. */ * blank and we're at the "Write File" prompt. */
while ((kbinput = do_statusbar_input(&meta_key, &func_key, while ((kbinput = do_statusbar_input(&meta_key, &func_key,
&s_or_t, &finished, TRUE)) != NANO_CANCEL_KEY && &s_or_t, &ran_func, &finished, TRUE)) != NANO_CANCEL_KEY &&
kbinput != NANO_ENTER_KEY) { kbinput != NANO_ENTER_KEY) {
/* If we have a shortcut with an associated function, break out /* If we have a shortcut with an associated function, break out
* if we're finished after running the function. */ * if we're finished after running or trying to run the
* function. */
if (finished) if (finished)
break; break;
...@@ -2617,8 +2619,10 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def, ...@@ -2617,8 +2619,10 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
wrefresh(bottomwin); wrefresh(bottomwin);
} }
/* We finished putting in an answer, so reset statusbar_x. */ /* We finished putting in an answer or ran a normal shortcut's
if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY) * associated function, so reset statusbar_x. */
if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY ||
ran_func)
statusbar_x = (size_t)-1; statusbar_x = (size_t)-1;
return kbinput; return kbinput;
......
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