fix cursor in editor on utf-8 files

This commit is contained in:
Ilia Maslakov 2009-04-13 15:33:21 +00:00
parent 95edc18aa8
commit b6ae0a2479

View File

@ -1381,7 +1381,7 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
{ {
long p, q; long p, q;
int col = 0; int col = 0;
int cw = 1;
if (upto) { if (upto) {
q = upto; q = upto;
cols = -10; cols = -10;
@ -1396,7 +1396,13 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
if (col > cols) if (col > cols)
return p - 1; return p - 1;
} }
c = edit_get_byte (edit, p); if ( !edit->utf8 ) {
c = edit_get_byte (edit, p);
} else {
cw = 1;
c = edit_get_byte (edit, p);
edit_get_utf (edit, p, &cw);
}
if (c == '\t') if (c == '\t')
col += TAB_SIZE - col % TAB_SIZE; col += TAB_SIZE - col % TAB_SIZE;
else if (c == '\n') { else if (c == '\n') {
@ -1408,6 +1414,8 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
col += 2; /* Caret notation for control characters */ col += 2; /* Caret notation for control characters */
else else
col++; col++;
if ( cw > 1 )
col -= cw-1;
} }
return col; return col;
} }