Page Menu
Home
Search
Configure Global Search
Log In
Files
F4163
ctrlbs20.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Juho Vepsalainen (bebraw)
Nov 13 2013, 1:14 PM
Size
9 KB
Subscribers
None
ctrlbs20.txt
View Options
Index: source/blender/include/interface.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/interface.h,v
retrieving revision 1.28
diff -u -p -u -r1.28 interface.h
--- source/blender/include/interface.h 28 Jan 2006 18:33:13 -0000 1.28
+++ source/blender/include/interface.h 19 Dec 2006 18:50:00 -0000
@@ -73,6 +73,9 @@
#define EXTEND_RIGHT 2
#define SELWIDTH (but->selend - but->selsta)
+#define LEFT_DIRECTION -1
+#define RIGHT_DIRECTION 1
+
typedef struct {
short xim, yim;
unsigned int *rect;
@@ -234,4 +237,3 @@ extern void ui_draw_anti_x(float x1, flo
#endif
-
Index: source/blender/src/interface.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/interface.c,v
retrieving revision 1.250
diff -u -p -u -r1.250 interface.c
--- source/blender/src/interface.c 7 Dec 2006 14:17:37 -0000 1.250
+++ source/blender/src/interface.c 19 Dec 2006 18:50:02 -0000
@@ -1653,6 +1653,152 @@ static short test_special_char(char ch)
return 0;
}
+static short erasetext(uiBut *but, short len, char *str, short negsteps, short possteps) {
+ if(but->pos != len) {
+ int x;
+
+ for(x=but->pos; x<=strlen(str); x++)
+ str[x-negsteps]= str[x+possteps];
+ }
+
+ but->pos-=negsteps;
+ len-=negsteps+possteps;
+ str[len]='\0';
+
+ return len;
+}
+
+static short eraseall(uiBut *but, short len, char *str) {
+ str[0]= 0;
+ but->pos= 0;
+ len= 0;
+
+ return len;
+}
+
+static short movecursortillspecialchar(short butpos, char *str, short dir) {
+ /* jump between special characters (/,\,_,-, etc.),
+ * look at function test_special_char() for complete
+ * list of special character, ctr -> */
+
+ if(dir == RIGHT_DIRECTION) {
+ if(test_special_char(str[butpos])) butpos++; /* special case */
+ else {
+ while(butpos < strlen(str)) {
+ butpos++;
+ if(test_special_char(str[butpos])) break;
+ }
+ }
+ }
+ else {
+ if(butpos > 0) {
+ butpos--; /* we read characters from left side of butpos */
+
+ /* first character is a special case */
+ if(!test_special_char(str[butpos])) {
+ while(butpos > 0) {
+ if(test_special_char(str[butpos])) {
+ butpos++; /* go back a bit */
+ break;
+ }
+ butpos--;
+ }
+ }
+ }
+ }
+
+ return butpos;
+}
+
+static short movecursor(short butpos, char *str, short dir, short steps) {
+ if(dir == RIGHT_DIRECTION) {
+ if(butpos < strlen(str)) {
+ butpos+=steps;
+ }
+ }
+ else {
+ if(butpos > 0) {
+ butpos-=steps;
+ }
+ }
+
+ return butpos;
+}
+
+static void makeselectionfromcursorpos(uiBut* but, char *str, short dir, short speciallimit) {
+ if(dir == RIGHT_DIRECTION)
+ but->selsta = but->pos;
+ else
+ but->selend = but->pos;
+
+ if(speciallimit == 1)
+ but->pos= movecursortillspecialchar(but->pos, str, dir);
+ else
+ but->pos= movecursor(but->pos, str, dir, 1);
+
+ if(dir == RIGHT_DIRECTION)
+ but->selend = but->pos;
+ else
+ but->selsta = but->pos;
+}
+
+static short findfirstkeyoflastword(short butpos, char *str) {
+ short foundword= 0, eraseamount= 0, x;
+
+ for(x=butpos-1; x>=0; x--) {
+ if(str[x] != ' ' && foundword == 0)
+ foundword= 1;
+ if(str[x] == ' ' && foundword == 1)
+ break;
+
+ eraseamount++;
+ }
+
+ return eraseamount;
+}
+
+static short selecttexttoleft(uiBut *but, short selextend) {
+ /* extend the selection based on the first direction taken */
+ if (!selextend) {
+ selextend = EXTEND_LEFT;
+ }
+ if (selextend == EXTEND_LEFT) {
+ but->selsta--;
+ if (but->selsta < 0) but->selsta = 0;
+ } else if (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;
+ selextend = EXTEND_LEFT;
+ }
+ }
+
+ return selextend;
+}
+
+static short selecttexttoright(uiBut *but, short len, short selextend) {
+ /* extend the selection based on the first direction taken */
+ if (!selextend) {
+ selextend = EXTEND_RIGHT;
+ }
+ if (selextend == EXTEND_RIGHT) {
+ but->selend++;
+ if (but->selend > len) but->selend = len;
+ } else if (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;
+ selextend = EXTEND_RIGHT;
+ }
+ }
+
+ return selextend;
+}
+
static int ui_do_but_TEX(uiBut *but)
{
unsigned short dev;
@@ -1803,25 +1949,15 @@ static int ui_do_but_TEX(uiBut *but)
switch (dev) {
case RIGHTARROWKEY:
+ /* select whole word */
+ if(G.qual==LR_SHIFTKEY+LR_CTRLKEY) {
+ makeselectionfromcursorpos(but, str, RIGHT_DIRECTION, 1);
+ }
/* if there's a selection */
- if (SELWIDTH > 0) {
+ else if(SELWIDTH > 0) {
/* extend the selection based on the first direction taken */
if(G.qual & LR_SHIFTKEY) {
- if (!selextend) {
- selextend = EXTEND_RIGHT;
- }
- if (selextend == EXTEND_RIGHT) {
- but->selend++;
- if (but->selend > len) but->selend = len;
- } else if (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;
- selextend = EXTEND_RIGHT;
- }
- }
+ selextend= selecttexttoright(but, len, selextend);
} else {
but->selsta = but->pos = but->selend;
selextend = 0;
@@ -1829,48 +1965,26 @@ static int ui_do_but_TEX(uiBut *but)
} else {
if(G.qual & LR_SHIFTKEY) {
/* make a selection, starting from the cursor position */
- but->selsta = but->pos;
-
- but->pos++;
- if(but->pos>strlen(str)) but->pos= strlen(str);
-
- but->selend = but->pos;
+ makeselectionfromcursorpos(but, str, RIGHT_DIRECTION, 0);
} else if(G.qual & LR_CTRLKEY) {
- /* jump betweenn special characters (/,\,_,-, etc.),
- * look at function test_special_char() for complete
- * list of special character, ctr -> */
- while(but->pos < len) {
- but->pos++;
- if(test_special_char(str[but->pos])) break;
- }
+ but->pos= movecursortillspecialchar(but->pos, str, RIGHT_DIRECTION);
} else {
- but->pos++;
- if(but->pos>strlen(str)) but->pos= strlen(str);
+ but->pos= movecursor(but->pos, str, RIGHT_DIRECTION, 1);
}
}
dodraw= 1;
break;
case LEFTARROWKEY:
+ /* select whole word */
+ if(G.qual==LR_SHIFTKEY+LR_CTRLKEY) {
+ makeselectionfromcursorpos(but, str, LEFT_DIRECTION, 1);
+ }
/* if there's a selection */
- if (SELWIDTH > 0) {
+ else if (SELWIDTH > 0) {
/* extend the selection based on the first direction taken */
if(G.qual & LR_SHIFTKEY) {
- if (!selextend) {
- selextend = EXTEND_LEFT;
- }
- if (selextend == EXTEND_LEFT) {
- but->selsta--;
- if (but->selsta < 0) but->selsta = 0;
- } else if (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;
- selextend = EXTEND_LEFT;
- }
- }
+ selextend= selecttexttoleft(but, selextend);
} else {
but->pos = but->selend = but->selsta;
selextend = 0;
@@ -1878,22 +1992,11 @@ static int ui_do_but_TEX(uiBut *but)
} else {
if(G.qual & LR_SHIFTKEY) {
/* 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;
+ makeselectionfromcursorpos(but, str, LEFT_DIRECTION, 0);
} else if(G.qual & LR_CTRLKEY) {
- /* jump betweenn special characters (/,\,_,-, etc.),
- * look at function test_special_char() for complete
- * list of special character, ctr -> */
- while(but->pos > 0){
- but->pos--;
- if(test_special_char(str[but->pos])) break;
- }
+ but->pos= movecursortillspecialchar(but->pos, str, LEFT_DIRECTION);
} else {
- if(but->pos>0) but->pos--;
+ but->pos= movecursor(but->pos, str, LEFT_DIRECTION, 1);
}
}
dodraw= 1;
@@ -1936,34 +2039,28 @@ static int ui_do_but_TEX(uiBut *but)
dodraw=1;
}
else if(but->pos>=0 && but->pos<strlen(str)) {
- for(x=but->pos; x<=strlen(str); x++)
- str[x]= str[x+1];
- str[--len]='\0';
+ len= erasetext(but, len, str, 0, 1);
dodraw= 1;
}
break;
- case BACKSPACEKEY:
+ case BACKSPACEKEY:
if(len!=0) {
if (SELWIDTH > 0) {
len -= ui_delete_selection_edittext(but);
if (len < 0) len = 0;
- dodraw=1;
+ }
+ else if(get_qual() & LR_CTRLKEY) {
+ len= erasetext(but, len, str, findfirstkeyoflastword(but->pos, str), 0);
}
else if(get_qual() & LR_SHIFTKEY) {
- str[0]= 0;
- but->pos= 0;
- len= 0;
- dodraw= 1;
- }
- else if(but->pos>0) {
- for(x=but->pos; x<=strlen(str); x++)
- str[x-1]= str[x];
- but->pos--;
- str[--len]='\0';
- dodraw= 1;
+ len= eraseall(but, len, str);
+ }
+ else if(but->pos>0) {
+ len= erasetext(but, len, str, 1, 0);
}
+ dodraw= 1;
}
break;
@@ -6597,4 +6694,3 @@ short pupmenu_col(char *instr, int maxro
return val;
}
-
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0e/49/33bcf7801d2eda553b1c93d7e717
Event Timeline
Log In to Comment