Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2010-12-17 22:58:02 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2010-12-17 22:58:02 +0300
commit4b0c455093202ff203b7ea751786c39afcdc5633 (patch)
treee857e6374719a313be3af1141a5609edccaa64b4 /source/blender/editors/space_text/text_ops.c
parenta0ce28d7312adc31194e2ba34974dc5de754fced (diff)
Fix #25263: Text cursor click point is random.
- Fixed some wierd cursor placements when clicking in special text position (mostly when line segments had null-terminator at the max allowed position) - Also subtract top padding, so centering is looks a bit better
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r--source/blender/editors/space_text/text_ops.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index bd291cc8fe2..c594fa7acc0 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -2220,14 +2220,14 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
Text *text= st->text;
TextLine **linep;
int *charp;
- int w, tabs;
+ int w;
text_update_character_width(st);
if(sel) { linep= &text->sell; charp= &text->selc; }
else { linep= &text->curl; charp= &text->curc; }
- y= (ar->winy - y)/st->lheight;
+ y= (ar->winy - 2 - y)/st->lheight;
if(st->showlinenrs)
x-= TXT_OFFSET+TEXTXLOC;
@@ -2267,14 +2267,12 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
chars= 0;
curs= 0;
endj= 0;
- tabs= 0;
for(i=0, j=0; loop; j++) {
/* Mimic replacement of tabs */
ch= (*linep)->line[j];
if(ch=='\t') {
chars= st->tabnumber-i%st->tabnumber;
- tabs+= chars-1;
ch= ' ';
}
else
@@ -2302,7 +2300,7 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
if(found) {
/* exact cursor position was found, check if it's */
/* still on needed line (hasn't been wrapped) */
- if(*charp>endj && !chop) (*charp)= endj;
+ if(*charp>endj && !chop && ch!='\0') (*charp)= endj;
loop= 0;
break;
}
@@ -2311,7 +2309,7 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
start= end;
end += max;
- if(start-tabs<(*linep)->len)
+ if(j<(*linep)->len)
y--;
chop= 1;
@@ -2340,13 +2338,13 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
}
if(ch=='\0') break;
}
- if(!loop || y<0) break;
+ if(!loop || found) break;
if(!(*linep)->next) {
*charp= (*linep)->len;
break;
}
-
+
/* On correct line but didn't meet cursor, must be at end */
if(y==0) {
*charp= (*linep)->len;