mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-19 07:46:24 -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
|
* and arranges to move it to the "lastflag", so that the next command can
|
||||||
* look at it. Return the status of command.
|
* 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 ;
|
int status ;
|
||||||
fn_t execfunc ;
|
fn_t execfunc ;
|
||||||
|
|
||||||
@ -214,51 +213,53 @@ int execute(int c, int f, int n)
|
|||||||
execfunc = getbind( c) ;
|
execfunc = getbind( c) ;
|
||||||
if( execfunc != NULL) {
|
if( execfunc != NULL) {
|
||||||
thisflag = 0 ;
|
thisflag = 0 ;
|
||||||
status = (*execfunc) (f, n);
|
status = execfunc( f, n) ;
|
||||||
lastflag = thisflag ;
|
lastflag = thisflag ;
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keystroke not bound => self insert, check if buffer is read only */
|
/* non insertable character can only be bound to function */
|
||||||
if (curbp->b_mode & MDVIEW)
|
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() ;
|
return rdonly() ;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/* check valid count */
|
||||||
* If a space was typed, fill column is defined, the argument is non-
|
if( n <= 0) {
|
||||||
* 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. */
|
|
||||||
lastflag = 0 ;
|
lastflag = 0 ;
|
||||||
return n < 0 ? FALSE : TRUE ;
|
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. */
|
thisflag = 0 ; /* For the future. */
|
||||||
|
|
||||||
|
/* following handling of overwrite is only valid when n == 1 */
|
||||||
/* if we are in overwrite mode, not at eol,
|
/* if we are in overwrite mode, not at eol,
|
||||||
and next char is not a tab or we are at a tab stop,
|
and next char is not a tab or we are at a tab stop,
|
||||||
delete a char forword */
|
delete a char forward */
|
||||||
if (curwp->w_bufp->b_mode & MDOVER &&
|
if( curbp->b_mode & MDOVER
|
||||||
curwp->w_doto < curwp->w_dotp->l_used &&
|
&& curwp->w_doto < curwp->w_dotp->l_used
|
||||||
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
&& (lgetc( curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||||
((curwp->w_doto) % tabwidth) == (tabwidth - 1)))
|
((curwp->w_doto) % tabwidth) == (tabwidth - 1)))
|
||||||
ldelchar( 1, FALSE) ;
|
ldelchar( 1, FALSE) ;
|
||||||
|
|
||||||
@ -285,9 +286,10 @@ int execute(int c, int f, int n)
|
|||||||
status = linsert( n, c) ;
|
status = linsert( n, c) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check auto-save mode */
|
/* perform auto-save */
|
||||||
if (curbp->b_mode & MDASAVE)
|
if( status == TRUE /* successful insertion */
|
||||||
if (--gacount == 0) {
|
&& (curbp->b_mode & MDASAVE) /* auto save is on */
|
||||||
|
&& (--gacount == 0)) { /* insertion count reached */
|
||||||
/* and save the file if needed */
|
/* and save the file if needed */
|
||||||
upscreen( FALSE, 0) ;
|
upscreen( FALSE, 0) ;
|
||||||
filesave( FALSE, 0) ;
|
filesave( FALSE, 0) ;
|
||||||
@ -298,10 +300,5 @@ int execute(int c, int f, int n)
|
|||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastflag = 0 ; /* Fake last flags. */
|
|
||||||
mloutfmt( "%B(Key not bound)") ; /* Complain */
|
|
||||||
return FALSE ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* end of execute.c */
|
/* end of execute.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user