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:
authorCampbell Barton <ideasman42@gmail.com>2010-11-29 23:42:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-29 23:42:03 +0300
commita5cac5434a9cb316b24e4b0a47c4d3f2f240dec6 (patch)
tree6c24aa5e18f967a0bf7979ad2a1d2e4c11aa8ae1 /source/blender/editors/space_console
parentc8422f0de3ef0ded0aa6886b8b2233f812b25647 (diff)
bugfix [#24969] Python Console bug: inserting a large text leads to strange caret behavior
Caret wasn't wrapping.
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_draw.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 6d7eb45f31e..8112008e9a1 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -150,17 +150,35 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
/* 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);