From ab7ca2dc441239686bcc44189c79e377ba4d089c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 03:03:12 +0000 Subject: fix for double clicking in the text editor not working usefully (double clicking a pair chars would select 3 - one to the left). --- source/blender/editors/interface/interface_handlers.c | 6 +++--- source/blender/editors/space_console/console_ops.c | 18 +++++++++--------- source/blender/editors/space_text/text_ops.c | 10 ++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index edd5b901ca1..b166e532f84 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1610,7 +1610,7 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump } else { int pos_i = but->pos; - BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump, true); but->pos = pos_i; if (select) { @@ -1679,7 +1679,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio else if (but->pos >= 0 && but->pos < len) { int pos = but->pos; int step; - BLI_str_cursor_step_utf8(str, len, &pos, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true); step = pos - but->pos; memmove(&str[but->pos], &str[but->pos + step], (len + 1) - but->pos); changed = 1; @@ -1694,7 +1694,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio int pos = but->pos; int step; - BLI_str_cursor_step_utf8(str, len, &pos, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true); step = but->pos - pos; memmove(&str[but->pos - step], &str[but->pos], (len + 1) - but->pos); but->pos -= step; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 5eed39a120e..1242d123a41 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -34,12 +34,12 @@ #include "DNA_userdef_types.h" +#include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BLI_string_cursor_utf8.h" #include "BLI_string_utf8.h" #include "BLI_string.h" #include "BLI_dynstr.h" -#include "BLI_utildefines.h" #include "BLI_math.h" #include "BKE_context.h" @@ -284,28 +284,28 @@ static int console_move_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_ALL); + STRCUR_JUMP_ALL, true); done = console_line_cursor_set(ci, pos); break; case LINE_END: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_ALL); + STRCUR_JUMP_ALL, true); done = console_line_cursor_set(ci, pos); break; case PREV_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_NONE); + STRCUR_JUMP_NONE, true); done = console_line_cursor_set(ci, pos); break; case NEXT_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_NONE); + STRCUR_JUMP_NONE, true); done = console_line_cursor_set(ci, pos); break; @@ -315,14 +315,14 @@ static int console_move_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, true); done = console_line_cursor_set(ci, pos); break; case NEXT_WORD: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, true); done = console_line_cursor_set(ci, pos); break; } @@ -562,7 +562,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - (type == DEL_NEXT_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + (type == DEL_NEXT_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM, true); stride = pos - ci->cursor; if (stride) { memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); @@ -578,7 +578,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - (type == DEL_PREV_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + (type == DEL_PREV_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM, true); stride = ci->cursor - pos; if (stride) { ci->cursor -= stride; /* same as above */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1f209f90007..b60528bcee8 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1312,9 +1312,11 @@ void TEXT_OT_select_line(wmOperatorType *ot) static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text = CTX_data_edit_text(C); + /* don't advance cursor before stepping */ + const bool use_init_step = false; - txt_jump_left(text, 0); - txt_jump_right(text, 1); + txt_jump_left(text, false, use_init_step); + txt_jump_right(text, true, use_init_step); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); @@ -1816,11 +1818,11 @@ static int text_move_cursor(bContext *C, int type, int select) break; case PREV_WORD: - txt_jump_left(text, select); + txt_jump_left(text, select, true); break; case NEXT_WORD: - txt_jump_right(text, select); + txt_jump_right(text, select, true); break; case PREV_CHAR: -- cgit v1.2.3