mirror of
https://github.com/rfivet/uemacs.git
synced 2024-10-01 09:45:58 -04:00
Review universal arg command and Alt-# processing in kbd_loop.
This commit is contained in:
parent
7188773d13
commit
f781d458aa
100
execute.c
100
execute.c
@ -315,7 +315,6 @@ void kbd_loop( void) {
|
|||||||
int basec ; /* c stripped of meta character */
|
int basec ; /* c stripped of meta character */
|
||||||
int f ; /* default flag */
|
int f ; /* default flag */
|
||||||
int n ; /* numeric repeat count */
|
int n ; /* numeric repeat count */
|
||||||
int mflag ; /* negative flag on repeat */
|
|
||||||
|
|
||||||
/* Execute the "command" macro...normally null. */
|
/* Execute the "command" macro...normally null. */
|
||||||
saveflag = lastflag ; /* Preserve lastflag through this. */
|
saveflag = lastflag ; /* Preserve lastflag through this. */
|
||||||
@ -365,80 +364,49 @@ void kbd_loop( void) {
|
|||||||
n = 1 ;
|
n = 1 ;
|
||||||
|
|
||||||
/* do META-# processing if needed */
|
/* do META-# processing if needed */
|
||||||
|
|
||||||
if( (c & META)
|
|
||||||
&& (((basec = c & ~META) >= '0' && basec <= '9') || basec == '-')) {
|
|
||||||
f = TRUE ; /* there is a # arg */
|
|
||||||
n = 0 ; /* start with a zero default */
|
|
||||||
mflag = 1 ; /* current minus flag */
|
|
||||||
c = basec ; /* strip the META */
|
|
||||||
do {
|
|
||||||
if( c == '-') {
|
|
||||||
/* already hit a minus or digit? */
|
|
||||||
if( (mflag == -1) || (n != 0))
|
|
||||||
break ;
|
|
||||||
|
|
||||||
mflag = -1 ;
|
|
||||||
} else
|
|
||||||
n = n * 10 + (c - '0') ;
|
|
||||||
|
|
||||||
if( (n == 0) && (mflag == -1)) /* lonely - */
|
|
||||||
mloutstr( "Arg:") ;
|
|
||||||
else
|
|
||||||
mloutfmt( "Arg: %d", n * mflag) ;
|
|
||||||
|
|
||||||
c = getcmd() ; /* get the next key */
|
|
||||||
} while( (c >= '0' && c <= '9') || (c == '-')) ;
|
|
||||||
|
|
||||||
n = n * mflag ; /* figure in the sign */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do ^U repeat argument processing */
|
/* do ^U repeat argument processing */
|
||||||
|
while( c == reptc
|
||||||
|
||( (c & META)
|
||||||
|
&& (((basec = c & ~META) >= '0' && basec <= '9') || basec == '-'))) {
|
||||||
|
int mflag = 0 ; /* minus flag, default to positive */
|
||||||
|
|
||||||
if( c == reptc) { /* ^U, start argument */
|
|
||||||
f = TRUE ;
|
f = TRUE ;
|
||||||
n = 4 ; /* with argument of 4 */
|
if( c == reptc) {
|
||||||
mflag = 0 ; /* that can be discarded. */
|
n = 4 ;
|
||||||
mloutstr( "Arg: 4") ;
|
basec = 2 ; /* lead by universal arg cmd */
|
||||||
while( ((c = getcmd()) >= '0' && c <= '9') || c == reptc
|
} else if( c & META) {
|
||||||
|| c == '-') {
|
if( basec == '-') {
|
||||||
if( c == reptc)
|
mflag = TRUE ; /* negative */
|
||||||
if( (n > 0) == ((n * 4) > 0))
|
|
||||||
n = n * 4 ;
|
|
||||||
else
|
|
||||||
n = 1 ;
|
n = 1 ;
|
||||||
/*
|
basec = 1 ; /* lead by M-- */
|
||||||
* If dash, and start of argument string, set arg.
|
} else {
|
||||||
* to -1. Otherwise, insert it.
|
n = basec - '0' ;
|
||||||
*/
|
basec = 0 ; /* lead by M-# */
|
||||||
else if( c == '-') {
|
}
|
||||||
if( mflag)
|
}
|
||||||
|
|
||||||
|
mloutfmt( "Arg: %s%d", mflag ? "-" : "", n) ;
|
||||||
|
while( ((c = getcmd()) >= '0' && c <= '9') || c == '-') {
|
||||||
|
if( c == '-') {
|
||||||
|
if( basec == 2) { /* directly follows universal arg cmd */
|
||||||
|
n = 1 ;
|
||||||
|
basec = 1 ;
|
||||||
|
mflag = TRUE ;
|
||||||
|
} else
|
||||||
break ;
|
break ;
|
||||||
|
} else {
|
||||||
n = 0 ;
|
if( basec) { /* follows universal arg cmd or leading dash */
|
||||||
mflag = -1 ;
|
n = c - '0' ;
|
||||||
}
|
basec = 0 ;
|
||||||
/*
|
} else if( n <= 0xCCCCCCB) /* avoid overflow */
|
||||||
* If first digit entered, replace previous argument
|
n = n * 10 + c - '0' ;
|
||||||
* with digit and set sign. Otherwise, append to arg.
|
|
||||||
*/
|
|
||||||
else {
|
|
||||||
if( !mflag) {
|
|
||||||
n = 0 ;
|
|
||||||
mflag = 1 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 10 * n + c - '0' ;
|
mloutfmt( "Arg: %s%d", mflag ? "-" : "", n) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
mloutfmt( "Arg: %d", (mflag >= 0) ? n : (n ? -n : -1)) ;
|
if( mflag)
|
||||||
}
|
n = -n ;
|
||||||
/*
|
|
||||||
* Make arguments preceded by a minus sign negative and change
|
|
||||||
* the special argument "^U -" to an effective "^U -1".
|
|
||||||
*/
|
|
||||||
if( mflag == -1)
|
|
||||||
n = n ? -n : -1 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and execute the command */
|
/* and execute the command */
|
||||||
|
Loading…
Reference in New Issue
Block a user