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>2011-10-09 04:35:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-09 04:35:31 +0400
commita016fdd499ae93329e42a5446ae3e25639f23c0b (patch)
tree32b1dc109c06790a2cb030abf521b46bf5c9030e
parent35fedac565426a8ada30c620888e5a1739bd9219 (diff)
fix [#28848] Editing object name (e.g.), Ctrl-Shift-Arrows don't work as Ctrl-Arrows.
-rw-r--r--source/blender/editors/interface/interface_handlers.c153
1 files changed, 71 insertions, 82 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b4970d5933c..a3d072c3220 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1370,47 +1370,24 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc
static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump)
{
- char *str;
- int len;
-
- str= data->str;
- len= strlen(str);
+ const char *str= data->str;
+ const int len= strlen(str);
+ const int pos_prev= but->pos;
+ const int has_sel= (but->selend - but->selsta) > 0;
- if(direction) { /* right*/
- /* if there's a selection */
- if ((but->selend - but->selsta) > 0) {
- /* extend the selection based on the first direction taken */
- if(select) {
- if (!data->selextend) {
- data->selextend = EXTEND_RIGHT;
- }
- if (data->selextend == EXTEND_RIGHT) {
- but->selend++;
- if (but->selend > len) but->selend = len;
- } else if (data->selextend == EXTEND_LEFT) {
- but->selsta++;
- /* if the selection start has gone past the end,
- * flip them so they're in sync again */
- if (but->selsta == but->selend) {
- but->pos = but->selsta;
- data->selextend = EXTEND_RIGHT;
- }
- }
- } else {
- but->selsta = but->pos = but->selend;
- data->selextend = 0;
- }
- } else {
- if(select) {
- /* make a selection, starting from the cursor position */
- int tlen;
- but->selsta = but->pos;
-
- but->pos++;
- if(but->pos > (tlen= strlen(str))) but->pos= tlen;
-
- but->selend = but->pos;
- } else if(jump) {
+ /* special case, quit selection and set cursor */
+ if (has_sel && !select) {
+ if (direction) {
+ but->selsta = but->pos = but->selend;
+ }
+ else {
+ but->pos = but->selend = but->selsta;
+ }
+ data->selextend = 0;
+ }
+ else {
+ if(direction) { /* right*/
+ if(jump) {
/* jump betweenn special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
@@ -1418,47 +1395,14 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction
but->pos++;
if(test_special_char(str[but->pos])) break;
}
- } else {
- int tlen;
+ }
+ else {
but->pos++;
- if(but->pos > (tlen= strlen(str))) but->pos= tlen;
+ if(but->pos > len) but->pos= len;
}
}
- }
- else { /* left */
- /* if there's a selection */
- if ((but->selend - but->selsta) > 0) {
- /* extend the selection based on the first direction taken */
- if(select) {
- if (!data->selextend) {
- data->selextend = EXTEND_LEFT;
- }
- if (data->selextend == EXTEND_LEFT) {
- but->selsta--;
- if (but->selsta < 0) but->selsta = 0;
- } else if (data->selextend == EXTEND_RIGHT) {
- but->selend--;
- /* if the selection start has gone past the end,
- * flip them so they're in sync again */
- if (but->selsta == but->selend) {
- but->pos = but->selsta;
- data->selextend = EXTEND_LEFT;
- }
- }
- } else {
- but->pos = but->selend = but->selsta;
- data->selextend = 0;
- }
- } else {
- if(select) {
- /* make a selection, starting from the cursor position */
- but->selend = but->pos;
-
- but->pos--;
- if(but->pos<0) but->pos= 0;
-
- but->selsta = but->pos;
- } else if(jump) {
+ else { /* left */
+ if(jump) {
/* jump betweenn special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
@@ -1466,18 +1410,63 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction
but->pos--;
if(test_special_char(str[but->pos])) break;
}
- } else {
+ }
+ else {
if(but->pos>0) but->pos--;
}
}
+
+
+ if(select) {
+ /* existing selection */
+ if (has_sel) {
+
+ if(data->selextend == 0) {
+ data->selextend= EXTEND_RIGHT;
+ }
+
+ if (direction) {
+ if (data->selextend == EXTEND_RIGHT) {
+ but->selend= but->pos;
+ }
+ else {
+ but->selsta= but->pos;
+ }
+ }
+ else {
+ if (data->selextend == EXTEND_LEFT) {
+ but->selsta= but->pos;
+ }
+ else {
+ but->selend= but->pos;
+ }
+ }
+
+ if (but->selend < but->selsta) {
+ SWAP(short, but->selsta, but->selend);
+ data->selextend= (data->selextend == EXTEND_RIGHT) ? EXTEND_LEFT : EXTEND_RIGHT;
+ }
+
+ } /* new selection */
+ else {
+ if (direction) {
+ data->selextend= EXTEND_RIGHT;
+ but->selend= but->pos;
+ but->selsta= pos_prev;
+ }
+ else {
+ data->selextend= EXTEND_LEFT;
+ but->selend= pos_prev;
+ but->selsta= but->pos;
+ }
+ }
+ }
}
}
static void ui_textedit_move_end(uiBut *but, uiHandleButtonData *data, int direction, int select)
{
- char *str;
-
- str= data->str;
+ const char *str= data->str;
if(direction) { /* right */
if(select) {