From d1091296636726149309d59a5d29e24cfd343631 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 26 Dec 2006 10:18:38 +0000 Subject: [PATCH] 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! --- source/blender/include/interface.h | 1 - source/blender/src/interface.c | 18 +++++++++--------- source/blender/src/interface_draw.c | 4 +--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/blender/include/interface.h b/source/blender/include/interface.h index f2f6aad855d..d7be02c6fc5 100644 --- a/source/blender/include/interface.h +++ b/source/blender/include/interface.h @@ -71,7 +71,6 @@ * extension direction, selextend, inside ui_do_but_TEX */ #define EXTEND_LEFT 1 #define EXTEND_RIGHT 2 -#define SELWIDTH (but->selend - but->selsta) typedef struct { short xim, yim; diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index b45b1f9dff5..94b3a57687a 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -1349,7 +1349,7 @@ static short ui_delete_selection_edittext(uiBut *but) str= (char *)but->poin; - deletedwidth = SELWIDTH; + deletedwidth = (but->selend - but->selsta); for(x=0; x< strlen(str); x++) { if (but->selend + x <= strlen(str) ) { @@ -1745,7 +1745,7 @@ static int ui_do_but_TEX(uiBut *but) /* paste */ if (dev==VKEY) { /* paste over the current selection */ - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { 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 */ if (dev==XKEY) { - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { len -= ui_delete_selection_edittext(but); if (len < 0) len = 0; @@ -1786,10 +1786,10 @@ static int ui_do_but_TEX(uiBut *but) } else if((ascii)){ - if(len-SELWIDTH+1 <= but->max) { + if(len-(but->selend - but->selsta)+1 <= but->max) { /* type over the current selection */ - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { len -= ui_delete_selection_edittext(but); } @@ -1810,7 +1810,7 @@ static int ui_do_but_TEX(uiBut *but) case RIGHTARROWKEY: /* if there's a selection */ - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { /* extend the selection based on the first direction taken */ if(G.qual & LR_SHIFTKEY) { if (!selextend) { @@ -1859,7 +1859,7 @@ static int ui_do_but_TEX(uiBut *but) case LEFTARROWKEY: /* if there's a selection */ - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { /* extend the selection based on the first direction taken */ if(G.qual & LR_SHIFTKEY) { if (!selextend) { @@ -1935,7 +1935,7 @@ static int ui_do_but_TEX(uiBut *but) break; case DELKEY: - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { len -= ui_delete_selection_edittext(but); if (len < 0) len = 0; @@ -1951,7 +1951,7 @@ static int ui_do_but_TEX(uiBut *but) case BACKSPACEKEY: if(len!=0) { - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { len -= ui_delete_selection_edittext(but); if (len < 0) len = 0; diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 653b596e5ec..e979d4453cb 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -1464,12 +1464,10 @@ static void ui_draw_text_icon(uiBut *but) /* text button selection and cursor */ if(but->pos != -1) { - if (SELWIDTH > 0) { + if ((but->selend - but->selsta) > 0) { /* text button selection */ selsta_tmp = but->selsta + 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) { ch= but->drawstr[selsta_tmp];