implement support for PC scancodes à la CHR$(0)+CHR$(&h48)
superseding an mksh-os2 patch which confirmed this is needed Reference: my copy of the Schneider EURO PC manual 50032 for Microsoft® GW-BASIC
This commit is contained in:
51
edit.c
51
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.288 2015/07/10 17:31:09 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.289 2015/07/10 18:41:05 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -887,7 +887,7 @@ struct x_defbindings {
|
|||||||
/* Separator for motion */
|
/* Separator for motion */
|
||||||
#define is_mfs(c) (!(ksh_isalnux(c) || (c) == '$' || ((c) & 0x80)))
|
#define is_mfs(c) (!(ksh_isalnux(c) || (c) == '$' || ((c) & 0x80)))
|
||||||
|
|
||||||
#define X_NTABS 3 /* normal, meta1, meta2 */
|
#define X_NTABS 4 /* normal, meta1, meta2, pc */
|
||||||
#define X_TABSZ 256 /* size of keydef tables etc */
|
#define X_TABSZ 256 /* size of keydef tables etc */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1102,6 +1102,25 @@ static struct x_defbindings const x_defbindings[] = {
|
|||||||
{ XFUNC_del_char, 2, 'P' },
|
{ XFUNC_del_char, 2, 'P' },
|
||||||
{ XFUNC_search_hist_up | 0x80, 2, '5' },
|
{ XFUNC_search_hist_up | 0x80, 2, '5' },
|
||||||
{ XFUNC_search_hist_dn | 0x80, 2, '6' },
|
{ XFUNC_search_hist_dn | 0x80, 2, '6' },
|
||||||
|
#endif
|
||||||
|
/* PC scancodes */
|
||||||
|
#if !defined(MKSH_SMALL) || defined(__OS2__)
|
||||||
|
{ XFUNC_meta3, 0, 0 },
|
||||||
|
{ XFUNC_mv_begin, 3, 71 },
|
||||||
|
{ XFUNC_prev_com, 3, 72 },
|
||||||
|
#ifndef MKSH_SMALL
|
||||||
|
{ XFUNC_search_hist_up, 3, 73 },
|
||||||
|
#endif
|
||||||
|
{ XFUNC_mv_back, 3, 75 },
|
||||||
|
{ XFUNC_mv_forw, 3, 77 },
|
||||||
|
{ XFUNC_mv_end, 3, 79 },
|
||||||
|
{ XFUNC_next_com, 3, 80 },
|
||||||
|
#ifndef MKSH_SMALL
|
||||||
|
{ XFUNC_search_hist_dn, 3, 81 },
|
||||||
|
#endif
|
||||||
|
{ XFUNC_del_char, 3, 83 },
|
||||||
|
#endif
|
||||||
|
#ifndef MKSH_SMALL
|
||||||
/* more non-standard ones */
|
/* more non-standard ones */
|
||||||
{ XFUNC_edit_line, 2, 'e' }
|
{ XFUNC_edit_line, 2, 'e' }
|
||||||
#endif
|
#endif
|
||||||
@ -2215,6 +2234,13 @@ x_meta2(int c MKSH_A_UNUSED)
|
|||||||
return (KSTD);
|
return (KSTD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
x_meta3(int c MKSH_A_UNUSED)
|
||||||
|
{
|
||||||
|
x_curprefix = 3;
|
||||||
|
return (KSTD);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x_kill(int c MKSH_A_UNUSED)
|
x_kill(int c MKSH_A_UNUSED)
|
||||||
{
|
{
|
||||||
@ -2413,8 +2439,8 @@ x_print(int prefix, int key)
|
|||||||
|
|
||||||
if (prefix)
|
if (prefix)
|
||||||
/* prefix == 1 || prefix == 2 */
|
/* prefix == 1 || prefix == 2 */
|
||||||
shf_puts(x_mapout(prefix == 1 ?
|
shf_puts(x_mapout(prefix == 1 ? CTRL('[') :
|
||||||
CTRL('[') : CTRL('X')), shl_stdout);
|
prefix == 2 ? CTRL('X') : 0), shl_stdout);
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
shprintf("%s = ", x_mapout(key));
|
shprintf("%s = ", x_mapout(key));
|
||||||
#else
|
#else
|
||||||
@ -2479,6 +2505,8 @@ x_bind(const char *a1, const char *a2,
|
|||||||
prefix = 1;
|
prefix = 1;
|
||||||
else if (f == XFUNC_meta2)
|
else if (f == XFUNC_meta2)
|
||||||
prefix = 2;
|
prefix = 2;
|
||||||
|
else if (f == XFUNC_meta3)
|
||||||
|
prefix = 3;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3618,6 +3646,18 @@ vi_hook(int ch)
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
|
|
||||||
case VNORMAL:
|
case VNORMAL:
|
||||||
|
/* PC scancodes */
|
||||||
|
if (!ch) switch (cmdlen = 0, (ch = x_getc())) {
|
||||||
|
case 71: ch = '0'; goto pseudo_vi_command;
|
||||||
|
case 72: ch = 'k'; goto pseudo_vi_command;
|
||||||
|
case 73: ch = 'A'; goto vi_xfunc_search_up;
|
||||||
|
case 75: ch = 'h'; goto pseudo_vi_command;
|
||||||
|
case 77: ch = 'l'; goto pseudo_vi_command;
|
||||||
|
case 79: ch = '$'; goto pseudo_vi_command;
|
||||||
|
case 80: ch = 'j'; goto pseudo_vi_command;
|
||||||
|
case 83: ch = 'x'; goto pseudo_vi_command;
|
||||||
|
default: ch = 0; goto vi_insert_failed;
|
||||||
|
}
|
||||||
if (insert != 0) {
|
if (insert != 0) {
|
||||||
if (ch == CTRL('v')) {
|
if (ch == CTRL('v')) {
|
||||||
state = VLIT;
|
state = VLIT;
|
||||||
@ -3625,6 +3665,7 @@ vi_hook(int ch)
|
|||||||
}
|
}
|
||||||
switch (vi_insert(ch)) {
|
switch (vi_insert(ch)) {
|
||||||
case -1:
|
case -1:
|
||||||
|
vi_insert_failed:
|
||||||
vi_error();
|
vi_error();
|
||||||
state = VNORMAL;
|
state = VNORMAL;
|
||||||
break;
|
break;
|
||||||
@ -3647,6 +3688,7 @@ vi_hook(int ch)
|
|||||||
argc1 = ksh_numdig(ch);
|
argc1 = ksh_numdig(ch);
|
||||||
state = VARG1;
|
state = VARG1;
|
||||||
} else {
|
} else {
|
||||||
|
pseudo_vi_command:
|
||||||
curcmd[cmdlen++] = ch;
|
curcmd[cmdlen++] = ch;
|
||||||
state = nextstate(ch);
|
state = nextstate(ch);
|
||||||
if (state == VSEARCH) {
|
if (state == VSEARCH) {
|
||||||
@ -3815,6 +3857,7 @@ vi_hook(int ch)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VPREFIX2:
|
case VPREFIX2:
|
||||||
|
vi_xfunc_search_up:
|
||||||
state = VFAIL;
|
state = VFAIL;
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'A':
|
case 'A':
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#if defined(EMACSFN_DEFNS)
|
#if defined(EMACSFN_DEFNS)
|
||||||
__RCSID("$MirOS: src/bin/mksh/emacsfn.h,v 1.5 2010/07/17 22:09:33 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/emacsfn.h,v 1.6 2015/07/10 18:41:07 tg Exp $");
|
||||||
#define FN(cname,sname,flags) static int x_##cname(int);
|
#define FN(cname,sname,flags) static int x_##cname(int);
|
||||||
#elif defined(EMACSFN_ENUMS)
|
#elif defined(EMACSFN_ENUMS)
|
||||||
#define FN(cname,sname,flags) XFUNC_##cname,
|
#define FN(cname,sname,flags) XFUNC_##cname,
|
||||||
@ -52,6 +52,7 @@ FN(list_file, "list-file", 0)
|
|||||||
FN(literal, "quote", 0)
|
FN(literal, "quote", 0)
|
||||||
FN(meta1, "prefix-1", XF_PREFIX)
|
FN(meta1, "prefix-1", XF_PREFIX)
|
||||||
FN(meta2, "prefix-2", XF_PREFIX)
|
FN(meta2, "prefix-2", XF_PREFIX)
|
||||||
|
FN(meta3, "prefix-3", XF_PREFIX)
|
||||||
FN(meta_yank, "yank-pop", 0)
|
FN(meta_yank, "yank-pop", 0)
|
||||||
FN(mv_back, "backward-char", XF_ARG)
|
FN(mv_back, "backward-char", XF_ARG)
|
||||||
FN(mv_begin, "beginning-of-line", 0)
|
FN(mv_begin, "beginning-of-line", 0)
|
||||||
|
26
mksh.1
26
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.375 2015/07/09 20:20:43 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.376 2015/07/10 18:41:07 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -74,7 +74,7 @@
|
|||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: July 9 2015 $
|
.Dd $Mdocdate: July 10 2015 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" Check which macro package we use, and do other -mdoc setup.
|
||||||
.\"
|
.\"
|
||||||
@ -5398,7 +5398,7 @@ Simply causes the character to appear as literal input.
|
|||||||
Most ordinary characters are bound to this.
|
Most ordinary characters are bound to this.
|
||||||
.It Xo backward\-char:
|
.It Xo backward\-char:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
.No \*(haB , \*(haXD , ANSI-CurLeft
|
.No \*(haB , \*(haXD , ANSI-CurLeft , PC-CurLeft
|
||||||
.Xc
|
.Xc
|
||||||
Moves the cursor backward
|
Moves the cursor backward
|
||||||
.Ar n
|
.Ar n
|
||||||
@ -5415,7 +5415,7 @@ and dollar sign
|
|||||||
characters.
|
characters.
|
||||||
.It beginning\-of\-history: \*(ha[\*(Lt
|
.It beginning\-of\-history: \*(ha[\*(Lt
|
||||||
Moves to the beginning of the history.
|
Moves to the beginning of the history.
|
||||||
.It beginning\-of\-line: \*(haA, ANSI-Home
|
.It beginning\-of\-line: \*(haA, ANSI-Home, PC-Home
|
||||||
Moves the cursor to the beginning of the edited input line.
|
Moves the cursor to the beginning of the edited input line.
|
||||||
.It Xo capitalise\-word:
|
.It Xo capitalise\-word:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
@ -5471,7 +5471,7 @@ Deletes
|
|||||||
characters before the cursor.
|
characters before the cursor.
|
||||||
.It Xo delete\-char\-forward:
|
.It Xo delete\-char\-forward:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
.No ANSI-Del
|
.No ANSI-Del , PC-Del
|
||||||
.Xc
|
.Xc
|
||||||
Deletes
|
Deletes
|
||||||
.Ar n
|
.Ar n
|
||||||
@ -5492,7 +5492,7 @@ Deletes characters after the cursor up to the end of
|
|||||||
words.
|
words.
|
||||||
.It Xo down\-history:
|
.It Xo down\-history:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
.No \*(haN , \*(haXB , ANSI-CurDown
|
.No \*(haN , \*(haXB , ANSI-CurDown , PC-CurDown
|
||||||
.Xc
|
.Xc
|
||||||
Scrolls the history buffer forward
|
Scrolls the history buffer forward
|
||||||
.Ar n
|
.Ar n
|
||||||
@ -5524,7 +5524,7 @@ The actual command executed is
|
|||||||
.Ic fc \-e ${VISUAL:\-${EDITOR:\-vi}} Ar n .
|
.Ic fc \-e ${VISUAL:\-${EDITOR:\-vi}} Ar n .
|
||||||
.It end\-of\-history: \*(ha[\*(Gt
|
.It end\-of\-history: \*(ha[\*(Gt
|
||||||
Moves to the end of the history.
|
Moves to the end of the history.
|
||||||
.It end\-of\-line: \*(haE, ANSI-End
|
.It end\-of\-line: \*(haE, ANSI-End, PC-End
|
||||||
Moves the cursor to the end of the input line.
|
Moves the cursor to the end of the input line.
|
||||||
.It eot: \*(ha_
|
.It eot: \*(ha_
|
||||||
Acts as an end-of-file; this is useful because edit-mode input disables
|
Acts as an end-of-file; this is useful because edit-mode input disables
|
||||||
@ -5549,7 +5549,7 @@ globbing on the word.
|
|||||||
If no files match the pattern, the bell is rung.
|
If no files match the pattern, the bell is rung.
|
||||||
.It Xo forward\-char:
|
.It Xo forward\-char:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
.No \*(haF , \*(haXC , ANSI-CurRight
|
.No \*(haF , \*(haXC , ANSI-CurRight , PC-CurRight
|
||||||
.Xc
|
.Xc
|
||||||
Moves the cursor forward
|
Moves the cursor forward
|
||||||
.Ar n
|
.Ar n
|
||||||
@ -5663,12 +5663,12 @@ commands continue searching backward to the next previous occurrence of the
|
|||||||
pattern.
|
pattern.
|
||||||
The history buffer retains only a finite number of lines; the oldest
|
The history buffer retains only a finite number of lines; the oldest
|
||||||
are discarded as necessary.
|
are discarded as necessary.
|
||||||
.It search\-history\-up: ANSI-PgUp
|
.It search\-history\-up: ANSI-PgUp, PC-PgUp
|
||||||
Search backwards through the history buffer for commands whose beginning match
|
Search backwards through the history buffer for commands whose beginning match
|
||||||
the portion of the input line before the cursor.
|
the portion of the input line before the cursor.
|
||||||
When used on an empty line, this has the same effect as
|
When used on an empty line, this has the same effect as
|
||||||
.Ic up\-history .
|
.Ic up\-history .
|
||||||
.It search\-history\-down: ANSI-PgDn
|
.It search\-history\-down: ANSI-PgDn, PC-PgDn
|
||||||
Search forwards through the history buffer for commands whose beginning match
|
Search forwards through the history buffer for commands whose beginning match
|
||||||
the portion of the input line before the cursor.
|
the portion of the input line before the cursor.
|
||||||
When used on an empty line, this has the same effect as
|
When used on an empty line, this has the same effect as
|
||||||
@ -5688,7 +5688,7 @@ exchanges the previous and current characters and moves the cursor one
|
|||||||
character to the right.
|
character to the right.
|
||||||
.It Xo up\-history:
|
.It Xo up\-history:
|
||||||
.Op Ar n
|
.Op Ar n
|
||||||
.No \*(haP , \*(haXA , ANSI-CurUp
|
.No \*(haP , \*(haXA , ANSI-CurUp , PC-CurUp
|
||||||
.Xc
|
.Xc
|
||||||
Scrolls the history buffer backward
|
Scrolls the history buffer backward
|
||||||
.Ar n
|
.Ar n
|
||||||
@ -6116,7 +6116,7 @@ Search for the
|
|||||||
.Ar n Ns th
|
.Ar n Ns th
|
||||||
occurrence of the last search string;
|
occurrence of the last search string;
|
||||||
the direction of the search is the opposite of the last search.
|
the direction of the search is the opposite of the last search.
|
||||||
.It Ar ANSI-CurUp
|
.It Ar ANSI-CurUp , PC-PgUp
|
||||||
Take the characters from the beginning of the line to the current
|
Take the characters from the beginning of the line to the current
|
||||||
cursor position as search string and do a backwards history search
|
cursor position as search string and do a backwards history search
|
||||||
for lines beginning with this string; keep the cursor position.
|
for lines beginning with this string; keep the cursor position.
|
||||||
@ -6267,6 +6267,8 @@ times.
|
|||||||
Undo the last edit command.
|
Undo the last edit command.
|
||||||
.It U
|
.It U
|
||||||
Undo all changes that have been made to the current line.
|
Undo all changes that have been made to the current line.
|
||||||
|
.It PC Home, End, Del, and cursor keys
|
||||||
|
They move as expected, both in insert and command mode.
|
||||||
.It Ar intr No and Ar quit
|
.It Ar intr No and Ar quit
|
||||||
The interrupt and quit terminal characters cause the current line to be
|
The interrupt and quit terminal characters cause the current line to be
|
||||||
deleted and a new prompt to be printed.
|
deleted and a new prompt to be printed.
|
||||||
|
Reference in New Issue
Block a user