[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33383] trunk/blender/source/blender/ editors: bugfix [#24969] Python Console bug: inserting a large text leads to strange caret behavior
Campbell Barton
ideasman42 at gmail.com
Mon Nov 29 21:42:03 CET 2010
Revision: 33383
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33383
Author: campbellbarton
Date: 2010-11-29 21:42:03 +0100 (Mon, 29 Nov 2010)
Log Message:
-----------
bugfix [#24969] Python Console bug: inserting a large text leads to strange caret behavior
Caret wasn't wrapping.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_console/console_draw.c
trunk/blender/source/blender/editors/space_info/textview.c
trunk/blender/source/blender/editors/space_info/textview.h
Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c 2010-11-29 18:58:49 UTC (rev 33382)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c 2010-11-29 20:42:03 UTC (rev 33383)
@@ -150,17 +150,35 @@
/* annoying hack, to draw the prompt */
if(tvc->iter_index == 0) {
- SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
- int prompt_len= strlen(sc->prompt);
+ const SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
+ const ConsoleLine *cl= (ConsoleLine *)sc->history.last;
+ const int prompt_len= strlen(sc->prompt);
+ const int cursor_loc= cl->cursor + prompt_len;
int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
- const int cursor = ((ConsoleLine *)sc->history.last)->cursor;
+ int pen[2];
xy[1] += tvc->lheight/6;
-
+
+ /* account for wrapping */
+ if(cl->len < tvc->console_width) {
+ /* simple case, no wrapping */
+ pen[0]= tvc->cwidth * cursor_loc;
+ pen[1]= -2;
+ }
+ else {
+ /* wrap */
+ pen[0]= tvc->cwidth * (cursor_loc % tvc->console_width);
+ pen[1]= -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
+ }
+
/* cursor */
UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, (char *)fg);
glColor3ubv(fg);
- glRecti(xy[0]+(tvc->cwidth*(cursor+prompt_len)) -1, xy[1]-2, xy[0]+(tvc->cwidth*(cursor+prompt_len)) +1, xy[1]+tvc->lheight-2);
+ glRecti( (xy[0] + pen[0]) - 1,
+ (xy[1] + pen[1]),
+ (xy[0] + pen[0]) + 1,
+ (xy[1] + pen[1] + tvc->lheight)
+ );
}
console_line_color(fg, cl->type);
Modified: trunk/blender/source/blender/editors/space_info/textview.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.c 2010-11-29 18:58:49 UTC (rev 33382)
+++ trunk/blender/source/blender/editors/space_info/textview.c 2010-11-29 20:42:03 UTC (rev 33383)
@@ -250,6 +250,7 @@
/* shouldnt be needed */
tvc->cwidth= cdc.cwidth;
+ tvc->console_width= cdc.console_width;
tvc->iter_index= 0;
if(tvc->sel_start != tvc->sel_end) {
Modified: trunk/blender/source/blender/editors/space_info/textview.h
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.h 2010-11-29 18:58:49 UTC (rev 33382)
+++ trunk/blender/source/blender/editors/space_info/textview.h 2010-11-29 20:42:03 UTC (rev 33383)
@@ -28,6 +28,8 @@
/* view settings */
int cwidth; /* shouldnt be needed! */
+ int console_width; /* shouldnt be needed! */
+
int winx;
int ymin, ymax;
More information about the Bf-blender-cvs
mailing list