[Bf-blender-cvs] [4535776] temp-text_editor_cursor_api: fix for linenumber offset, was not taken into account before, also missed some y offset because cursor position was at top-left of character

Martin Felke noreply at git.blender.org
Tue Dec 30 12:54:59 CET 2014


Commit: 45357768832ff494ff4dfe6e4991d67f75aec954
Author: Martin Felke
Date:   Tue Dec 30 12:53:58 2014 +0100
Branches: temp-text_editor_cursor_api
https://developer.blender.org/rB45357768832ff494ff4dfe6e4991d67f75aec954

fix for linenumber offset, was not taken into account before, also missed some y offset because cursor position was at top-left of character

===================================================================

M	source/blender/editors/space_text/text_draw.c

===================================================================

diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 074c569..d9d46de 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1567,14 +1567,15 @@ bool ED_text_region_location_from_cursor(SpaceText *st, ARegion* ar, const int c
 	}
 	else {
 		int offl = 0, offc = 0;
+		int linenr_offset = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
 
 		if (st->wordwrap) {
 			wrap_offset(st, ar, line, cursor_co[1], &offl, &offc);
 		}
 
-		r_pixel_co[0] = (cursor_co[1] + offc - st->left) * st->cwidth;
+		r_pixel_co[0] = (cursor_co[1] + offc - st->left) * st->cwidth + linenr_offset;
 		r_pixel_co[1] = (cursor_co[0] + offl - st->top) * (st->lheight_dpi + TXT_LINE_SPACING);
-		r_pixel_co[1] = ar->winy - r_pixel_co[1];
+		r_pixel_co[1] = ar->winy - (r_pixel_co[1] + TXT_OFFSET);
 	}
 	return true;




More information about the Bf-blender-cvs mailing list