Review inspound, '#' insertion in C mode.

This commit is contained in:
Renaud 2016-02-24 20:00:44 +08:00
parent c390cf2a3e
commit 8dfa92ba44
3 changed files with 26 additions and 25 deletions

View File

@ -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,

View File

@ -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

View File

@ -30,7 +30,6 @@ int trim( int f, int n) ;
int openline( int f, int n) ;
int insert_newline( int f, int n) ;
int insbrace( int n, int c) ;
int inspound( void) ;
int deblank( int f, int n) ;
int indent( int f, int n) ;
int forwdel( int f, int n) ;