1
1
revert void edit_cursor_move to original.
    add void edit_right_char_move_cmd (WEdit * edit)
    add void edit_left_char_move_cmd  (WEdit * edit)
    replace edit_cursor_move call to edit_left_char_move_cmd/edit_right_char_move_cmd in edit_execute_cmd (on key press LEFT/RIGHT)
Этот коммит содержится в:
Ilia Maslakov 2009-04-29 07:06:27 +00:00
родитель 2a52039fae
Коммит 3020c5573d

Просмотреть файл

@ -1283,16 +1283,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
void edit_cursor_move (WEdit * edit, long increment) void edit_cursor_move (WEdit * edit, long increment)
{ {
/* this is the same as a combination of two of the above routines, with only one push onto the undo stack */ /* this is the same as a combination of two of the above routines, with only one push onto the undo stack */
int c = 0; int c;
long curs1 = edit->curs1;
long curs2 = edit->curs2;
int cw = 1;
int char_step = 0;
int i;
/* one char move*/
if ( increment == -1 || increment == 1)
char_step = 1;
#ifdef FAST_MOVE_CURSOR #ifdef FAST_MOVE_CURSOR
if (increment < -256) { if (increment < -256) {
@ -1309,27 +1300,17 @@ void edit_cursor_move (WEdit * edit, long increment)
edit_push_action (edit, CURS_RIGHT); edit_push_action (edit, CURS_RIGHT);
cw = 1; c = edit_get_byte (edit, edit->curs1 - 1);
if ( edit->utf8 && char_step ) { if (!((edit->curs2 + 1) & M_EDIT_BUF_SIZE))
edit_get_prev_utf (edit, curs1, &cw); edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
if ( cw < 1 ) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c;
cw = 1; edit->curs2++;
c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE];
if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
} }
for ( i = 1; i<= cw; i++ ) { edit->curs1--;
c = edit_get_byte (edit, curs1 - 1);
if (!((curs2 + 1) & M_EDIT_BUF_SIZE))
edit->buffers2[(curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (curs2 & M_EDIT_BUF_SIZE) - 1] = c;
curs2++;
c = edit->buffers1[(curs1 - 1) >> S_EDIT_BUF_SIZE][(curs1 - 1) & M_EDIT_BUF_SIZE];
if (!((curs1 - 1) & M_EDIT_BUF_SIZE)) {
g_free (edit->buffers1[curs1 >> S_EDIT_BUF_SIZE]);
edit->buffers1[curs1 >> S_EDIT_BUF_SIZE] = NULL;
}
curs1--;
}
edit->curs1 = curs1;
edit->curs2 = curs2;
if (c == '\n') { if (c == '\n') {
edit->curs_line--; edit->curs_line--;
edit->force |= REDRAW_LINE_BELOW; edit->force |= REDRAW_LINE_BELOW;
@ -1343,27 +1324,17 @@ void edit_cursor_move (WEdit * edit, long increment)
edit_push_action (edit, CURS_LEFT); edit_push_action (edit, CURS_LEFT);
cw = 1; c = edit_get_byte (edit, edit->curs1);
if ( edit->utf8 && char_step ) { if (!(edit->curs1 & M_EDIT_BUF_SIZE))
edit_get_utf (edit, curs1, &cw); edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
if ( cw < 1 ) edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE][edit->curs1 & M_EDIT_BUF_SIZE] = c;
cw = 1; edit->curs1++;
c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0;
} }
for ( i = 1; i<= cw; i++ ) { edit->curs2--;
c = edit_get_byte (edit, curs1);
if (!(curs1 & M_EDIT_BUF_SIZE))
edit->buffers1[curs1 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
edit->buffers1[curs1 >> S_EDIT_BUF_SIZE][curs1 & M_EDIT_BUF_SIZE] = c;
curs1++;
c = edit->buffers2[(curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
if (!(curs2 & M_EDIT_BUF_SIZE)) {
g_free (edit->buffers2[curs2 >> S_EDIT_BUF_SIZE]);
edit->buffers2[curs2 >> S_EDIT_BUF_SIZE] = 0;
}
curs2--;
}
edit->curs1 = curs1;
edit->curs2 = curs2;
if (c == '\n') { if (c == '\n') {
edit->curs_line++; edit->curs_line++;
edit->force |= REDRAW_LINE_ABOVE; edit->force |= REDRAW_LINE_ABOVE;
@ -1958,6 +1929,28 @@ static void edit_right_word_move_cmd (WEdit * edit)
edit->force |= REDRAW_PAGE; edit->force |= REDRAW_PAGE;
} }
static void edit_right_char_move_cmd (WEdit * edit)
{
int cw = 1;
if ( edit->utf8 ) {
edit_get_utf (edit, edit->curs1, &cw);
if ( cw < 1 )
cw = 1;
}
edit_cursor_move (edit, cw);
}
static void edit_left_char_move_cmd (WEdit * edit)
{
int cw = 1;
if ( edit->utf8 ) {
edit_get_prev_utf (edit, edit->curs1, &cw);
if ( cw < 1 )
cw = 1;
}
edit_cursor_move (edit, -cw);
}
static void edit_right_delete_word (WEdit * edit) static void edit_right_delete_word (WEdit * edit)
{ {
@ -2572,7 +2565,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
break; break;
} }
} }
edit_cursor_move (edit, -1); edit_left_char_move_cmd (edit);
break; break;
case CK_Right: case CK_Right:
case CK_Right_Highlight: case CK_Right_Highlight:
@ -2583,7 +2576,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
break; break;
} }
} }
edit_cursor_move (edit, 1); edit_right_char_move_cmd (edit);
break; break;
case CK_Begin_Page: case CK_Begin_Page:
case CK_Begin_Page_Highlight: case CK_Begin_Page_Highlight: