Commit fc0ddab3 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

input: provide feedback on the Unicode digits typed so far

This fulfills https://savannah.gnu.org/bugs/?48154.
No related merge requests found
Showing with 17 additions and 10 deletions
+17 -10
...@@ -775,7 +775,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput); ...@@ -775,7 +775,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput);
int get_byte_kbinput(int kbinput); int get_byte_kbinput(int kbinput);
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
long add_unicode_digit(int kbinput, long factor, long *uni); long add_unicode_digit(int kbinput, long factor, long *uni);
long get_unicode_kbinput(int kbinput); long get_unicode_kbinput(WINDOW *win, int kbinput);
#endif #endif
int get_control_kbinput(int kbinput); int get_control_kbinput(int kbinput);
void unparse_kbinput(char *output, size_t output_len); void unparse_kbinput(char *output, size_t output_len);
......
...@@ -1230,7 +1230,7 @@ long add_unicode_digit(int kbinput, long factor, long *uni) ...@@ -1230,7 +1230,7 @@ long add_unicode_digit(int kbinput, long factor, long *uni)
/* Translate a Unicode sequence: turn a six-digit hexadecimal number /* Translate a Unicode sequence: turn a six-digit hexadecimal number
* (from 000000 to 10FFFF, case-insensitive) into its corresponding * (from 000000 to 10FFFF, case-insensitive) into its corresponding
* multibyte value. */ * multibyte value. */
long get_unicode_kbinput(int kbinput) long get_unicode_kbinput(WINDOW *win, int kbinput)
{ {
static int uni_digits = 0; static int uni_digits = 0;
static long uni = 0; static long uni = 0;
...@@ -1290,12 +1290,24 @@ long get_unicode_kbinput(int kbinput) ...@@ -1290,12 +1290,24 @@ long get_unicode_kbinput(int kbinput)
break; break;
} }
/* If we have a result, reset the Unicode digit counter and the /* If we have a full result, reset the Unicode digit counter and the
* Unicode sequence holder. */ * Unicode sequence holder. */
if (retval != ERR) { if (retval != ERR) {
uni_digits = 0; uni_digits = 0;
uni = 0; uni = 0;
} }
/* Show feedback only when editing, not when at a prompt. */
else if (win == edit) {
char partial[7] = "......";
/* Construct the partial result, right-padding it with dots. */
snprintf(partial, uni_digits + 1, "%06lX", uni);
partial[uni_digits] = '.';
/* TRANSLATORS: This is shown while a six-digit hexadecimal
* Unicode character code (%s) is being typed in. */
statusline(HUSH, _("Unicode Input: %s"), partial);
}
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "get_unicode_kbinput(): kbinput = %d, uni_digits = %d, uni = %ld, retval = %ld\n", kbinput, uni_digits, uni, retval); fprintf(stderr, "get_unicode_kbinput(): kbinput = %d, uni_digits = %d, uni = %ld, retval = %ld\n", kbinput, uni_digits, uni, retval);
...@@ -1413,7 +1425,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) ...@@ -1413,7 +1425,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
if (using_utf8()) { if (using_utf8()) {
/* Check whether the first keystroke is a valid hexadecimal /* Check whether the first keystroke is a valid hexadecimal
* digit. */ * digit. */
long uni = get_unicode_kbinput(*kbinput); long uni = get_unicode_kbinput(win, *kbinput);
/* If the first keystroke isn't a valid hexadecimal digit, put /* If the first keystroke isn't a valid hexadecimal digit, put
* back the first keystroke. */ * back the first keystroke. */
...@@ -1427,16 +1439,11 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) ...@@ -1427,16 +1439,11 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
char *uni_mb; char *uni_mb;
int uni_mb_len, *seq, i; int uni_mb_len, *seq, i;
if (win == edit)
/* TRANSLATORS: This is displayed during the input of a
* six-digit hexadecimal Unicode character code. */
statusbar(_("Unicode Input"));
while (uni == ERR) { while (uni == ERR) {
free(kbinput); free(kbinput);
while ((kbinput = get_input(win, 1)) == NULL) while ((kbinput = get_input(win, 1)) == NULL)
; ;
uni = get_unicode_kbinput(*kbinput); uni = get_unicode_kbinput(win, *kbinput);
} }
/* Put back the multibyte equivalent of the Unicode /* Put back the multibyte equivalent of the Unicode
......
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