Making 'meta_key' and 'func_key' into global variables, instead of

having them declared everywhere and passing them around endlessly.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5039 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-06-30 18:04:33 +00:00
parent eaf235f1e6
commit 7e5324d164
11 changed files with 91 additions and 109 deletions

View File

@ -3,6 +3,8 @@
with --ignorercfiles, do not try to find one, because that would lead with --ignorercfiles, do not try to find one, because that would lead
to the magic database being searched, which slows down startup a lot. to the magic database being searched, which slows down startup a lot.
* src/color.c (color_update): Move some variables to a better place. * src/color.c (color_update): Move some variables to a better place.
* src/*: Make 'meta_key' and 'func_key' into global variables, instead
of having them declared everywhere and passing them around endlessly.
2014-06-29 Benno Schulenberg <bensberg@justemail.net> 2014-06-29 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c: Fix compilation with --enable-tiny --enable-nanorc. * src/rcfile.c: Fix compilation with --enable-tiny --enable-nanorc.

View File

@ -50,7 +50,7 @@ char *do_browser(char *path, DIR *dir)
{ {
char *retval = NULL; char *retval = NULL;
int kbinput; int kbinput;
bool meta_key, func_key, old_const_update = ISSET(CONST_UPDATE); bool old_const_update = ISSET(CONST_UPDATE);
char *prev_dir = NULL; char *prev_dir = NULL;
/* The directory we were in, if any, before backing up via /* The directory we were in, if any, before backing up via
* browsing to "..". */ * browsing to "..". */
@ -122,7 +122,7 @@ char *do_browser(char *path, DIR *dir)
old_selected = selected; old_selected = selected;
kbinput = get_kbinput(edit, &meta_key, &func_key); kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) { if (kbinput == KEY_MOUSE) {
@ -158,8 +158,8 @@ char *do_browser(char *path, DIR *dir)
} }
#endif /* !DISABLE_MOUSE */ #endif /* !DISABLE_MOUSE */
parse_browser_input(&kbinput, &meta_key); parse_browser_input(&kbinput);
s = get_shortcut(MBROWSER, &kbinput, &meta_key); s = get_shortcut(MBROWSER, &kbinput);
if (!s) if (!s)
continue; continue;
f = sctofunc((sc *) s); f = sctofunc((sc *) s);
@ -204,7 +204,6 @@ char *do_browser(char *path, DIR *dir)
FALSE, FALSE,
#endif #endif
MGOTODIR, ans, MGOTODIR, ans,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
NULL, NULL,
#endif #endif
@ -529,9 +528,9 @@ void browser_init(const char *path, DIR *dir)
/* Convert certain non-shortcut keys into their corresponding shortcut /* Convert certain non-shortcut keys into their corresponding shortcut
* sequences, for compatibility with Pico. */ * sequences, for compatibility with Pico. */
void parse_browser_input(int *kbinput, bool *meta_key) void parse_browser_input(int *kbinput)
{ {
if (!*meta_key) { if (!meta_key) {
switch (*kbinput) { switch (*kbinput) {
case ' ': case ' ':
*kbinput = KEY_NPAGE; *kbinput = KEY_NPAGE;
@ -741,7 +740,6 @@ int filesearch_init(void)
{ {
int i = 0; int i = 0;
char *buf; char *buf;
bool meta_key, func_key;
const sc *s; const sc *s;
static char *backupstring = NULL; static char *backupstring = NULL;
/* The search string we'll be using. */ /* The search string we'll be using. */
@ -775,7 +773,6 @@ int filesearch_init(void)
TRUE, TRUE,
#endif #endif
MWHEREISFILE, backupstring, MWHEREISFILE, backupstring,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
&search_history, &search_history,
#endif #endif
@ -805,7 +802,7 @@ int filesearch_init(void)
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
return -1; return -1;
} else { } else {
s = get_shortcut(MBROWSER, &i, &meta_key); s = get_shortcut(MBROWSER, &i);
if (i == -2 || i == 0) { if (i == -2 || i == 0) {
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
/* Use last_search if answer is an empty string, or /* Use last_search if answer is an empty string, or

View File

@ -1009,7 +1009,7 @@ void do_insertfile(
filestruct *edittop_save = openfile->edittop; filestruct *edittop_save = openfile->edittop;
size_t current_x_save = openfile->current_x; size_t current_x_save = openfile->current_x;
ssize_t current_y_save = openfile->current_y; ssize_t current_y_save = openfile->current_y;
bool edittop_inside = FALSE, meta_key = FALSE, func_key = FALSE; bool edittop_inside = FALSE;
const sc *s; const sc *s;
#ifndef NANO_TINY #ifndef NANO_TINY
bool right_side_up = FALSE, single_line = FALSE; bool right_side_up = FALSE, single_line = FALSE;
@ -1045,7 +1045,6 @@ void do_insertfile(
execute ? MEXTCMD : execute ? MEXTCMD :
#endif #endif
MINSERTFILE, ans, MINSERTFILE, ans,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
NULL, NULL,
#endif #endif
@ -1072,7 +1071,7 @@ void do_insertfile(
ans = mallocstrcpy(ans, answer); ans = mallocstrcpy(ans, answer);
s = get_shortcut(currmenu, &i, &meta_key); s = get_shortcut(currmenu, &i);
#ifndef NANO_TINY #ifndef NANO_TINY
#ifndef DISABLE_MULTIBUFFER #ifndef DISABLE_MULTIBUFFER
@ -2218,7 +2217,7 @@ bool do_writeout(bool exiting)
#ifndef DISABLE_EXTRA #ifndef DISABLE_EXTRA
static bool did_credits = FALSE; static bool did_credits = FALSE;
#endif #endif
bool retval = FALSE, meta_key = FALSE, func_key = FALSE; bool retval = FALSE;
const sc *s; const sc *s;
currmenu = MWRITEFILE; currmenu = MWRITEFILE;
@ -2273,7 +2272,6 @@ bool do_writeout(bool exiting)
TRUE, TRUE,
#endif #endif
MWRITEFILE, ans, MWRITEFILE, ans,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
NULL, NULL,
#endif #endif
@ -2293,7 +2291,7 @@ bool do_writeout(bool exiting)
break; break;
} else { } else {
ans = mallocstrcpy(ans, answer); ans = mallocstrcpy(ans, answer);
s = get_shortcut(currmenu, &i, &meta_key); s = get_shortcut(currmenu, &i);
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
if (s && s->scfunc == to_files_void) { if (s && s->scfunc == to_files_void) {

View File

@ -38,6 +38,11 @@ bool jump_buf_main = FALSE;
* SIGWINCH? */ * SIGWINCH? */
#endif #endif
bool meta_key;
/* Whether the current keystroke is a Meta key. */
bool func_key;
/* Whether the current keystroke is an extended keypad value. */
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
ssize_t fill = 0; ssize_t fill = 0;
/* The column where we will wrap lines. */ /* The column where we will wrap lines. */

View File

@ -37,7 +37,7 @@ static char *help_text = NULL;
void do_help(void (*refresh_func)(void)) void do_help(void (*refresh_func)(void))
{ {
int kbinput = ERR; int kbinput = ERR;
bool meta_key, func_key, old_no_help = ISSET(NO_HELP); bool old_no_help = ISSET(NO_HELP);
size_t line = 0; size_t line = 0;
/* The line number in help_text of the first displayed help /* The line number in help_text of the first displayed help
* line. This variable is zero-based. */ * line. This variable is zero-based. */
@ -123,7 +123,7 @@ void do_help(void (*refresh_func)(void))
old_line = line; old_line = line;
kbinput = get_kbinput(edit, &meta_key, &func_key); kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) { if (kbinput == KEY_MOUSE) {
@ -133,8 +133,8 @@ void do_help(void (*refresh_func)(void))
} }
#endif #endif
parse_help_input(&kbinput, &meta_key); parse_help_input(&kbinput);
s = get_shortcut(MHELP, &kbinput, &meta_key); s = get_shortcut(MHELP, &kbinput);
if (!s) if (!s)
continue; continue;
f = sctofunc((sc *) s); f = sctofunc((sc *) s);
@ -478,9 +478,9 @@ void help_init(void)
/* Convert certain non-shortcut keys into their corresponding shortcut /* Convert certain non-shortcut keys into their corresponding shortcut
* sequences. */ * sequences. */
void parse_help_input(int *kbinput, bool *meta_key) void parse_help_input(int *kbinput)
{ {
if (!*meta_key) { if (!meta_key) {
switch (*kbinput) { switch (*kbinput) {
/* For consistency with the file browser. */ /* For consistency with the file browser. */
case ' ': case ' ':

View File

@ -1583,11 +1583,10 @@ void terminal_init(void)
} }
/* 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.
* meta sequence, set func_key to TRUE if the character is a function key.
* If allow_funcs is FALSE, don't actually run any functions associated * If allow_funcs is FALSE, don't actually run any functions associated
* with shortcut keys. */ * with shortcut keys. */
int do_input(bool *meta_key, bool *func_key, bool allow_funcs) int do_input(bool allow_funcs)
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
@ -1601,15 +1600,15 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
bool have_shortcut; bool have_shortcut;
/* Read in a character. */ /* Read in a character. */
input = get_kbinput(edit, meta_key, func_key); input = get_kbinput(edit);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (*func_key && input == KEY_MOUSE) { if (func_key && input == KEY_MOUSE) {
/* We received a mouse click. */ /* We received a mouse click. */
if (do_mouse() == 1) if (do_mouse() == 1)
/* The click was on a shortcut -- read in the character /* The click was on a shortcut -- read in the character
* that it was converted into. */ * that it was converted into. */
input = get_kbinput(edit, meta_key, func_key); input = get_kbinput(edit);
else else
/* The click was invalid or has been handled -- get out. */ /* The click was invalid or has been handled -- get out. */
return ERR; return ERR;
@ -1617,7 +1616,7 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
#endif #endif
/* Check for a shortcut in the main list. */ /* Check for a shortcut in the main list. */
s = get_shortcut(MMAIN, &input, meta_key); s = get_shortcut(MMAIN, &input);
/* If we got a shortcut from the main list, or a "universal" /* If we got a shortcut from the main list, or a "universal"
* edit window shortcut, set have_shortcut to TRUE. */ * edit window shortcut, set have_shortcut to TRUE. */
@ -1626,11 +1625,11 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
/* 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) {
statusbar(_("Unknown Command")); statusbar(_("Unknown Command"));
beep(); beep();
*meta_key = FALSE; meta_key = FALSE;
*func_key = FALSE; func_key = FALSE;
input = ERR; input = ERR;
} }
} }
@ -2791,8 +2790,6 @@ int main(int argc, char **argv)
display_buffer(); display_buffer();
while (TRUE) { while (TRUE) {
bool meta_key, func_key;
/* Make sure the cursor is in the edit window. */ /* Make sure the cursor is in the edit window. */
reset_cursor(); reset_cursor();
wnoutrefresh(edit); wnoutrefresh(edit);
@ -2821,7 +2818,7 @@ int main(int argc, char **argv)
currmenu = MMAIN; currmenu = MMAIN;
/* Read in and interpret characters. */ /* Read in and interpret characters. */
do_input(&meta_key, &func_key, TRUE); do_input(TRUE);
} }
/* We should never get here. */ /* We should never get here. */

View File

@ -42,14 +42,13 @@ static bool reset_statusbar_x = FALSE;
* prompt? */ * prompt? */
/* 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.
* meta sequence, set func_key to TRUE if the character is a function * 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. * or trying to run a function associated with a shortcut key.
* refresh_func is the function we will call to refresh the edit window. */ * refresh_func is the function we will call to refresh the edit window. */
int do_statusbar_input(bool *meta_key, bool *func_key, int do_statusbar_input(bool *ran_func, bool *finished,
bool *ran_func, bool *finished, void (*refresh_func)(void)) void (*refresh_func)(void))
{ {
int input; int input;
/* The character we read in. */ /* The character we read in. */
@ -65,24 +64,24 @@ int do_statusbar_input(bool *meta_key, bool *func_key,
*finished = FALSE; *finished = FALSE;
/* Read in a character. */ /* Read in a character. */
input = get_kbinput(bottomwin, meta_key, func_key); input = get_kbinput(bottomwin);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
/* 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) {
if (do_statusbar_mouse() == 1) if (do_statusbar_mouse() == 1)
input = get_kbinput(bottomwin, meta_key, func_key); input = get_kbinput(bottomwin);
else { else {
*meta_key = FALSE; meta_key = FALSE;
*func_key = FALSE; func_key = FALSE;
input = ERR; input = ERR;
} }
} }
#endif #endif
/* Check for a shortcut in the current list. */ /* Check for a shortcut in the current list. */
s = get_shortcut(currmenu, &input, meta_key); s = get_shortcut(currmenu, &input);
/* 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. */
@ -91,10 +90,10 @@ int do_statusbar_input(bool *meta_key, bool *func_key,
/* 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;
*func_key = FALSE; func_key = FALSE;
input = ERR; input = ERR;
} }
} }
@ -727,7 +726,6 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
bool allow_files, bool allow_files,
#endif #endif
const char *curranswer, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
filestruct **history_list, filestruct **history_list,
#endif #endif
@ -800,11 +798,10 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
* 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 (TRUE) { while (TRUE) {
kbinput = do_statusbar_input(meta_key, func_key, kbinput = do_statusbar_input(&ran_func, &finished, 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);
if (s) if (s)
if (s->scfunc == do_cancel || s->scfunc == do_enter_void) if (s->scfunc == do_cancel || s->scfunc == do_enter_void)
@ -963,7 +960,6 @@ int do_prompt(bool allow_tabs,
bool allow_files, bool allow_files,
#endif #endif
int menu, const char *curranswer, int menu, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
filestruct **history_list, filestruct **history_list,
#endif #endif
@ -995,7 +991,6 @@ int do_prompt(bool allow_tabs,
allow_files, allow_files,
#endif #endif
curranswer, curranswer,
meta_key, func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
history_list, history_list,
#endif #endif
@ -1119,14 +1114,13 @@ int do_yesno_prompt(bool all, const char *msg)
do { do {
int kbinput; int kbinput;
bool meta_key, func_key;
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int mouse_x, mouse_y; int mouse_x, mouse_y;
#endif #endif
currmenu = MYESNO; currmenu = MYESNO;
kbinput = get_kbinput(bottomwin, &meta_key, &func_key); kbinput = get_kbinput(bottomwin);
s = get_shortcut(currmenu, &kbinput, &meta_key); s = get_shortcut(currmenu, &kbinput);
if (s && s->scfunc == do_cancel) if (s && s->scfunc == do_cancel)
ok = -1; ok = -1;

View File

@ -32,6 +32,9 @@ extern sigjmp_buf jump_buf;
extern bool jump_buf_main; extern bool jump_buf_main;
#endif #endif
extern bool meta_key;
extern bool func_key;
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
extern ssize_t fill; extern ssize_t fill;
extern ssize_t wrap_at; extern ssize_t wrap_at;
@ -141,7 +144,7 @@ extern char *homedir;
char *do_browser(char *path, DIR *dir); char *do_browser(char *path, DIR *dir);
char *do_browse_from(const char *inpath); char *do_browse_from(const char *inpath);
void browser_init(const char *path, DIR *dir); void browser_init(const char *path, DIR *dir);
void parse_browser_input(int *kbinput, bool *meta_key); void parse_browser_input(int *kbinput);
void browser_refresh(void); void browser_refresh(void);
bool browser_select_filename(const char *needle); bool browser_select_filename(const char *needle);
int filesearch_init(void); int filesearch_init(void);
@ -369,7 +372,7 @@ void thanks_for_all_the_fish(void);
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
void do_help(void (*refresh_func)(void)); void do_help(void (*refresh_func)(void));
void help_init(void); void help_init(void);
void parse_help_input(int *kbinput, bool *meta_key); void parse_help_input(int *kbinput);
size_t help_line_len(const char *ptr); size_t help_line_len(const char *ptr);
#endif #endif
void do_help_void(void); void do_help_void(void);
@ -487,15 +490,15 @@ void enable_signals(void);
void disable_flow_control(void); 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 allow_funcs); int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int do_mouse(void); int do_mouse(void);
#endif #endif
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, int do_statusbar_input(bool *ran_func, bool *finished,
bool *ran_func, bool *finished, void (*refresh_func)(void)); void (*refresh_func)(void));
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int do_statusbar_mouse(void); int do_statusbar_mouse(void);
#endif #endif
@ -524,7 +527,6 @@ const sc *get_prompt_string(int *value, bool allow_tabs,
bool allow_files, bool allow_files,
#endif #endif
const char *curranswer, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
filestruct **history_list, filestruct **history_list,
#endif #endif
@ -538,7 +540,6 @@ int do_prompt(bool allow_tabs,
bool allow_files, bool allow_files,
#endif #endif
int menu, const char *curranswer, int menu, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
filestruct **history_list, filestruct **history_list,
#endif #endif
@ -750,10 +751,10 @@ void dump_filestruct_reverse(void);
void get_key_buffer(WINDOW *win); void get_key_buffer(WINDOW *win);
size_t get_key_buffer_len(void); size_t get_key_buffer_len(void);
void unget_input(int *input, size_t input_len); void unget_input(int *input, size_t input_len);
void unget_kbinput(int kbinput, bool meta_key, bool func_key); void unget_kbinput(int kbinput, bool metakey, bool funckey);
int *get_input(WINDOW *win, size_t input_len); int *get_input(WINDOW *win, size_t input_len);
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key); int get_kbinput(WINDOW *win);
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key); int parse_kbinput(WINDOW *win);
int get_escape_seq_kbinput(const int *seq, size_t seq_len); int get_escape_seq_kbinput(const int *seq, size_t seq_len);
int get_escape_seq_abcd(int kbinput); int get_escape_seq_abcd(int kbinput);
int parse_escape_seq_kbinput(WINDOW *win, int kbinput); int parse_escape_seq_kbinput(WINDOW *win, int kbinput);
@ -769,7 +770,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts); int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif #endif
const sc *get_shortcut(int menu, int *kbinput, bool *meta_key); const sc *get_shortcut(int menu, int *kbinput);
void blank_line(WINDOW *win, int y, int x, int n); void blank_line(WINDOW *win, int y, int x, int n);
void blank_titlebar(void); void blank_titlebar(void);
void blank_topbar(void); void blank_topbar(void);

View File

@ -138,7 +138,6 @@ int search_init(bool replacing, bool use_answer)
int i = 0; int i = 0;
char *buf; char *buf;
sc *s; sc *s;
bool meta_key = FALSE, func_key = FALSE;
static char *backupstring = NULL; static char *backupstring = NULL;
/* The search string we'll be using. */ /* The search string we'll be using. */
@ -177,7 +176,6 @@ int search_init(bool replacing, bool use_answer)
TRUE, TRUE,
#endif #endif
replacing ? MREPLACE : MWHEREIS, backupstring, replacing ? MREPLACE : MWHEREIS, backupstring,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
&search_history, &search_history,
#endif #endif
@ -910,7 +908,6 @@ void do_replace(void)
{ {
filestruct *edittop_save, *begin; filestruct *edittop_save, *begin;
size_t begin_x, pww_save; size_t begin_x, pww_save;
bool meta_key = FALSE, func_key = FALSE;
ssize_t numreplaced; ssize_t numreplaced;
int i; int i;
@ -953,7 +950,6 @@ void do_replace(void)
TRUE, TRUE,
#endif #endif
MREPLACEWITH, last_replace, MREPLACEWITH, last_replace,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
&replace_history, &replace_history,
#endif #endif
@ -1027,7 +1023,6 @@ void goto_line_posx(ssize_t line, size_t pos_x)
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive, bool save_pos, bool allow_update) bool interactive, bool save_pos, bool allow_update)
{ {
bool meta_key = FALSE, func_key = FALSE;
const sc *s; const sc *s;
if (interactive) { if (interactive) {
@ -1039,7 +1034,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
TRUE, TRUE,
#endif #endif
MGOTOLINE, use_answer ? ans : "", MGOTOLINE, use_answer ? ans : "",
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
NULL, NULL,
#endif #endif
@ -1055,7 +1049,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
return; return;
} }
s = get_shortcut(currmenu, &i, &meta_key); s = get_shortcut(currmenu, &i);
if (s && s->scfunc == gototext_void) { if (s && s->scfunc == gototext_void) {
/* Keep answer up on the statusbar. */ /* Keep answer up on the statusbar. */

View File

@ -1874,7 +1874,6 @@ void do_justify(bool full_justify)
bool modified_save = openfile->modified; bool modified_save = openfile->modified;
int kbinput; int kbinput;
bool meta_key, func_key;
const sc *s; const sc *s;
/* Move to the beginning of the current line, so that justifying at /* Move to the beginning of the current line, so that justifying at
@ -2193,8 +2192,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, FALSE); kbinput = do_input(FALSE);
s = get_shortcut(MMAIN, &kbinput, &meta_key); s = get_shortcut(MMAIN, &kbinput);
if (s && s->scfunc == do_uncut_text) { if (s && s->scfunc == do_uncut_text) {
/* Splice the justify buffer back into the file, but only if we /* Splice the justify buffer back into the file, but only if we
@ -2286,7 +2285,6 @@ bool do_int_spell_fix(const char *word)
char *save_search, *save_replace; char *save_search, *save_replace;
size_t match_len, current_x_save = openfile->current_x; size_t match_len, current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant; size_t pww_save = openfile->placewewant;
bool meta_key = FALSE, func_key = FALSE;
filestruct *edittop_save = openfile->edittop; filestruct *edittop_save = openfile->edittop;
filestruct *current_save = openfile->current; filestruct *current_save = openfile->current;
/* Save where we are. */ /* Save where we are. */
@ -2374,7 +2372,6 @@ bool do_int_spell_fix(const char *word)
TRUE, TRUE,
#endif #endif
MSPELL, word, MSPELL, word,
&meta_key, &func_key,
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
NULL, NULL,
#endif #endif
@ -3117,7 +3114,6 @@ void do_linter(void)
while (1) { while (1) {
ssize_t tmpcol = 1; ssize_t tmpcol = 1;
int kbinput; int kbinput;
bool meta_key, func_key;
if (curlint->colno > 0) if (curlint->colno > 0)
tmpcol = curlint->colno; tmpcol = curlint->colno;
@ -3172,8 +3168,8 @@ void do_linter(void)
bottombars(MLINTER); bottombars(MLINTER);
} }
kbinput = get_kbinput(bottomwin, &meta_key, &func_key); kbinput = get_kbinput(bottomwin);
s = get_shortcut(currmenu, &kbinput, &meta_key); s = get_shortcut(currmenu, &kbinput);
tmplint = curlint; tmplint = curlint;
if (!s) if (!s)

View File

@ -224,17 +224,17 @@ void unget_input(int *input, size_t input_len)
} }
/* Put back the character stored in kbinput, putting it in byte range /* Put back the character stored in kbinput, putting it in byte range
* beforehand. If meta_key is TRUE, put back the Escape character after * beforehand. If metakey is TRUE, put back the Escape character after
* putting back kbinput. If func_key is TRUE, put back the function key * putting back kbinput. If funckey is TRUE, put back the function key
* (a value outside byte range) without putting it in byte range. */ * (a value outside byte range) without putting it in byte range. */
void unget_kbinput(int kbinput, bool meta_key, bool func_key) void unget_kbinput(int kbinput, bool metakey, bool funckey)
{ {
if (!func_key) if (!funckey)
kbinput = (char)kbinput; kbinput = (char)kbinput;
unget_input(&kbinput, 1); unget_input(&kbinput, 1);
if (meta_key) { if (metakey) {
kbinput = NANO_CONTROL_3; kbinput = NANO_CONTROL_3;
unget_input(&kbinput, 1); unget_input(&kbinput, 1);
} }
@ -298,20 +298,19 @@ int *get_input(WINDOW *win, size_t input_len)
/* Read in a single character. If it's ignored, swallow it and go on. /* Read in a single character. If it's ignored, swallow it and go on.
* Otherwise, try to translate it from ASCII, meta key sequences, escape * Otherwise, try to translate it from ASCII, meta key sequences, escape
* sequences, and/or extended keypad values. Set meta_key to TRUE when * sequences, and/or extended keypad values. Supported extended keypad
* we get a meta key sequence, and set func_key to TRUE when we get an * values consist of
* extended keypad value. Supported extended keypad values consist of
* [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace, * [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown), * the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
* the function keypad (F1-F16), and the numeric keypad with NumLock * the function keypad (F1-F16), and the numeric keypad with NumLock
* off. */ * off. */
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key) int get_kbinput(WINDOW *win)
{ {
int kbinput; int kbinput;
/* Read in a character and interpret it. Continue doing this until /* Read in a character and interpret it. Continue doing this until
* we get a recognized value or sequence. */ * we get a recognized value or sequence. */
while ((kbinput = parse_kbinput(win, meta_key, func_key)) == ERR) while ((kbinput = parse_kbinput(win)) == ERR)
; ;
/* If we read from the edit window, blank the statusbar if we need /* If we read from the edit window, blank the statusbar if we need
@ -326,13 +325,13 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
* sequences into their corresponding key values. Set meta_key to TRUE * sequences into their corresponding key values. Set meta_key to TRUE
* when we get a meta key sequence, and set func_key to TRUE when we get * when we get a meta key sequence, and set func_key to TRUE when we get
* a function key. */ * a function key. */
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) int parse_kbinput(WINDOW *win)
{ {
static int escapes = 0, byte_digits = 0; static int escapes = 0, byte_digits = 0;
int *kbinput, retval = ERR; int *kbinput, retval = ERR;
*meta_key = FALSE; meta_key = FALSE;
*func_key = FALSE; func_key = FALSE;
/* Read in a character. */ /* Read in a character. */
if (nodelay_mode) { if (nodelay_mode) {
@ -379,7 +378,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
* meta key sequence mode. Set meta_key to * meta key sequence mode. Set meta_key to
* TRUE, and save the lowercase version of the * TRUE, and save the lowercase version of the
* non-escape character as the result. */ * non-escape character as the result. */
*meta_key = TRUE; meta_key = TRUE;
retval = tolower(*kbinput); retval = tolower(*kbinput);
} else } else
/* One escape followed by a non-escape, and /* One escape followed by a non-escape, and
@ -469,7 +468,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
* escape counter, set meta_key to TRUE, and * escape counter, set meta_key to TRUE, and
* interpret the escape sequence. */ * interpret the escape sequence. */
escapes = 0; escapes = 0;
*meta_key = TRUE; meta_key = TRUE;
retval = parse_escape_seq_kbinput(win, retval = parse_escape_seq_kbinput(win,
*kbinput); *kbinput);
} }
@ -649,11 +648,11 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
/* If our result is an extended keypad value (i.e. a value /* If our result is an extended keypad value (i.e. a value
* outside of byte range), set func_key to TRUE. */ * outside of byte range), set func_key to TRUE. */
if (retval != ERR) if (retval != ERR)
*func_key = !is_byte(retval); func_key = !is_byte(retval);
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, func_key = %s, escapes = %d, byte_digits = %d, retval = %d\n", *kbinput, *meta_key ? "TRUE" : "FALSE", *func_key ? "TRUE" : "FALSE", escapes, byte_digits, retval); fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, func_key = %s, escapes = %d, byte_digits = %d, retval = %d\n", *kbinput, meta_key ? "TRUE" : "FALSE", func_key ? "TRUE" : "FALSE", escapes, byte_digits, retval);
#endif #endif
free(kbinput); free(kbinput);
@ -1791,26 +1790,26 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
* key itself) and meta_key (whether the key is a meta sequence). The * key itself) and meta_key (whether the key is a meta sequence). The
* returned shortcut will be the first in the list that corresponds to * returned shortcut will be the first in the list that corresponds to
* the given sequence. */ * the given sequence. */
const sc *get_shortcut(int menu, int *kbinput, bool *meta_key) const sc *get_shortcut(int menu, int *kbinput)
{ {
sc *s; sc *s;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s -- ", *kbinput, *meta_key ? "TRUE" : "FALSE"); fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s -- ", *kbinput, meta_key ? "TRUE" : "FALSE");
#endif #endif
for (s = sclist; s != NULL; s = s->next) { for (s = sclist; s != NULL; s = s->next) {
if ((menu & s->menu) && *kbinput == s->seq if ((menu & s->menu) && *kbinput == s->seq
&& *meta_key == (s->type == META)) { && meta_key == (s->type == META)) {
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "matched seq \"%s\", and btw meta was %d (menu is %x from %x)\n", fprintf (stderr, "matched seq \"%s\", and btw meta was %d (menu is %x from %x)\n",
s->keystr, *meta_key, menu, s->menu); s->keystr, meta_key, menu, s->menu);
#endif #endif
return s; return s;
} }
} }
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "matched nothing, btw meta was %d\n", *meta_key); fprintf (stderr, "matched nothing, btw meta was %d\n", meta_key);
#endif #endif
return NULL; return NULL;
@ -1820,14 +1819,13 @@ const sc *get_shortcut(int menu, int *kbinput, bool *meta_key)
const subnfunc *getfuncfromkey(WINDOW *win) const subnfunc *getfuncfromkey(WINDOW *win)
{ {
int kbinput; int kbinput;
bool func_key = FALSE, meta_key = FALSE;
const sc *s; const sc *s;
kbinput = parse_kbinput(win, &meta_key, &func_key); kbinput = parse_kbinput(win);
if (kbinput == 0) if (kbinput == 0)
return NULL; return NULL;
s = get_shortcut(currmenu, &kbinput, &meta_key); s = get_shortcut(currmenu, &kbinput);
if (!s) if (!s)
return NULL; return NULL;