fix for own mistake for ctrl+left/right movement and code cleanup for txt_jump_left/right

This commit is contained in:
Sv. Lockal 2012-05-08 11:18:20 +00:00
parent 7a4ad3aaae
commit ba7d24559d

@ -956,60 +956,46 @@ void txt_move_right(Text *text, short sel)
void txt_jump_left(Text *text, short sel) void txt_jump_left(Text *text, short sel)
{ {
TextLine **linep, *oldl; TextLine **linep;
int *charp, oldc, oldflags; int *charp, oldc;
unsigned char oldu;
if (!text) return; if (!text) return;
if (sel) txt_curs_sel(text, &linep, &charp); if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return; if (!*linep) return;
oldflags = text->flags;
text->flags &= ~TXT_TABSTOSPACES;
oldl = *linep;
oldc = *charp; oldc = *charp;
oldu = undoing;
undoing = 1; /* Don't push individual moves to undo stack */
BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len,
charp, STRCUR_DIR_PREV, charp, STRCUR_DIR_PREV,
STRCUR_JUMP_DELIM); STRCUR_JUMP_DELIM);
text->flags = oldflags; if (!sel) txt_pop_sel(text);
if (!undoing) {
undoing = oldu; int span = txt_get_span(text->lines.first, *linep);
if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp);
}
} }
void txt_jump_right(Text *text, short sel) void txt_jump_right(Text *text, short sel)
{ {
TextLine **linep, *oldl; TextLine **linep;
int *charp, oldc, oldflags; int *charp, oldc;
unsigned char oldu;
if (!text) return; if (!text) return;
if (sel) txt_curs_sel(text, &linep, &charp); if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return; if (!*linep) return;
oldflags = text->flags;
text->flags &= ~TXT_TABSTOSPACES;
oldl = *linep;
oldc = *charp; oldc = *charp;
oldu = undoing;
undoing = 1; /* Don't push individual moves to undo stack */
BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len,
charp, STRCUR_DIR_NEXT, charp, STRCUR_DIR_NEXT,
STRCUR_JUMP_DELIM); STRCUR_JUMP_DELIM);
text->flags = oldflags; if (!sel) txt_pop_sel(text);
if (!undoing) {
undoing = oldu; int span = txt_get_span(text->lines.first, *linep);
if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp);
}
} }
void txt_move_bol(Text *text, short sel) void txt_move_bol(Text *text, short sel)