Map DEL (0x7F) consistently to CTL-? so that it can be bound with bind-to-key command.

Revise Y/N prompt and function name keying.
This commit is contained in:
Renaud 2019-08-09 20:47:05 +08:00
parent 52a386ed01
commit 81431d2d76
2 changed files with 21 additions and 34 deletions

View File

@ -35,6 +35,7 @@
* control-X commands. * control-X commands.
*/ */
struct key_tab keytab[NBINDS] = { struct key_tab keytab[NBINDS] = {
{CONTROL | '?', backdel},
{CONTROL | 'A', (fn_t) gotobol} {CONTROL | 'A', (fn_t) gotobol}
, ,
{CONTROL | 'B', (fn_t) backchar} {CONTROL | 'B', (fn_t) backchar}
@ -206,6 +207,7 @@ struct key_tab keytab[NBINDS] = {
, ,
{CTLX | 'Z', enlargewind} {CTLX | 'Z', enlargewind}
, ,
{META | CONTROL | '?', delbword},
#if WORDPRO #if WORDPRO
{META | CONTROL | 'C', wordcount} {META | CONTROL | 'C', wordcount}
, ,
@ -315,8 +317,6 @@ struct key_tab keytab[NBINDS] = {
, ,
{META | 'Z', quickexit} {META | 'Z', quickexit}
, ,
{META | 0x7F, delbword}
,
#if VT220 #if VT220
{SPEC | '1', (fn_t) gotobob /* fisearch */} {SPEC | '1', (fn_t) gotobob /* fisearch */}
@ -353,9 +353,6 @@ struct key_tab keytab[NBINDS] = {
, ,
#endif #endif
{0x7F, backdel}
,
/* special internal bindings */ /* special internal bindings */
{ SPEC | META | 'W', wrapword }, /* called on word wrap */ { SPEC | META | 'W', wrapword }, /* called on word wrap */
{ SPEC | META | 'C', nullproc }, /* every command input */ { SPEC | META | 'C', nullproc }, /* every command input */

48
input.c
View File

@ -65,16 +65,16 @@ void ue_system( const char *cmd) {
*/ */
int mlyesno( const char *prompt) int mlyesno( const char *prompt)
{ {
char c; /* input character */ int c ; /* input character */
for (;;) { for (;;) {
/* prompt the user */ /* prompt the user */
mlwrite( "%s (y/n)? ", prompt) ; mlwrite( "%s (y/n)? ", prompt) ;
/* get the response */ /* get the response */
c = tgetc(); c = get1key() ;
if (c == ectoc(abortc)) /* Bail out! */ if( c == abortc) /* Bail out! */
return ABORT; return ABORT;
if (c == 'y' || c == 'Y') if (c == 'y' || c == 'Y')
@ -147,13 +147,14 @@ int newmlargt( char **outbufref, const char *prompt, int size) {
* expanded character to character * expanded character to character
* collapse the CONTROL and SPEC flags back into an ascii code * collapse the CONTROL and SPEC flags back into an ascii code
*/ */
int ectoc(int c) int ectoc( int c) {
{ if( c & CONTROL)
if (c & CONTROL) c ^= CONTROL | 0x40 ;
c = c & ~(CONTROL | 0x40);
if (c & SPEC) if( c & SPEC)
c = c & 255; c &= 255 ;
return c;
return c ;
} }
/* /*
@ -284,7 +285,7 @@ fn_t getname(void)
TTflush(); TTflush();
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
} else { } else {
if (cpos < NSTRING - 1 && c > ' ') { if( cpos < NSTRING - 1 && (islower( c) || c == '-')) {
buf[cpos++] = c; buf[cpos++] = c;
echoc( c) ; echoc( c) ;
TTflush(); TTflush();
@ -344,29 +345,18 @@ int tgetc(void)
return c; return c;
} }
/* GET1KEY: Get one keystroke. The only prefixs legal here /* GET1KEY: Get one keystroke. The only prefixs legal here are the SPEC
are the SPEC and CONTROL prefixes. and CONTROL prefixes. */
*/ int get1key( void) {
int c ;
int get1key(void)
{
int c;
/* get a keystroke */ /* get a keystroke */
c = tgetc(); c = tgetc();
#if MSDOS if( (c >= 0x00 && c <= 0x1F) || c == 0x7F) /* C0 control -> C- */
if (c == 0) { /* Apply SPEC prefix */ c ^= CONTROL | 0x40 ;
c = tgetc();
if (c >= 0x00 && c <= 0x1F) /* control key? */
c = CONTROL | (c + '@');
return SPEC | c;
}
#endif
if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */ return c ;
c = CONTROL | (c + '@');
return c;
} }
/* GETCMD: Get a command from the keyboard. Process all applicable /* GETCMD: Get a command from the keyboard. Process all applicable