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>2012-12-09 07:57:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-09 07:57:10 +0400
commit78c7951463502e6711099efdafb5f94a045aeec7 (patch)
tree78c7f6ccdec97d8f4c4e571a52aed495e1a3302a
parent0fb3ef7fd83cd31c61f9c8128919a06ad48264cb (diff)
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)
-rw-r--r--source/blender/blenlib/intern/string_cursor_utf8.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c
index bab144266a4..8e8b23bd666 100644
--- a/source/blender/blenlib/intern/string_cursor_utf8.c
+++ b/source/blender/blenlib/intern/string_cursor_utf8.c
@@ -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 @@ typedef enum strCursorDelimType {
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 @@ static strCursorDelimType test_special_char(const char *ch_utf8)
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 @@ static strCursorDelimType test_special_char(const char *ch_utf8)
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,48 +141,43 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
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;
}
- }
-
- /* 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);
+ BLI_str_cursor_step_prev_utf8(str, maxlen, pos);
}
}
}