mirror of
https://github.com/rfivet/uemacs.git
synced 2024-09-30 01:05:54 -04:00
backward char movement consistent with mixed byte/UTF-8 content.
This commit is contained in:
parent
356a003194
commit
135238106c
66
line.c
66
line.c
@ -32,10 +32,6 @@ int tabmask = 0x07 ; /* tabulator mask */
|
|||||||
|
|
||||||
static int ldelnewline( void) ;
|
static int ldelnewline( void) ;
|
||||||
|
|
||||||
static inline int is_beginning_utf8( unsigned char c) {
|
|
||||||
return (c & 0xc0) != 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The editor holds deleted text chunks in the struct kill buffer. The
|
/* The editor holds deleted text chunks in the struct kill buffer. The
|
||||||
* kill buffer is logically a stream of ascii characters, however
|
* kill buffer is logically a stream of ascii characters, however
|
||||||
* due to its unpredicatable size, it gets implemented as a linked
|
* due to its unpredicatable size, it gets implemented as a linked
|
||||||
@ -96,30 +92,52 @@ char *getkill( void) {
|
|||||||
* location. Error if you try and move out of the buffer. Set the flag if the
|
* location. Error if you try and move out of the buffer. Set the flag if the
|
||||||
* line pointer for dot changes.
|
* line pointer for dot changes.
|
||||||
*/
|
*/
|
||||||
int backchar(int f, int n)
|
int backchar( int f, int n) {
|
||||||
{
|
if( n < 0)
|
||||||
struct line *lp;
|
return forwchar( f, -n) ;
|
||||||
|
|
||||||
if (n < 0)
|
while( n--) {
|
||||||
return forwchar(f, -n);
|
if( curwp->w_doto == 0) {
|
||||||
while (n--) {
|
struct line *lp ;
|
||||||
if (curwp->w_doto == 0) {
|
|
||||||
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
|
lp = lback( curwp->w_dotp) ;
|
||||||
return FALSE;
|
if( lp == curbp->b_linep)
|
||||||
curwp->w_dotp = lp;
|
return FALSE ;
|
||||||
curwp->w_doto = llength(lp);
|
|
||||||
curwp->w_flag |= WFMOVE;
|
curwp->w_dotp = lp ;
|
||||||
|
curwp->w_doto = llength( lp) ;
|
||||||
|
curwp->w_flag |= WFMOVE ;
|
||||||
} else {
|
} else {
|
||||||
do {
|
unsigned pos ;
|
||||||
unsigned char c;
|
|
||||||
curwp->w_doto--;
|
pos = curwp->w_doto -= 1 ;
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
if( pos > 0) {
|
||||||
if (is_beginning_utf8(c))
|
unsigned char *p ;
|
||||||
break;
|
|
||||||
} while (curwp->w_doto);
|
p = (unsigned char *) &( (curwp->w_dotp)->l_text[ pos]) ;
|
||||||
|
if( (*p & 0xC0) == 0x80) {
|
||||||
|
unsigned char c ;
|
||||||
|
int delta = 0 ;
|
||||||
|
|
||||||
|
c = *--p ;
|
||||||
|
if( (c & 0xE0) == 0xC0) /* valid 2 bytes unicode seq */
|
||||||
|
delta = 1 ;
|
||||||
|
else if( ((c & 0xC0) == 0x80) && (pos > 1)) {
|
||||||
|
c = *--p ;
|
||||||
|
if( (c & 0xF0) == 0xE0) /* valid 3 bytes unicode seq */
|
||||||
|
delta = 2 ;
|
||||||
|
else if( ((c & 0xC0) == 0x80) && (pos > 2))
|
||||||
|
if( (p[ -1] & 0xF8) == 0xF0) /* valid 4 bytes unicode seq */
|
||||||
|
delta = 3 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
curwp->w_doto -= delta ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user