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-10 06:06:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-10 06:06:26 +0400
commit9e5dc7de01f63827706e8a7ed83629801d60af53 (patch)
tree1e0767af83ff614af2c154f5e22cd8138033e1d8 /source/blender/blenlib/intern/string_cursor_utf8.c
parentec3b5d5205cee92d0fd10a617cfd8f95be416fc7 (diff)
revert most of r52820 (patch to fix [#33452]), this caused a regression in text stepping when ctrl is held.
This adds back the problem that double-clicking on a single char wont select it. Double click selection may need its own logic.
Diffstat (limited to 'source/blender/blenlib/intern/string_cursor_utf8.c')
-rw-r--r--source/blender/blenlib/intern/string_cursor_utf8.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c
index c364d22b75b..65763f21b0f 100644
--- a/source/blender/blenlib/intern/string_cursor_utf8.c
+++ b/source/blender/blenlib/intern/string_cursor_utf8.c
@@ -141,43 +141,48 @@ 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 delim_type = (*pos) < maxlen ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
- * look at function test_special_char() for complete
+ * look at function cursor_delim_type() for complete
* list of special character, ctr -> */
- while (TRUE) {
- if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) {
+ 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;
}
- else if ((*pos) >= maxlen) {
- break;
+ else {
+ break; /* unlikely but just in case */
}
- 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 delim_type = (*pos) > 0 ? cursor_delim_type(&str[(*pos)]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
- * look at function test_special_char() for complete
+ * look at function cursor_delim_type() for complete
* list of special character, ctr -> */
- 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;
+ while ((*pos) > 0) {
+ if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) {
+ if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos])))
+ break;
}
- else if ((*pos) <= 0) {
+ else {
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);
}
}
}