Page Menu
Home
Search
Configure Global Search
Log In
Files
F4161
ctrlbs18.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
ctrlbs18.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 16:53:24 -0000
@@ -234,4 +234,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 16:53:27 -0000
@@ -1653,6 +1653,153 @@ 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 -> */
+
+ /* right*/
+ if(dir == 1) {
+ while(butpos < strlen(str)) {
+ butpos++;
+ if(test_special_char(str[butpos])) break;
+ }
+ } /* left*/
+ else {
+ while(butpos > 0) {
+ butpos--;
+ if(test_special_char(str[butpos])) break;
+ }
+ }
+
+ return butpos;
+}
+
+static short movecursor(short butpos, char *str, short dir, short steps) {
+ /* right*/
+ if(dir == 1) {
+ if(butpos < strlen(str)) {
+ butpos+=steps;
+ }
+ } /* left*/
+ else {
+ if(butpos > 0) {
+ butpos-=steps;
+ }
+ }
+
+ return butpos;
+}
+
+static void setcursortostart(uiBut* but, char *str, short dir) {
+ if(dir == 1)
+ but->selsta = but->pos;
+ else
+ but->selend = but->pos;
+
+ but->pos= movecursor(but->pos, str, dir, 1);
+
+ if(dir == 1)
+ 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 findlastkeyoflastword(short butpos, char *str) {
+ short foundword= 0, eraseamount= 0, x;
+
+ for(x=butpos; x<strlen(str); 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 +1950,28 @@ static int ui_do_but_TEX(uiBut *but)
switch (dev) {
case RIGHTARROWKEY:
+ /* select whole word */
+ if(G.qual==LR_SHIFTKEY+LR_CTRLKEY) {
+ short distancetolastkey;
+
+ /* make a selection, starting from the cursor position */
+ if (SELWIDTH == 0)
+ setcursortostart(but, str, 1);
+
+ /* we want to get the distance from selection if there's one */
+ if(SELWIDTH != 0)
+ distancetolastkey= findlastkeyoflastword(but->selsta, str);
+ else
+ distancetolastkey= findlastkeyoflastword(but->pos, str);
+
+ for(x=0; x<distancetolastkey; x++)
+ selextend= selecttexttoright(but, len, selextend);
+ }
/* 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 +1979,39 @@ 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;
+ setcursortostart(but, str, 1);
} 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, 1);
} else {
- but->pos++;
- if(but->pos>strlen(str)) but->pos= strlen(str);
+ but->pos= movecursor(but->pos, str, 1, 1);
}
}
dodraw= 1;
break;
case LEFTARROWKEY:
+ /* select whole word */
+ if(G.qual==LR_SHIFTKEY+LR_CTRLKEY) {
+ short distancetofirstkey;
+
+ /* make a selection, starting from the cursor position */
+ if (SELWIDTH == 0)
+ setcursortostart(but, str, -1);
+
+ /* we want to get the distance from selection if there's one */
+ if(SELWIDTH != 0)
+ distancetofirstkey= findfirstkeyoflastword(but->selsta, str);
+ else
+ distancetofirstkey= findfirstkeyoflastword(but->pos, str);
+
+ for(x=0; x<distancetofirstkey; x++)
+ selextend= selecttexttoleft(but, selextend);
+ }
/* 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 +2019,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;
+ setcursortostart(but, str, -1);
} 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, -1);
} else {
- if(but->pos>0) but->pos--;
+ but->pos= movecursor(but->pos, str, -1, 1);
}
}
dodraw= 1;
@@ -1936,34 +2066,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 +6721,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
1e/e4/5926955cffacbcb57a6faaf96659
Event Timeline
Log In to Comment