Page MenuHome

DoubleclickTextSelect.patch

DoubleclickTextSelect.patch

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
Index: source/blender/blenlib/intern/string_cursor_utf8.c
===================================================================
--- source/blender/blenlib/intern/string_cursor_utf8.c (revision 52817)
+++ source/blender/blenlib/intern/string_cursor_utf8.c (working copy)
@@ -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,6 +77,8 @@
case '^':
case '*':
case '&':
+ case '!':
+ case '|':
return STRCUR_DELIM_OPERATOR;
case '\'':
@@ -97,20 +90,21 @@
return STRCUR_DELIM_WHITESPACE;
case '\\':
- case '!':
case '@':
case '#':
case '$':
case ':':
case ';':
case '?':
+ case '£':
+ case '€':
/* 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 delimType = (*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) && (delimType != 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 delimType = (*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) && (delimType != cursor_delim_type(&str[*pos]))) {
+ /* left only: compensate for index/change in direction */
+ if (delimType != 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 {

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
62/2c/ca160f0b7b7786ba8235c4e5a6b0

Event Timeline