[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52820] trunk/blender/source/blender/ blenlib/intern/string_cursor_utf8.c: patch [#33452] Double click select does not work properly + patch
Campbell Barton
ideasman42 at gmail.com
Sun Dec 9 04:57:12 CET 2012
Revision: 52820
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52820
Author: campbellbarton
Date: 2012-12-09 03:57:10 +0000 (Sun, 09 Dec 2012)
Log Message:
-----------
patch [#33452] Double click select does not work properly + patch
from Tobias Johansson (mutze)
with some minor edits (don't treat '!' as an operator - python centric)
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 2012-12-09 01:42:26 UTC (rev 52819)
+++ trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c 2012-12-09 03:57:10 UTC (rev 52820)
@@ -38,7 +38,7 @@
typedef enum strCursorDelimType {
STRCUR_DELIM_NONE,
- STRCUR_DELIM_ALPHA,
+ STRCUR_DELIM_ALPHANUMERIC,
STRCUR_DELIM_PUNCT,
STRCUR_DELIM_BRACE,
STRCUR_DELIM_OPERATOR,
@@ -47,21 +47,12 @@
STRCUR_DELIM_OTHER
} strCursorDelimType;
-/* return 1 if char ch is special character, otherwise return 0 */
-static strCursorDelimType test_special_char(const char *ch_utf8)
+static strCursorDelimType cursor_delim_type(const char *ch_utf8)
{
/* for full unicode support we really need to have large lookup tables to figure
* out whats what in every possible char set - and python, glib both have these. */
unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8);
- if ((uch >= 'a' && uch <= 'z') ||
- (uch >= 'A' && uch <= 'Z') ||
- (uch == '_') /* not quite correct but allow for python, could become configurable */
- )
- {
- return STRCUR_DELIM_ALPHA;
- }
-
switch (uch) {
case ',':
case '.':
@@ -86,10 +77,11 @@
case '^':
case '*':
case '&':
+ case '|':
return STRCUR_DELIM_OPERATOR;
case '\'':
- case '\"': // " - an extra closing one for Aligorith's text editor
+ case '\"':
return STRCUR_DELIM_QUOTE;
case ' ':
@@ -97,20 +89,22 @@
return STRCUR_DELIM_WHITESPACE;
case '\\':
- case '!':
case '@':
case '#':
case '$':
case ':':
case ';':
case '?':
+ case '!':
+ case 0xA3: /* pound */
+ case 0x80: /* euro */
/* case '_': *//* special case, for python */
return STRCUR_DELIM_OTHER;
default:
break;
}
- return STRCUR_DELIM_NONE;
+ return STRCUR_DELIM_ALPHANUMERIC; /* Not quite true, but ok for now */
}
int BLI_str_cursor_step_next_utf8(const char *str, size_t maxlen, int *pos)
@@ -147,49 +141,44 @@
int *pos, strCursorJumpDirection direction,
strCursorJumpType jump)
{
- const int pos_prev = *pos;
-
if (direction == STRCUR_DIR_NEXT) {
BLI_str_cursor_step_next_utf8(str, maxlen, pos);
-
if (jump != STRCUR_JUMP_NONE) {
- const strCursorDelimType is_special = (*pos) < maxlen ? test_special_char(&str[*pos]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
- while ((*pos) < maxlen) {
- if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos])))
+ while (TRUE) {
+ if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) {
break;
}
- else {
- break; /* unlikely but just in case */
+ else if ((*pos) >= maxlen) {
+ break;
}
+ BLI_str_cursor_step_next_utf8(str, maxlen, pos);
}
}
}
else if (direction == STRCUR_DIR_PREV) {
BLI_str_cursor_step_prev_utf8(str, maxlen, pos);
-
if (jump != STRCUR_JUMP_NONE) {
- const strCursorDelimType is_special = (*pos) > 1 ? test_special_char(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType delim_type = (*pos) > 0 ? cursor_delim_type(&str[(*pos)]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
- while ((*pos) > 0) {
- if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos])))
- break;
+ while (TRUE) {
+ if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) {
+ /* left only: compensate for index/change in direction */
+ if (delim_type != STRCUR_DELIM_NONE) {
+ BLI_str_cursor_step_next_utf8(str, maxlen, pos);
+ }
+ break;
}
- else {
+ else if ((*pos) <= 0) {
break;
}
+ BLI_str_cursor_step_prev_utf8(str, maxlen, pos);
}
-
- /* 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