add unget_kbinput(), a wrapper for ungetch()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1911 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
a0b5ba2f7f
Коммит
dfca1c4ea6
@ -16,6 +16,8 @@ CVS code -
|
|||||||
parsing the numeric argument after "tabsize" works properly
|
parsing the numeric argument after "tabsize" works properly
|
||||||
again. (DLR, found by Mike Frysinger)
|
again. (DLR, found by Mike Frysinger)
|
||||||
- winio.c:
|
- winio.c:
|
||||||
|
unget_kbinput()
|
||||||
|
- New function used as a wrapper for ungetch(). (DLR)
|
||||||
get_mouseinput()
|
get_mouseinput()
|
||||||
- Consolidate two if statements to increase efficiency. (DLR)
|
- Consolidate two if statements to increase efficiency. (DLR)
|
||||||
do_yesno()
|
do_yesno()
|
||||||
|
@ -2619,7 +2619,7 @@ char *do_browser(const char *inpath)
|
|||||||
if (selected > numents - 1)
|
if (selected > numents - 1)
|
||||||
selected = numents - 1;
|
selected = numents - 1;
|
||||||
else if (selectedbackup == selected)
|
else if (selectedbackup == selected)
|
||||||
ungetch('s'); /* Unget the 'select' key */
|
unget_kbinput('s', FALSE); /* Unget the 'select' key */
|
||||||
} else { /* Must be clicking a shortcut */
|
} else { /* Must be clicking a shortcut */
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||||
|
@ -2609,9 +2609,7 @@ void do_justify(bool full_justify)
|
|||||||
edit_refresh();
|
edit_refresh();
|
||||||
} else {
|
} else {
|
||||||
placewewant = 0;
|
placewewant = 0;
|
||||||
ungetch(kbinput);
|
unget_kbinput(kbinput, meta_key);
|
||||||
if (meta_key)
|
|
||||||
ungetch(NANO_CONTROL_3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cutbuffer = cutbuffer_save;
|
cutbuffer = cutbuffer_save;
|
||||||
|
@ -491,6 +491,7 @@ int check_wildcard_match(const char *text, const char *pattern);
|
|||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void reset_kbinput(void);
|
void reset_kbinput(void);
|
||||||
#endif
|
#endif
|
||||||
|
void unget_kbinput(int kbinput, bool meta_key);
|
||||||
int get_kbinput(WINDOW *win, bool *meta_key);
|
int get_kbinput(WINDOW *win, bool *meta_key);
|
||||||
int get_translated_kbinput(int kbinput, bool *es
|
int get_translated_kbinput(int kbinput, bool *es
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
37
src/winio.c
37
src/winio.c
@ -99,6 +99,15 @@ void reset_kbinput(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Put back the input character stored in kbinput. If meta_key is TRUE,
|
||||||
|
* put back the Escape character after putting back kbinput. */
|
||||||
|
void unget_kbinput(int kbinput, bool meta_key)
|
||||||
|
{
|
||||||
|
ungetch(kbinput);
|
||||||
|
if (meta_key)
|
||||||
|
ungetch(NANO_CONTROL_3);
|
||||||
|
}
|
||||||
|
|
||||||
/* Read in a single input character. If it's ignored, swallow it and go
|
/* Read in a single input character. If it's ignored, swallow it and go
|
||||||
* on. Otherwise, try to translate it from ASCII, extended keypad
|
* on. Otherwise, try to translate it from ASCII, extended keypad
|
||||||
* values, and/or escape sequences. Set meta_key to TRUE when we get a
|
* values, and/or escape sequences. Set meta_key to TRUE when we get a
|
||||||
@ -147,7 +156,7 @@ int get_kbinput(WINDOW *win, bool *meta_key)
|
|||||||
|
|
||||||
/* Next, send back the character we got and read in the
|
/* Next, send back the character we got and read in the
|
||||||
* complete escape sequence. */
|
* complete escape sequence. */
|
||||||
ungetch(kbinput);
|
unget_kbinput(kbinput, FALSE);
|
||||||
escape_seq = get_verbatim_kbinput(win, escape_seq, &es_len,
|
escape_seq = get_verbatim_kbinput(win, escape_seq, &es_len,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
@ -166,7 +175,7 @@ int get_kbinput(WINDOW *win, bool *meta_key)
|
|||||||
/* This escape sequence is unrecognized. Send it
|
/* This escape sequence is unrecognized. Send it
|
||||||
* back. */
|
* back. */
|
||||||
for (; es_len > 1; es_len--)
|
for (; es_len > 1; es_len--)
|
||||||
ungetch(escape_seq[es_len - 1]);
|
unget_kbinput(escape_seq[es_len - 1], FALSE);
|
||||||
retval = escape_seq[0];
|
retval = escape_seq[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1243,9 +1252,9 @@ int get_untranslated_kbinput(int kbinput, size_t position, bool
|
|||||||
* coordinates where it took place in mouse_x and mouse_y. After that,
|
* coordinates where it took place in mouse_x and mouse_y. After that,
|
||||||
* assuming allow_shortcuts is FALSE, if the shortcut list on the
|
* assuming allow_shortcuts is FALSE, if the shortcut list on the
|
||||||
* bottom two lines of the screen is visible and the mouse event took
|
* bottom two lines of the screen is visible and the mouse event took
|
||||||
* place on it, figure out which shortcut was clicked and ungetch() the
|
* place on it, figure out which shortcut was clicked and put back the
|
||||||
* equivalent keystroke(s). Return FALSE if no keystrokes were
|
* equivalent keystroke(s). Return FALSE if no keystrokes were
|
||||||
* ungetch()ed, or TRUE if at least one was. Assume that KEY_MOUSE has
|
* put back, or TRUE if at least one was. Assume that KEY_MOUSE has
|
||||||
* already been read in. */
|
* already been read in. */
|
||||||
bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||||
{
|
{
|
||||||
@ -1265,7 +1274,7 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
|||||||
/* If we're allowing shortcuts, the current shortcut list is being
|
/* If we're allowing shortcuts, the current shortcut list is being
|
||||||
* displayed on the last two lines of the screen, and the mouse
|
* displayed on the last two lines of the screen, and the mouse
|
||||||
* event took place inside it, we need to figure out which shortcut
|
* event took place inside it, we need to figure out which shortcut
|
||||||
* was clicked and ungetch() the equivalent keystroke(s) for it. */
|
* was clicked and put back the equivalent keystroke(s) for it. */
|
||||||
if (allow_shortcuts && !ISSET(NO_HELP) && wenclose(bottomwin,
|
if (allow_shortcuts && !ISSET(NO_HELP) && wenclose(bottomwin,
|
||||||
*mouse_y, *mouse_x)) {
|
*mouse_y, *mouse_x)) {
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -1306,16 +1315,12 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
|||||||
for (; j > 0; j--)
|
for (; j > 0; j--)
|
||||||
s = s->next;
|
s = s->next;
|
||||||
|
|
||||||
/* And ungetch() the equivalent control key. If it's a meta key
|
/* And put back the equivalent key. Assume that the shortcut
|
||||||
* sequence, we need to ungetch() Escape too. Assume that the
|
* has an equivalent control key, meta key sequence, or both. */
|
||||||
* shortcut has an equivalent control key, meta key sequence, or
|
|
||||||
* both. */
|
|
||||||
if (s->ctrlval != NANO_NO_KEY)
|
if (s->ctrlval != NANO_NO_KEY)
|
||||||
ungetch(s->ctrlval);
|
unget_kbinput(s->ctrlval, FALSE);
|
||||||
else if (s->ctrlval != NANO_NO_KEY) {
|
else if (s->ctrlval != NANO_NO_KEY)
|
||||||
ungetch(s->metaval);
|
unget_kbinput(s->metaval, TRUE);
|
||||||
ungetch(NANO_CONTROL_3);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -2022,7 +2027,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||||||
#endif
|
#endif
|
||||||
if (meta_key && (kbinput == t->metaval || kbinput == t->miscval))
|
if (meta_key && (kbinput == t->metaval || kbinput == t->miscval))
|
||||||
/* We hit a meta key. Do like above. We don't
|
/* We hit a meta key. Do like above. We don't
|
||||||
* just ungetch() the letter and let it get
|
* just put back the letter and let it get
|
||||||
* caught above cause that screws the
|
* caught above cause that screws the
|
||||||
* keypad... */
|
* keypad... */
|
||||||
return kbinput;
|
return kbinput;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user