size_t mark_beginx_save = mark_beginx;
#endif
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 (full_justify)
/* Now get a keystroke and see if it's unjustify. If not, put back
* 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 &&
kbinput == NANO_UNJUSTIFY_KEY) {
}
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;
/* The character we read in. */
#endif
*s_or_t = FALSE;
+ *ran_func = FALSE;
*finished = FALSE;
/* Read in a character. */
break;
#endif
/* Handle the normal edit window shortcuts, setting
- * finished to TRUE to indicate that we're done after
- * running or trying to run their associated
+ * ran_func to TRUE if we try to run their associated
+ * functions and setting finished to TRUE to indicate
+ * that we're done after trying to run their associated
* functions. */
default:
/* Blow away the text in the cutbuffer if we aren't
cutbuffer_reset();
if (s->func != NULL) {
+ *ran_func = TRUE;
if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning();
else
edit_refresh();
while (TRUE) {
- bool meta_key;
- /* 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. */
+ bool meta_key, func_key, s_or_t, ran_func, finished;
/* Make sure the cursor is in the edit window. */
reset_cursor();
currshortcut = main_list;
/* 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);
}
void enable_flow_control(void);
void terminal_init(void);
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
bool do_mouse(void);
#endif
const toggle *get_toggle(int kbinput, bool meta_key);
#endif
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
bool do_statusbar_mouse(void);
#endif
#endif /* !NANO_SMALL */
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;
/* The character we read in. */
bool have_shortcut;
*s_or_t = FALSE;
+ *ran_func = FALSE;
*finished = FALSE;
/* Read in a character. */
break;
}
/* Handle the normal statusbar prompt shortcuts, setting
- * finished to TRUE to indicate that we're done after
- * running or trying to run their associated
+ * ran_func to TRUE if we try to run their associated
+ * functions and setting finished to TRUE to indicate
+ * that we're done after trying to run their associated
* functions. */
default:
if (s->func != NULL) {
- if (ISSET(VIEW_MODE) && !s->viewok)
- print_view_warning();
- else
+ *ran_func = TRUE;
+ if (!ISSET(VIEW_MODE) || s->viewok)
s->func();
}
*finished = TRUE;
)
{
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;
/* used by input_tab() */
* 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, &finished, TRUE)) != NANO_CANCEL_KEY &&
+ &s_or_t, &ran_func, &finished, TRUE)) != NANO_CANCEL_KEY &&
kbinput != NANO_ENTER_KEY) {
/* 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)
break;
wrefresh(bottomwin);
}
- /* We finished putting in an answer, so reset statusbar_x. */
- if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY)
+ /* We finished putting in an answer or ran a normal shortcut's
+ * associated function, so reset statusbar_x. */
+ if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY ||
+ ran_func)
statusbar_x = (size_t)-1;
return kbinput;