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.
This commit is contained in:
Joachim Nilsson 2010-07-25 22:01:04 +02:00
parent dbad0d0871
commit 67e9aa3f2b
2 changed files with 24 additions and 34 deletions

View File

@ -25,7 +25,7 @@
typedef char* (*rl_complete_func_t)(char*, int*); typedef char* (*rl_complete_func_t)(char*, int*);
typedef int (*rl_list_possib_func_t)(char*, char***); 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; extern int rl_meta_chars;
/* Use these functions to set custom command/file completion, see cli.c for example usage. */ /* Use these functions to set custom command/file completion, see cli.c for example usage. */

View File

@ -110,7 +110,7 @@ int el_no_echo = 0; /* e.g., under Emacs */
int rl_point; int rl_point;
int rl_mark; int rl_mark;
int rl_end; 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; char *rl_line_buffer;
const char *rl_readline_name;/* Set by calling program, for conditional parsing of ~/.inputrc - Not supported yet! */ 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('^');
tty_put('?'); tty_put('?');
} }
else if (ISCTL(c)) {
tty_put('^');
tty_put(UNCTL(c));
}
else if (rl_meta_chars && ISMETA(c)) { else if (rl_meta_chars && ISMETA(c)) {
tty_put('M'); tty_put('M');
tty_put('-'); tty_put('-');
tty_put(UNMETA(c)); tty_put(UNMETA(c));
} }
else #if 0
else if (ISCTL(c)) {
tty_put('^');
tty_put(UNCTL(c));
}
#endif
else {
tty_put(c); tty_put(c);
}
} }
static void tty_string(char *p) static void tty_string(char *p)
@ -861,26 +864,30 @@ static el_status_t meta(void)
static el_status_t emacs(int c) static el_status_t emacs(int c)
{ {
el_status_t s; el_status_t s;
el_keymap_t *kp; 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 /* This test makes it impossible to enter eight-bit characters when
* meta-char mode is enabled. */ * meta-char mode is enabled. */
OldPoint = rl_point;
if (rl_meta_chars && ISMETA(c)) { if (rl_meta_chars && ISMETA(c)) {
Pushed = 1; Pushed = 1;
PushBack = UNMETA(c); PushBack = UNMETA(c);
return meta(); return meta();
} }
#endif /* Debian patch removal. */
for (kp = Map; kp->Function; kp++) for (kp = Map; kp->Function; kp++) {
if (kp->Key == c) if (kp->Key == c)
break; 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. */ /* No pushback means no repeat count; hacky, but true. */
Repeat = NO_ARG; Repeat = NO_ARG;
}
return s; return s;
} }
@ -1241,23 +1248,6 @@ static el_status_t quote(void)
return (c = tty_get()) == EOF ? CSeof : insert_char((int)c); 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) static el_status_t mk_set(void)
{ {
rl_mark = rl_point; rl_mark = rl_point;
@ -1467,8 +1457,8 @@ static el_keymap_t Map[] = {
}; };
static el_keymap_t MetaMap[]= { static el_keymap_t MetaMap[]= {
{ CTL('H'), wipe }, { CTL('H'), bk_kill_word },
{ DEL, wipe }, { DEL, bk_kill_word },
{ ' ', mk_set }, { ' ', mk_set },
{ '.', last_argument }, { '.', last_argument },
{ '<', h_first }, { '<', h_first },