Alex Mole's patch for END and HOME

http://www.blender.org/pipermail/bf-committers/2003-December/004691.html

Makes HOME and END keys work in text space and text
edit boxes.

I've tested it for some time now and I haven't had any problem or spotted any irregularities of some sort.

One think though. It doesn't update the panning of the text window if the cursor gets out of the screen. I guess someone (more familiar with the code) could look into this.

Really nifty when coding scripts.
This commit is contained in:
2003-12-28 21:28:35 +00:00
parent 9aed5cb7f0
commit 65aeef11e1
2 changed files with 46 additions and 16 deletions

View File

@@ -1135,6 +1135,7 @@ static int ui_do_but_TEX(uiBut *but)
unsigned short dev;
short x, mval[2], len=0, dodraw;
char *str, backstr[UI_MAX_DRAW_STR];
short capturing;
str= (char *)but->poin;
@@ -1166,7 +1167,8 @@ static int ui_do_but_TEX(uiBut *but)
len= strlen(str);
but->min= 0.0;
while(TRUE) {
capturing = TRUE;
while(capturing) {
char ascii;
short val;
@@ -1195,29 +1197,45 @@ static int ui_do_but_TEX(uiBut *but)
}
else if(val) {
if(dev==RIGHTARROWKEY) {
switch (dev) {
case RIGHTARROWKEY:
if(G.qual & LR_SHIFTKEY) but->pos= strlen(str);
else but->pos++;
if(but->pos>strlen(str)) but->pos= strlen(str);
dodraw= 1;
}
else if(dev==LEFTARROWKEY) {
break;
case LEFTARROWKEY:
if(G.qual & LR_SHIFTKEY) but->pos= 0;
else if(but->pos>0) but->pos--;
dodraw= 1;
}
else if(dev==PADENTER || dev==RETKEY) {
break;
}
else if(dev==DELKEY) {
if(but->pos>=0 && but->pos<strlen(str)) {
for(x=but->pos; x<=strlen(str); x++)
str[x]= str[x+1];
str[--len]='\0';
dodraw= 1;
}
}
else if(dev==BACKSPACEKEY) {
case ENDKEY:
but->pos= strlen(str);
dodraw= 1;
break;
case HOMEKEY:
but->pos= 0;
dodraw= 1;
break;
case PADENTER:
case RETKEY:
capturing = FALSE;
break;
case DELKEY:
if(but->pos>=0 && but->pos<strlen(str)) {
for(x=but->pos; x<=strlen(str); x++)
str[x]= str[x+1];
str[--len]='\0';
dodraw= 1;
}
case BACKSPACEKEY:
if(len!=0) {
if(get_qual() & LR_SHIFTKEY) {
str[0]= 0;
@@ -1233,8 +1251,10 @@ static int ui_do_but_TEX(uiBut *but)
dodraw= 1;
}
}
break;
}
}
if(dodraw) {
ui_check_but(but);
ui_draw_but(but);