slackbuilds_ponce/system/pdksh/patches/109_mksh-delete_key.patch
2010-05-13 01:01:03 +02:00

115 lines
3.1 KiB
Diff

Patch from mksh to make delete key work (closes: #190566)
Index: pdksh-5.2.14/emacs.c
===================================================================
--- pdksh-5.2.14.orig/emacs.c 2009-09-15 20:59:29.000000000 +0200
+++ pdksh-5.2.14/emacs.c 2009-09-15 21:06:50.000000000 +0200
@@ -327,6 +327,26 @@
{ XFUNC_next_com, 2, 'B' },
{ XFUNC_mv_forw, 2, 'C' },
{ XFUNC_mv_back, 2, 'D' },
+ /* These for ansi arrow keys: arguablely shouldn't be here by
+ * default, but its simpler/faster/smaller than using termcap
+ * entries.
+ */
+ { XFUNC_meta2, 1, '[' },
+ { XFUNC_meta2, 1, 'O' },
+ { XFUNC_prev_com, 2, 'A' },
+ { XFUNC_next_com, 2, 'B' },
+ { XFUNC_mv_forw, 2, 'C' },
+ { XFUNC_mv_back, 2, 'D' },
+ { XFUNC_mv_begin | 0x80, 2, '1' },
+ { XFUNC_mv_begin | 0x80, 2, '7' },
+ { XFUNC_mv_begin, 2, 'H' },
+ { XFUNC_mv_end | 0x80, 2, '4' },
+ { XFUNC_mv_end | 0x80, 2, '8' },
+ { XFUNC_mv_end, 2, 'F' },
+ { XFUNC_del_char | 0x80, 2, '3' },
+ { XFUNC_prev_com | 0x80, 2, '5' },
+ { XFUNC_next_com | 0x80, 2, '6' },
+
};
int
@@ -371,7 +391,14 @@
return 0;
f = x_curprefix == -1 ? XFUNC_insert
- : x_tab[x_curprefix][c&CHARMASK];
+ : x_tab[x_curprefix][c&CHARMASK] ;
+
+ if (f & 0x80) {
+ f &= 0x7F;
+ if ((i = x_e_getc()) != '~')
+ x_e_ungetc(i);
+ }
+
if (!(x_ftab[f].xf_flags & XF_PREFIX)
&& x_last_command != XFUNC_set_arg)
@@ -1385,6 +1412,7 @@
x_print(prefix, key)
int prefix, key;
{
+ int f = x_tab[prefix][key];
if (prefix == 1)
shprintf("%s", x_mapout(x_prefix1));
if (prefix == 2)
@@ -1393,9 +1421,9 @@
if (prefix == 3)
shprintf("%s", x_mapout(x_prefix3));
#endif /* OS2 */
- shprintf("%s = ", x_mapout(key));
- if (x_tab[prefix][key] != XFUNC_ins_string)
- shprintf("%s\n", x_ftab[x_tab[prefix][key]].xf_name);
+ shprintf("%s%s = ", x_mapout(key), (f & 0x80) ? "~" : "");
+ if ((f & 0x7F) != XFUNC_ins_string)
+ shprintf("%s\n", x_ftab[f & 0x7F].xf_name);
else
shprintf("'%s'\n", x_atab[prefix][key]);
}
@@ -1410,6 +1438,7 @@
int prefix, key;
char *sp = NULL;
char *m1, *m2;
+ char hastilde;
if (x_tab == NULL) {
bi_errorf("cannot bind, not a tty");
@@ -1437,7 +1466,7 @@
return 0;
}
- m1 = x_mapin(a1);
+ m2 = m1 = x_mapin(a1);
prefix = key = 0;
for (;; m1++) {
key = *m1 & CHARMASK;
@@ -1453,6 +1482,19 @@
break;
}
+ if (*++m1 && ((*m1 != '~') || *(m1+1))) {
+ char msg[256] = "key sequence '";
+ const char *c = a1;
+ m1 = msg + strlen(msg);
+ while (*c && m1 < (msg + sizeof(msg) - 3))
+ strcat(msg, x_mapout(*c++));
+ bi_errorf("%s' too long", msg);
+ return (1);
+ }
+
+ hastilde = *m1;
+ afree(m2, ATEMP);
+
if (a2 == NULL) {
x_print(prefix, key);
return 0;
@@ -1483,7 +1525,7 @@
if (x_tab[prefix][key] == XFUNC_ins_string && x_atab[prefix][key])
afree((void *)x_atab[prefix][key], AEDIT);
- x_tab[prefix][key] = f;
+ x_tab[prefix][key] = f | (hastilde ? 0x80 : 0);
x_atab[prefix][key] = sp;
/* Track what the user has bound so x_emacs_keys() won't toast things */