mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Review execute keystroke handling logic.
This commit is contained in:
parent
ee667b25ed
commit
5c6aac1ae9
81
execute.c
81
execute.c
@ -205,8 +205,7 @@ static void fmatch( int ch) {
|
||||
* and arranges to move it to the "lastflag", so that the next command can
|
||||
* look at it. Return the status of command.
|
||||
*/
|
||||
int execute(int c, int f, int n)
|
||||
{
|
||||
int execute( int c, int f, int n) {
|
||||
int status ;
|
||||
fn_t execfunc ;
|
||||
|
||||
@ -214,51 +213,53 @@ int execute(int c, int f, int n)
|
||||
execfunc = getbind( c) ;
|
||||
if( execfunc != NULL) {
|
||||
thisflag = 0 ;
|
||||
status = (*execfunc) (f, n);
|
||||
status = execfunc( f, n) ;
|
||||
lastflag = thisflag ;
|
||||
return status ;
|
||||
}
|
||||
|
||||
/* keystroke not bound => self insert, check if buffer is read only */
|
||||
if (curbp->b_mode & MDVIEW)
|
||||
/* non insertable character can only be bound to function */
|
||||
if( c < 0x20
|
||||
|| (c >= 0x7F && c < 0xA0)
|
||||
|| c > 0x10FFFF) { /* last valid unicode */
|
||||
lastflag = 0 ; /* Fake last flags. */
|
||||
mloutfmt( "%B(Key not bound)") ; /* Complain */
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/* insertable character => self insert, check if buffer is read only */
|
||||
if( curbp->b_mode & MDVIEW) {
|
||||
lastflag = 0 ;
|
||||
return rdonly() ;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a space was typed, fill column is defined, the argument is non-
|
||||
* negative, wrap mode is enabled, and we are now past fill column,
|
||||
* and we are not read-only, perform word wrap.
|
||||
*/
|
||||
if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
||||
n >= 0 && getccol(FALSE) > fillcol &&
|
||||
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
||||
execute(META | SPEC | 'W', FALSE, 1);
|
||||
|
||||
#if PKCODE
|
||||
if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */
|
||||
#if IBMPC
|
||||
|| (c >= 0x80 && c <= 0xFE)) {
|
||||
#else
|
||||
#if VMS || BSD || USG /* 8BIT P.K. */
|
||||
|| (c >= 0xA0 && c <= 0x10FFFF)) {
|
||||
#else
|
||||
) {
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */
|
||||
#endif
|
||||
if (n <= 0) { /* Fenceposts. */
|
||||
/* check valid count */
|
||||
if( n <= 0) {
|
||||
lastflag = 0 ;
|
||||
return n < 0 ? FALSE : TRUE ;
|
||||
}
|
||||
|
||||
/* wrap on space after fill column in wrap mode */
|
||||
if( c == ' '
|
||||
&& (curwp->w_bufp->b_mode & MDWRAP)
|
||||
&& fillcol > 0
|
||||
&& getccol( FALSE) > fillcol) {
|
||||
status = execute( META | SPEC | 'W', FALSE, 1) ; /* defaults to wrapword */
|
||||
if( status != TRUE) {
|
||||
lastflag = 0 ;
|
||||
return status ;
|
||||
}
|
||||
}
|
||||
|
||||
thisflag = 0 ; /* For the future. */
|
||||
|
||||
/* following handling of overwrite is only valid when n == 1 */
|
||||
/* if we are in overwrite mode, not at eol,
|
||||
and next char is not a tab or we are at a tab stop,
|
||||
delete a char forword */
|
||||
if (curwp->w_bufp->b_mode & MDOVER &&
|
||||
curwp->w_doto < curwp->w_dotp->l_used &&
|
||||
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
delete a char forward */
|
||||
if( curbp->b_mode & MDOVER
|
||||
&& curwp->w_doto < curwp->w_dotp->l_used
|
||||
&& (lgetc( curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
((curwp->w_doto) % tabwidth) == (tabwidth - 1)))
|
||||
ldelchar( 1, FALSE) ;
|
||||
|
||||
@ -285,9 +286,10 @@ int execute(int c, int f, int n)
|
||||
status = linsert( n, c) ;
|
||||
}
|
||||
|
||||
/* check auto-save mode */
|
||||
if (curbp->b_mode & MDASAVE)
|
||||
if (--gacount == 0) {
|
||||
/* perform auto-save */
|
||||
if( status == TRUE /* successful insertion */
|
||||
&& (curbp->b_mode & MDASAVE) /* auto save is on */
|
||||
&& (--gacount == 0)) { /* insertion count reached */
|
||||
/* and save the file if needed */
|
||||
upscreen( FALSE, 0) ;
|
||||
filesave( FALSE, 0) ;
|
||||
@ -298,10 +300,5 @@ int execute(int c, int f, int n)
|
||||
return status ;
|
||||
}
|
||||
|
||||
lastflag = 0 ; /* Fake last flags. */
|
||||
mloutfmt( "%B(Key not bound)") ; /* Complain */
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
/* end of execute.c */
|
||||
|
Loading…
Reference in New Issue
Block a user