From 67e9aa3f2b27f704adae0235f834c27d9eadb0e0 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 25 Jul 2010 22:01:04 +0200 Subject: [PATCH] Revert broken Debian patch for 8-bit char input, fix tty_show() instead. This changeset fixes an old Debian patch that attempted to fix the display of 8-bit characters in the function emacs(). It accidentally crippled the function of M-d and M-DEL. The latter was however also broken by being mapped to wipe(), more on that below. The real fix is to set rl_meta_chars to 0 by default and in the tty_show() function, which tried to be smart and output control and meta characters (in the wrong order as well). Simply disabling the special code for output of control characters fixes 8-bit input. We also nuke the old and broken wipe() function that was mapped to M-DEL, instead we map that key binding to bk_kill_word(), which works. --- include/editline.h | 2 +- src/editline.c | 56 +++++++++++++++++++--------------------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/include/editline.h b/include/editline.h index 5b8f922..9684410 100644 --- a/include/editline.h +++ b/include/editline.h @@ -25,7 +25,7 @@ typedef char* (*rl_complete_func_t)(char*, int*); typedef int (*rl_list_possib_func_t)(char*, char***); -/* Display print 8-bit chars as `M-x' or as the actual 8-bit char? (Default:1) */ +/* Display 8-bit chars "as-is" or as `M-x'? Toggle with M-m. (Default:0 - "as-is") */ extern int rl_meta_chars; /* Use these functions to set custom command/file completion, see cli.c for example usage. */ diff --git a/src/editline.c b/src/editline.c index 2820fd5..d533428 100644 --- a/src/editline.c +++ b/src/editline.c @@ -110,7 +110,7 @@ int el_no_echo = 0; /* e.g., under Emacs */ int rl_point; int rl_mark; int rl_end; -int rl_meta_chars = 1; /* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */ +int rl_meta_chars = 0; /* Display 8-bit chars as the actual char(0) or as `M-x'(1)? */ char *rl_line_buffer; const char *rl_readline_name;/* Set by calling program, for conditional parsing of ~/.inputrc - Not supported yet! */ @@ -161,17 +161,20 @@ static void tty_show(char c) tty_put('^'); tty_put('?'); } - else if (ISCTL(c)) { - tty_put('^'); - tty_put(UNCTL(c)); - } else if (rl_meta_chars && ISMETA(c)) { tty_put('M'); tty_put('-'); tty_put(UNMETA(c)); } - else +#if 0 + else if (ISCTL(c)) { + tty_put('^'); + tty_put(UNCTL(c)); + } +#endif + else { tty_put(c); + } } static void tty_string(char *p) @@ -861,26 +864,30 @@ static el_status_t meta(void) static el_status_t emacs(int c) { - el_status_t s; - el_keymap_t *kp; + el_status_t s; + el_keymap_t *kp; + + /* Save point before interpreting input character 'c'. */ + OldPoint = rl_point; -#if 0 /* Debian patch removes this to be able to handle 8-bit input */ /* This test makes it impossible to enter eight-bit characters when * meta-char mode is enabled. */ - OldPoint = rl_point; if (rl_meta_chars && ISMETA(c)) { Pushed = 1; PushBack = UNMETA(c); return meta(); } -#endif /* Debian patch removal. */ - for (kp = Map; kp->Function; kp++) + + for (kp = Map; kp->Function; kp++) { if (kp->Key == c) break; - s = kp->Function ? (*kp->Function)() : insert_char((int)c); - if (!Pushed) + } + s = kp->Function ? (*kp->Function)() : insert_char(c); + if (!Pushed) { /* No pushback means no repeat count; hacky, but true. */ Repeat = NO_ARG; + } + return s; } @@ -1241,23 +1248,6 @@ static el_status_t quote(void) return (c = tty_get()) == EOF ? CSeof : insert_char((int)c); } -static el_status_t wipe(void) -{ - int i; - - if (rl_mark > rl_end) - return ring_bell(); - - if (rl_point > rl_mark) { - i = rl_point; - rl_point = rl_mark; - rl_mark = i; - reposition(); - } - - return delete_string(rl_mark - rl_point); -} - static el_status_t mk_set(void) { rl_mark = rl_point; @@ -1467,8 +1457,8 @@ static el_keymap_t Map[] = { }; static el_keymap_t MetaMap[]= { - { CTL('H'), wipe }, - { DEL, wipe }, + { CTL('H'), bk_kill_word }, + { DEL, bk_kill_word }, { ' ', mk_set }, { '.', last_argument }, { '<', h_first },