- Add a func_key flag to the low-level input functions and the
currently existing high-level input functions, to indicate
extended keypad values. This is needed for UTF-8 support.
- Changes to get_kbinput(), get_translated_kbinput(),
- get_shortcut(), get_edit_input(), etc. (DLR)
+ Changes to unget_kbinput(), get_kbinput(),
+ get_translated_kbinput(), get_shortcut(), get_edit_input(),
+ etc. (DLR)
- Add a multibuffer mode toggle to the "Execute Command" prompt,
for consistency with the "Read File" prompt. Changes to
do_insertfile() and shortcut_init(). (DLR)
if (selected > numents - 1)
selected = numents - 1;
else if (selectedbackup == selected)
- unget_kbinput('s', FALSE); /* Unget the 'select' key */
- } else { /* Must be clicking a shortcut */
+ /* Unget the 'select' key */
+ unget_kbinput('s', FALSE, FALSE);
+ } else {
+ /* Must be clicking a shortcut */
int mouse_x, mouse_y;
get_mouseinput(&mouse_x, &mouse_y, TRUE);
}
#ifndef NANO_SMALL
void reset_kbinput(void);
#endif
-void unget_kbinput(int kbinput, bool meta_key);
+void unget_kbinput(int kbinput, bool meta_key, bool func_key);
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
int get_translated_kbinput(int kbinput, seq_type *seq
#ifndef NANO_SMALL
/* 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)
+void unget_kbinput(int kbinput, bool meta_key, bool func_key)
{
- ungetch(kbinput);
+ /* If this character is outside the ASCII range and func_key is
+ * FALSE, treat it as a wide character and put back its equivalent
+ * multibyte sequence. */
+ if (kbinput > 255 && !func_key)
+ {
+ int i;
+ char *s = charalloc(MB_CUR_MAX + 1);
+ wchar_t wc = (wchar_t)kbinput;
+
+ i = wctomb(s, wc);
+
+ if (i == -1)
+ /* This wide character is unrecognized. Send it back. */
+ ungetch(kbinput);
+ else {
+ for (; i > 0; i--)
+ ungetch(s[i - 1]);
+ }
+ free(s);
+ } else
+ ungetch(kbinput);
if (meta_key)
ungetch(NANO_CONTROL_3);
}
/* This escape sequence is unrecognized. Send
* it back. */
for (; seq_len > 1; seq_len--)
- unget_kbinput(sequence[seq_len - 1], FALSE);
+ unget_kbinput(sequence[seq_len - 1], FALSE,
+ FALSE);
retval = sequence[0];
}
}
/* This UTF-8 sequence is unrecognized. Send it
* back. */
for (; seq_len > 1; seq_len--)
- unget_kbinput(sequence[seq_len - 1], FALSE);
+ unget_kbinput(sequence[seq_len - 1], FALSE,
+ FALSE);
retval = sequence[0];
} else
retval = wc;
+ free(s);
}
free(sequence);
}
* has, at the very least, an equivalent control key, an
* equivalent primary meta key sequence, or both. */
if (s->ctrlval != NANO_NO_KEY)
- unget_kbinput(s->ctrlval, FALSE);
+ unget_kbinput(s->ctrlval, FALSE, FALSE);
else if (s->metaval != NANO_NO_KEY)
- unget_kbinput(s->metaval, TRUE);
+ unget_kbinput(s->metaval, TRUE, FALSE);
return TRUE;
}