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/blenlib/intern/string_cursor_utf8.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/blenlib/intern/string_cursor_utf8.c') diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 65763f21b0f..b8797855f17 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -139,12 +139,15 @@ int BLI_str_cursor_step_prev_utf8(const char *str, size_t UNUSED(maxlen), int *p void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, strCursorJumpDirection direction, - strCursorJumpType jump) + strCursorJumpType jump, bool use_init_step) { const int pos_prev = *pos; if (direction == STRCUR_DIR_NEXT) { - BLI_str_cursor_step_next_utf8(str, maxlen, pos); + if (use_init_step) { + BLI_assert(jump == STRCUR_JUMP_DELIM); + BLI_str_cursor_step_next_utf8(str, maxlen, pos); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE; @@ -163,7 +166,10 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, } } else if (direction == STRCUR_DIR_PREV) { - BLI_str_cursor_step_prev_utf8(str, maxlen, pos); + if (use_init_step) { + BLI_assert(jump == STRCUR_JUMP_DELIM); + BLI_str_cursor_step_prev_utf8(str, maxlen, pos); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; -- cgit v1.2.3