mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-12 23:56:51 -05:00
Review inspound, '#' insertion in C mode.
This commit is contained in:
parent
c390cf2a3e
commit
8dfa92ba44
26
execute.c
26
execute.c
@ -14,6 +14,32 @@
|
||||
int gasave = 256 ; /* global ASAVE size */
|
||||
int gacount = 256 ; /* count until next ASAVE */
|
||||
|
||||
|
||||
/* insert a # into the text here...we are in CMODE */
|
||||
static int inspound( void) {
|
||||
/* if we are at the beginning of the line, no go */
|
||||
if( curwp->w_doto != 0) {
|
||||
int i ;
|
||||
|
||||
/* scan to see if all space before this is white space */
|
||||
for( i = curwp->w_doto - 1 ; i >= 0 ; i -= 1) {
|
||||
int ch ; /* last character before input */
|
||||
|
||||
ch = lgetc( curwp->w_dotp, i) ;
|
||||
if( ch != ' ' && ch != '\t')
|
||||
break ;
|
||||
}
|
||||
|
||||
/* delete back first */
|
||||
if( i < 0)
|
||||
while( getccol( FALSE) >= 1)
|
||||
backdel( FALSE, 1) ;
|
||||
}
|
||||
|
||||
/* and insert the required pound */
|
||||
return linsert( 1, '#') ;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the general command execution routine. It handles the fake binding
|
||||
* of all the keys to "self-insert". It also clears out the "thisflag" word,
|
||||
|
24
random.c
24
random.c
@ -704,30 +704,6 @@ int insbrace(int n, int c)
|
||||
}
|
||||
#endif
|
||||
|
||||
int inspound(void)
|
||||
{ /* insert a # into the text here...we are in CMODE */
|
||||
int ch; /* last character before input */
|
||||
int i;
|
||||
|
||||
/* if we are at the beginning of the line, no go */
|
||||
if (curwp->w_doto == 0)
|
||||
return linsert(1, '#');
|
||||
|
||||
/* scan to see if all space before this is white space */
|
||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||
ch = lgetc(curwp->w_dotp, i);
|
||||
if (ch != ' ' && ch != '\t')
|
||||
return linsert(1, '#');
|
||||
}
|
||||
|
||||
/* delete back first */
|
||||
while (getccol(FALSE) >= 1)
|
||||
backdel(FALSE, 1);
|
||||
|
||||
/* and insert the required pound */
|
||||
return linsert(1, '#');
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete blank lines around dot. What this command does depends if dot is
|
||||
* sitting on a blank line. If dot is sitting on a blank line, this command
|
||||
|
Loading…
Reference in New Issue
Block a user