1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-17 23:06:25 -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) {
assert( f == TRUE || (f == FALSE && n == 1)) ;
if( n < 0)
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.
*/
boolean forwchar( int f, int n) {
assert( f == TRUE || (f == FALSE && n == 1)) ;
if( n < 0)
return backchar( f, -n) ;

View File

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

View File

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