Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-06 07:35:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-06 07:35:21 +0400
commit43196852347ddc801c854ab73ecd3bb73350838a (patch)
tree65e1ab74f6c9fd5b9592893b97ca277843345b7d /source/blender/blenlib/intern/string_cursor_utf8.c
parentc97983c9dea72737ad29b6ee3a71726e4a8a11e7 (diff)
fix for cursor jumping error stepping backwards where the the first character of a string would be skipped no matter what it was.
Diffstat (limited to 'source/blender/blenlib/intern/string_cursor_utf8.c')
-rw-r--r--source/blender/blenlib/intern/string_cursor_utf8.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c
index 674d5ae5c8d..38e57cacfb4 100644
--- a/source/blender/blenlib/intern/string_cursor_utf8.c
+++ b/source/blender/blenlib/intern/string_cursor_utf8.c
@@ -141,7 +141,7 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
int *pos, strCursorJumpDirection direction,
strCursorJumpType jump, bool use_init_step)
{
- const int pos_prev = *pos;
+ const int pos_orig = *pos;
if (direction == STRCUR_DIR_NEXT) {
if (use_init_step) {
@@ -158,8 +158,9 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
* list of special character, ctr -> */
while ((*pos) < maxlen) {
if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos])))
- break;
+ if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) {
+ break;
+ }
}
else {
break; /* unlikely but just in case */
@@ -176,24 +177,25 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
}
if (jump != STRCUR_JUMP_NONE) {
- const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType delim_type = (*pos) > 0 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
* look at function cursor_delim_type() for complete
* list of special character, ctr -> */
while ((*pos) > 0) {
+ const int pos_prev = *pos;
if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos])))
+ if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) {
+ /* left only: compensate for index/change in direction */
+ if ((pos_orig - (*pos)) >= 1) {
+ *pos = pos_prev;
+ }
break;
+ }
}
else {
break;
}
}
-
- /* left only: compensate for index/change in direction */
- if (((*pos) != 0) && ABS(pos_prev - (*pos)) >= 1) {
- BLI_str_cursor_step_next_utf8(str, maxlen, pos);
- }
}
}
else {