Bugfix #5498
Textbutton: SHIFT+Arrow selections did not work proper when the amount of text in a button was more than its width could display. Now still doesn't work OK 100% (when selection itself goes outside of button view). Also: removed the very bad SELWIDTH define (but->selend - but->selsta). That's not making readable code!
This commit is contained in:
@@ -71,7 +71,6 @@
|
|||||||
* extension direction, selextend, inside ui_do_but_TEX */
|
* extension direction, selextend, inside ui_do_but_TEX */
|
||||||
#define EXTEND_LEFT 1
|
#define EXTEND_LEFT 1
|
||||||
#define EXTEND_RIGHT 2
|
#define EXTEND_RIGHT 2
|
||||||
#define SELWIDTH (but->selend - but->selsta)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short xim, yim;
|
short xim, yim;
|
||||||
|
|||||||
@@ -1349,7 +1349,7 @@ static short ui_delete_selection_edittext(uiBut *but)
|
|||||||
|
|
||||||
str= (char *)but->poin;
|
str= (char *)but->poin;
|
||||||
|
|
||||||
deletedwidth = SELWIDTH;
|
deletedwidth = (but->selend - but->selsta);
|
||||||
|
|
||||||
for(x=0; x< strlen(str); x++) {
|
for(x=0; x< strlen(str); x++) {
|
||||||
if (but->selend + x <= strlen(str) ) {
|
if (but->selend + x <= strlen(str) ) {
|
||||||
@@ -1745,7 +1745,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
/* paste */
|
/* paste */
|
||||||
if (dev==VKEY) {
|
if (dev==VKEY) {
|
||||||
/* paste over the current selection */
|
/* paste over the current selection */
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
len -= ui_delete_selection_edittext(but);
|
len -= ui_delete_selection_edittext(but);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1775,7 +1775,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
|
|
||||||
/* for cut only, delete the selection afterwards */
|
/* for cut only, delete the selection afterwards */
|
||||||
if (dev==XKEY) {
|
if (dev==XKEY) {
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
len -= ui_delete_selection_edittext(but);
|
len -= ui_delete_selection_edittext(but);
|
||||||
|
|
||||||
if (len < 0) len = 0;
|
if (len < 0) len = 0;
|
||||||
@@ -1786,10 +1786,10 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
}
|
}
|
||||||
else if((ascii)){
|
else if((ascii)){
|
||||||
|
|
||||||
if(len-SELWIDTH+1 <= but->max) {
|
if(len-(but->selend - but->selsta)+1 <= but->max) {
|
||||||
|
|
||||||
/* type over the current selection */
|
/* type over the current selection */
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
len -= ui_delete_selection_edittext(but);
|
len -= ui_delete_selection_edittext(but);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1810,7 +1810,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
|
|
||||||
case RIGHTARROWKEY:
|
case RIGHTARROWKEY:
|
||||||
/* if there's a selection */
|
/* if there's a selection */
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
/* extend the selection based on the first direction taken */
|
/* extend the selection based on the first direction taken */
|
||||||
if(G.qual & LR_SHIFTKEY) {
|
if(G.qual & LR_SHIFTKEY) {
|
||||||
if (!selextend) {
|
if (!selextend) {
|
||||||
@@ -1859,7 +1859,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
|
|
||||||
case LEFTARROWKEY:
|
case LEFTARROWKEY:
|
||||||
/* if there's a selection */
|
/* if there's a selection */
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
/* extend the selection based on the first direction taken */
|
/* extend the selection based on the first direction taken */
|
||||||
if(G.qual & LR_SHIFTKEY) {
|
if(G.qual & LR_SHIFTKEY) {
|
||||||
if (!selextend) {
|
if (!selextend) {
|
||||||
@@ -1935,7 +1935,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DELKEY:
|
case DELKEY:
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
len -= ui_delete_selection_edittext(but);
|
len -= ui_delete_selection_edittext(but);
|
||||||
|
|
||||||
if (len < 0) len = 0;
|
if (len < 0) len = 0;
|
||||||
@@ -1951,7 +1951,7 @@ static int ui_do_but_TEX(uiBut *but)
|
|||||||
|
|
||||||
case BACKSPACEKEY:
|
case BACKSPACEKEY:
|
||||||
if(len!=0) {
|
if(len!=0) {
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
len -= ui_delete_selection_edittext(but);
|
len -= ui_delete_selection_edittext(but);
|
||||||
|
|
||||||
if (len < 0) len = 0;
|
if (len < 0) len = 0;
|
||||||
|
|||||||
@@ -1464,12 +1464,10 @@ static void ui_draw_text_icon(uiBut *but)
|
|||||||
/* text button selection and cursor */
|
/* text button selection and cursor */
|
||||||
if(but->pos != -1) {
|
if(but->pos != -1) {
|
||||||
|
|
||||||
if (SELWIDTH > 0) {
|
if ((but->selend - but->selsta) > 0) {
|
||||||
/* text button selection */
|
/* text button selection */
|
||||||
selsta_tmp = but->selsta + strlen(but->str);
|
selsta_tmp = but->selsta + strlen(but->str);
|
||||||
selend_tmp = but->selend + strlen(but->str);
|
selend_tmp = but->selend + strlen(but->str);
|
||||||
if (but->ofs >= strlen(but->str))
|
|
||||||
selsta_tmp += (but->ofs - strlen(but->str));
|
|
||||||
|
|
||||||
if(but->drawstr[0]!=0) {
|
if(but->drawstr[0]!=0) {
|
||||||
ch= but->drawstr[selsta_tmp];
|
ch= but->drawstr[selsta_tmp];
|
||||||
|
|||||||
Reference in New Issue
Block a user