forked from bartvdbraak/blender
fix [#28848] Editing object name (e.g.), Ctrl-Shift-Arrows don't work as Ctrl-Arrows.
This commit is contained in:
parent
35fedac565
commit
a016fdd499
@ -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)
|
static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump)
|
||||||
{
|
{
|
||||||
char *str;
|
const char *str= data->str;
|
||||||
int len;
|
const int len= strlen(str);
|
||||||
|
const int pos_prev= but->pos;
|
||||||
|
const int has_sel= (but->selend - but->selsta) > 0;
|
||||||
|
|
||||||
str= data->str;
|
/* special case, quit selection and set cursor */
|
||||||
len= strlen(str);
|
if (has_sel && !select) {
|
||||||
|
if (direction) {
|
||||||
if(direction) { /* right*/
|
but->selsta = but->pos = but->selend;
|
||||||
/* if there's a selection */
|
}
|
||||||
if ((but->selend - but->selsta) > 0) {
|
else {
|
||||||
/* extend the selection based on the first direction taken */
|
but->pos = but->selend = but->selsta;
|
||||||
if(select) {
|
}
|
||||||
if (!data->selextend) {
|
data->selextend = 0;
|
||||||
data->selextend = EXTEND_RIGHT;
|
}
|
||||||
}
|
else {
|
||||||
if (data->selextend == EXTEND_RIGHT) {
|
if(direction) { /* right*/
|
||||||
but->selend++;
|
if(jump) {
|
||||||
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) {
|
|
||||||
/* jump betweenn special characters (/,\,_,-, etc.),
|
/* jump betweenn special characters (/,\,_,-, etc.),
|
||||||
* look at function test_special_char() for complete
|
* look at function test_special_char() for complete
|
||||||
* list of special character, ctr -> */
|
* list of special character, ctr -> */
|
||||||
@ -1418,47 +1395,14 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction
|
|||||||
but->pos++;
|
but->pos++;
|
||||||
if(test_special_char(str[but->pos])) break;
|
if(test_special_char(str[but->pos])) break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
int tlen;
|
else {
|
||||||
but->pos++;
|
but->pos++;
|
||||||
if(but->pos > (tlen= strlen(str))) but->pos= tlen;
|
if(but->pos > len) but->pos= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else { /* left */
|
||||||
else { /* left */
|
if(jump) {
|
||||||
/* 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) {
|
|
||||||
/* jump betweenn special characters (/,\,_,-, etc.),
|
/* jump betweenn special characters (/,\,_,-, etc.),
|
||||||
* look at function test_special_char() for complete
|
* look at function test_special_char() for complete
|
||||||
* list of special character, ctr -> */
|
* list of special character, ctr -> */
|
||||||
@ -1466,18 +1410,63 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction
|
|||||||
but->pos--;
|
but->pos--;
|
||||||
if(test_special_char(str[but->pos])) break;
|
if(test_special_char(str[but->pos])) break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if(but->pos>0) but->pos--;
|
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)
|
static void ui_textedit_move_end(uiBut *but, uiHandleButtonData *data, int direction, int select)
|
||||||
{
|
{
|
||||||
char *str;
|
const char *str= data->str;
|
||||||
|
|
||||||
str= data->str;
|
|
||||||
|
|
||||||
if(direction) { /* right */
|
if(direction) { /* right */
|
||||||
if(select) {
|
if(select) {
|
||||||
|
Loading…
Reference in New Issue
Block a user