Revision: 51321
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51321
Author:   lockal
Date:     2012-10-14 19:57:49 +0000 (Sun, 14 Oct 2012)
Log Message:
-----------
Fix for misplaced cursor in wrapped console prompt, also fixes newline for 
single wrap when input line width equals console width

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_console/console_draw.c
    trunk/blender/source/blender/editors/space_info/textview.c

Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c   
2012-10-14 19:39:38 UTC (rev 51320)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c   
2012-10-14 19:57:49 UTC (rev 51321)
@@ -94,12 +94,14 @@
 {
        /* fake the edit line being in the scroll buffer */
        ConsoleLine *cl = sc->history.last;
+       int prompt_len = strlen(sc->prompt);
+       
        cl_dummy->type = CONSOLE_LINE_INPUT;
-       cl_dummy->len = cl_dummy->len_alloc = strlen(sc->prompt) + cl->len;
+       cl_dummy->len = prompt_len + cl->len;
        cl_dummy->len_alloc = cl_dummy->len + 1;
        cl_dummy->line = MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
-       memcpy(cl_dummy->line, sc->prompt, (cl_dummy->len_alloc - cl->len));
-       memcpy(cl_dummy->line + ((cl_dummy->len_alloc - cl->len)) - 1, 
cl->line, cl->len + 1);
+       memcpy(cl_dummy->line, sc->prompt, prompt_len);
+       memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1);
        BLI_addtail(&sc->scrollback, cl_dummy);
 }
 void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine 
*cl_dummy) 
@@ -158,12 +160,13 @@
                const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
                const int prompt_len = strlen(sc->prompt);
                const int cursor_loc = cl->cursor + prompt_len;
+               const int line_len = cl->len + prompt_len;
                int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
                int pen[2];
                xy[1] += tvc->lheight / 6;
 
                /* account for wrapping */
-               if (cl->len < tvc->console_width) {
+               if (line_len < tvc->console_width) {
                        /* simple case, no wrapping */
                        pen[0] = tvc->cwidth * cursor_loc;
                        pen[1] = -2;
@@ -171,7 +174,7 @@
                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);
+                       pen[1] = -2 + (((line_len / tvc->console_width) - 
(cursor_loc / tvc->console_width)) * tvc->lheight);
                }
 
                /* cursor */

Modified: trunk/blender/source/blender/editors/space_info/textview.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.c  2012-10-14 
19:39:38 UTC (rev 51320)
+++ trunk/blender/source/blender/editors/space_info/textview.c  2012-10-14 
19:57:49 UTC (rev 51321)
@@ -128,7 +128,7 @@
                return 1;
        }
 
-       if (str_len > cdc->console_width) { /* wrap? */
+       if (tot_lines > 1) { /* wrap? */
                const int initial_offset = ((tot_lines - 1) * 
cdc->console_width);
                const char *line_stride = str + initial_offset;  /* advance to 
the last line and draw it first */
                

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to