1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Check consistency of forwchar/backchar calls.

Review entab dot movement.
This commit is contained in:
Renaud 2016-05-20 19:46:54 +08:00
parent 2b21a98e9c
commit 92078e5595
3 changed files with 24 additions and 16 deletions

2
line.c
View File

@ -114,6 +114,7 @@ static unsigned utf8_revdelta( unsigned char *p, unsigned pos) {
} }
boolean backchar( int f, int n) { boolean backchar( int f, int n) {
assert( f == TRUE || (f == FALSE && n == 1)) ;
if( n < 0) if( n < 0)
return forwchar( f, -n) ; return forwchar( f, -n) ;
@ -147,6 +148,7 @@ boolean backchar( int f, int n) {
* buffer. Set the flag if the line pointer for dot changes. * buffer. Set the flag if the line pointer for dot changes.
*/ */
boolean forwchar( int f, int n) { boolean forwchar( int f, int n) {
assert( f == TRUE || (f == FALSE && n == 1)) ;
if( n < 0) if( n < 0)
return backchar( f, -n) ; return backchar( f, -n) ;

View File

@ -329,12 +329,15 @@ int detab(int f, int n)
/* detab the entire current line */ /* detab the entire current line */
while (curwp->w_doto < llength(curwp->w_dotp)) { while (curwp->w_doto < llength(curwp->w_dotp)) {
/* if we have a tab */ /* if we have a tab */
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') { if( curwbyte() == '\t') {
ldelchar(1, FALSE); int size ;
insspace( TRUE, tabwidth - curwp->w_doto % tabwidth);
}
forwchar(FALSE, 1); ldelchar( 1, FALSE) ;
size = tabwidth - curwp->w_doto % tabwidth ;
insspace( TRUE, size) ;
forwchar( TRUE, size) ;
} else
forwchar( FALSE, 1) ;
} }
/* advance/or back to the next line */ /* advance/or back to the next line */
@ -391,7 +394,7 @@ int entab(int f, int n)
} }
/* get the current character */ /* get the current character */
switch( lgetc( curwp->w_dotp, curwp->w_doto)) { switch( curwbyte()) {
case '\t': /* a tab...count em up */ case '\t': /* a tab...count em up */
ccol = nextab(ccol); ccol = nextab(ccol);
break; break;
@ -967,7 +970,7 @@ int getfence(int f, int n)
/* if no eol */ /* if no eol */
if( curwp->w_doto != llength(curwp->w_dotp)) { if( curwp->w_doto != llength(curwp->w_dotp)) {
c = lgetc( curwp->w_dotp, curwp->w_doto) ; c = curwbyte() ;
if( c == ch) if( c == ch)
++count ; ++count ;
else if( c == ofence) else if( c == ofence)

View File

@ -13,13 +13,13 @@
* the full blown redisplay is just too expensive to run for every input * the full blown redisplay is just too expensive to run for every input
* character. * character.
*/ */
struct window { typedef struct window {
struct window *w_wndp; /* Next window */ struct window *w_wndp; /* Next window */
struct buffer *w_bufp; /* Buffer displayed in window */ struct buffer *w_bufp; /* Buffer displayed in window */
struct line *w_linep; /* Top line in the window */ line_p w_linep ; /* Top line in the window */
struct line *w_dotp; /* Line containing "." */ line_p w_dotp ; /* Line containing "." */
struct line *w_markp; /* Line containing "mark" */ line_p w_markp ; /* Line containing "mark" */
int w_doto; /* Byte offset for "." */ int w_doto ; /* Byte offset for "." */
int w_marko; /* Byte offset for "mark" */ int w_marko; /* Byte offset for "mark" */
int w_toprow ; /* Origin 0 top row of window */ int w_toprow ; /* Origin 0 top row of window */
int w_ntrows ; /* # of rows of text in window */ int w_ntrows ; /* # of rows of text in window */
@ -29,10 +29,13 @@ struct window {
char w_fcolor; /* current forground color */ char w_fcolor; /* current forground color */
char w_bcolor; /* current background color */ char w_bcolor; /* current background color */
#endif #endif
}; } *window_p ;
extern struct window *curwp ; /* Current window */ extern window_p curwp ; /* Current window */
extern struct window *wheadp ; /* Head of list of windows */ extern window_p wheadp ; /* Head of list of windows */
/* curwbyte return the byte after the dot in current window */
#define curwbyte() lgetc( curwp->w_dotp, curwp->w_doto)
#define WFFORCE 0x01 /* Window needs forced reframe */ #define WFFORCE 0x01 /* Window needs forced reframe */
#define WFMOVE 0x02 /* Movement from line to line */ #define WFMOVE 0x02 /* Movement from line to line */
@ -66,6 +69,6 @@ int newsize( int f, int n) ;
int newwidth( int f, int n) ; int newwidth( int f, int n) ;
int getwpos( void) ; int getwpos( void) ;
void cknewwindow( void) ; void cknewwindow( void) ;
struct window *wpopup( void) ; /* Pop up window creation. */ window_p wpopup( void) ; /* Pop up window creation. */
#endif #endif