[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56506] trunk/blender/source/blender/ blenlib/intern/string_cursor_utf8.c: fix for cursor jumping error stepping backwards where the the first character of a string would be skipped no matter what it was .

Campbell Barton ideasman42 at gmail.com
Mon May 6 05:35:23 CEST 2013


Revision: 56506
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56506
Author:   campbellbarton
Date:     2013-05-06 03:35:21 +0000 (Mon, 06 May 2013)
Log Message:
-----------
fix for cursor jumping error stepping backwards where the the first character of a string would be skipped no matter what it was.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c

Modified: trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c	2013-05-05 18:41:45 UTC (rev 56505)
+++ trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c	2013-05-06 03:35:21 UTC (rev 56506)
@@ -141,7 +141,7 @@
                               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 @@
 			 * 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 @@
 		}
 
 		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 {




More information about the Bf-blender-cvs mailing list