1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-10 06:26:04 -05:00

Fix regression on key command input for M-^X and ^X^X.

This commit is contained in:
Renaud 2021-08-07 13:46:14 +08:00
parent c55a72ad26
commit 1cdc889f6f
2 changed files with 28 additions and 26 deletions

18
bind.c
View File

@ -448,22 +448,19 @@ static const char *getfname( unsigned keycode, const char *failmsg) {
* String key name TO Command Key * String key name TO Command Key
* *
* char *keyname; name of key to translate to Command key form * char *keyname; name of key to translate to Command key form
* fmt: [M-][^X][^][FN]X * fmt: [M-|^X][^][FN]X
* returns ~0 on invalid sequence * returns ~0 on invalid sequence
*/ */
static unsigned int stock( char *keyname) { static unsigned int stock( char *keyname) {
/* parse it up */ /* parse it up */
unsigned c = 0 ; unsigned c = 0 ;
/* first, the META prefix */ /* first, the prefix META or ^X */
if( *keyname == 'M' && keyname[ 1] == '-') { if( *keyname == 'M' && keyname[ 1] == '-') {
c = META ; c = META ;
keyname += 2 ; keyname += 2 ;
} } else if( *keyname == '^' && keyname[ 1] == 'X') {
c = CTLX ;
/* control-x prefix */
if( *keyname == '^' && keyname[ 1] == 'X') {
c |= CTLX ;
keyname += 2 ; keyname += 2 ;
} }
@ -487,10 +484,9 @@ static unsigned int stock( char *keyname) {
if( *keyname < 32 || *keyname == 0x7F) { if( *keyname < 32 || *keyname == 0x7F) {
c |= CTRL ; c |= CTRL ;
*keyname ^= 0x40 ; *keyname ^= 0x40 ;
} } else if( c && !(c & SPEC)
&& *keyname >= 'a' && *keyname <= 'z')
/* make sure we are not lower case (not with function keys) */ /* make sure we are not lower case (not with function keys) */
if( *keyname >= 'a' && *keyname <= 'z' && !(c & SPEC))
*keyname -= 32 ; *keyname -= 32 ;
/* the final sequence... */ /* the final sequence... */

36
input.c
View File

@ -371,11 +371,10 @@ int get1key( void) {
} }
/* GETCMD: Get a command from the keyboard. Process all applicable prefix /* GETCMD: Get a command from the keyboard. Process all applicable prefix
keys. Handle alted and controlled FNx, not shifted. Allow double keys. Handle alted and controlled FNx, not shifted.
prefix M-^X.
*/ */
int getcmd( void) { int getcmd( void) {
int cmask = 0 ; /* prefixes M- & ^X */ int prefix = 0 ; /* prefixes M- or ^X */
int keyread[ STACKSIZE] ; /* room to process sequences like ^[[24;2~ */ int keyread[ STACKSIZE] ; /* room to process sequences like ^[[24;2~ */
int *kptr = keyread ; int *kptr = keyread ;
int c ; int c ;
@ -390,7 +389,7 @@ int getcmd( void) {
if( c == 'O') { /* F1 .. F4 */ if( c == 'O') { /* F1 .. F4 */
c = *(kptr++) = get1key() ; c = *(kptr++) = get1key() ;
if( c >= 'P' && c <= 'S') if( c >= 'P' && c <= 'S')
return c | SPEC | cmask ; return c | SPEC | prefix ;
} else if( c == '[') { } else if( c == '[') {
int v1, v ; /* ^[[v1;v~ or ^[[v~ */ int v1, v ; /* ^[[v1;v~ or ^[[v~ */
@ -398,14 +397,17 @@ int getcmd( void) {
v1 = v = 0 ; v1 = v = 0 ;
while( kptr < &keyread[ STACKSIZE]) { while( kptr < &keyread[ STACKSIZE]) {
c = *(kptr++) = get1key() ; c = *(kptr++) = get1key() ;
if( (c == '~') || (c >= 'A' && c <= 'Z')) { if( (c == '~')
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z')) {
/* Found end of sequence */ /* Found end of sequence */
int mask = prefix ;
if( v1) { /* Handle ALT/CTL, not SHFT */ if( v1) { /* Handle ALT/CTL, not SHFT */
if( (v - 1) & 4)
cmask |= CTRL ;
if( (v - 1) & 2) if( (v - 1) & 2)
cmask |= META ; mask = META ;
if( (v - 1) & 4)
mask |= CTRL ;
v = v1 ; v = v1 ;
} }
@ -417,7 +419,7 @@ int getcmd( void) {
break ; break ;
} }
return c | SPEC | cmask ; return c | SPEC | mask ;
} else if( c == ';') { /* Start of SHFT/ALT/CTL state */ } else if( c == ';') { /* Start of SHFT/ALT/CTL state */
v1 = v ; v1 = v ;
v = 0 ; v = 0 ;
@ -433,20 +435,24 @@ int getcmd( void) {
KPUSH( *(--kptr)) ; KPUSH( *(--kptr)) ;
c = get1key() ; c = get1key() ;
} } else
kptr-- ;
if( c == metac) { if( c == metac) {
cmask |= META ; prefix = META ;
} else if( c == ctlxc) { } else if( c == ctlxc) {
cmask |= CTLX ; if( prefix)
break ; /* ^X^X or M-^X */
else
prefix = CTLX ;
} else } else
break ; break ;
} }
if( cmask && islower( c)) if( prefix && islower( c))
c = flipcase( c) ; c = flipcase( c) ;
return c | cmask ; return c | prefix ;
} }
/* A more generalized prompt/reply function allowing the caller /* A more generalized prompt/reply function allowing the caller