Fix T74298: Incorrect cursor position in Python console
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 May 2020 08:05:09 +0000 (18:05 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 May 2020 08:16:52 +0000 (18:16 +1000)
source/blender/editors/space_console/console_draw.c
source/blender/editors/space_info/info_draw.c
source/blender/editors/space_info/textview.c

index 6c56e8dfb79b891ae5b9b3f423c2ac5a4ae84b16..6b741363d423dea51e8ab30ef42452113c213273 100644 (file)
@@ -91,7 +91,6 @@ void console_scrollback_prompt_end(SpaceConsole *sc, ConsoleLine *cl_dummy)
 static int console_textview_begin(TextViewContext *tvc)
 {
   SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
-  tvc->lheight = sc->lheight * UI_DPI_FAC;
   tvc->sel_start = sc->sel_start;
   tvc->sel_end = sc->sel_end;
 
@@ -157,10 +156,10 @@ static void console_textview_draw_cursor(TextViewContext *tvc,
     console_cursor_wrap_offset(sc->prompt, columns, &offl, &offc, NULL);
     console_cursor_wrap_offset(cl->line, columns, &offl, &offc, cl->line + cl->cursor);
     pen[0] = cwidth * offc;
-    pen[1] = -2 - (tvc->lheight + descender) * offl;
+    pen[1] = -tvc->lheight * offl;
 
     console_cursor_wrap_offset(cl->line + cl->cursor, columns, &offl, &offc, NULL);
-    pen[1] += (tvc->lheight + descender) * offl;
+    pen[1] += tvc->lheight * offl;
 
     pen[0] += tvc->draw_rect.xmin;
     pen[1] += tvc->draw_rect.ymin;
@@ -229,7 +228,7 @@ static int console_textview_main__internal(SpaceConsole *sc,
   /* view */
   tvc.sel_start = sc->sel_start;
   tvc.sel_end = sc->sel_end;
-  tvc.lheight = sc->lheight * 1.2f * UI_DPI_FAC;
+  tvc.lheight = sc->lheight * UI_DPI_FAC;
   tvc.scroll_ymin = v2d->cur.ymin;
   tvc.scroll_ymax = v2d->cur.ymax;
 
index 2a3f6d6e365a8509e49fab9bbd215644da3d1a3d..3685e5de8527e8f66ac9fe9b5553f717a0e6a852 100644 (file)
@@ -141,7 +141,6 @@ static int report_textview_begin(TextViewContext *tvc)
 {
   const ReportList *reports = tvc->arg2;
 
-  tvc->lheight = 14 * UI_DPI_FAC;
   tvc->sel_start = 0;
   tvc->sel_end = 0;
 
index c842fa8b4ac05ac2dc7a45c01b1610b3d8681d67..3c0ef4a63866e2052b1dde77f3db666cf7b5b570 100644 (file)
@@ -394,26 +394,27 @@ int textview_draw(TextViewContext *tvc,
 
       tvc->line_get(tvc, &ext_line, &ext_len);
 
-      if (!textview_draw_string(&tds,
-                                ext_line,
-                                ext_len,
-                                (data_flag & TVC_LINE_FG) ? fg : NULL,
-                                (data_flag & TVC_LINE_BG) ? bg : NULL,
-                                (data_flag & TVC_LINE_ICON) ? icon : 0,
-                                (data_flag & TVC_LINE_ICON_FG) ? icon_fg : NULL,
-                                (data_flag & TVC_LINE_ICON_BG) ? icon_bg : NULL,
-                                bg_sel)) {
-        /* When drawing, if we pass v2d->cur.ymax, then quit. */
-        if (do_draw) {
-          /* Past the y limits. */
-          break;
-        }
-      }
+      const bool is_out_of_view_y = !textview_draw_string(
+          &tds,
+          ext_line,
+          ext_len,
+          (data_flag & TVC_LINE_FG) ? fg : NULL,
+          (data_flag & TVC_LINE_BG) ? bg : NULL,
+          (data_flag & TVC_LINE_ICON) ? icon : 0,
+          (data_flag & TVC_LINE_ICON_FG) ? icon_fg : NULL,
+          (data_flag & TVC_LINE_ICON_BG) ? icon_bg : NULL,
+          bg_sel);
 
       if (do_draw) {
+        /* We always want the cursor to draw. */
         if (tvc->draw_cursor && iter_index == 0) {
           tvc->draw_cursor(tvc, tds.cwidth, tds.columns, tds.lofs);
         }
+
+        /* When drawing, if we pass v2d->cur.ymax, then quit. */
+        if (is_out_of_view_y) {
+          break;
+        }
       }
 
       if ((mval[1] != INT_MAX) && (mval[1] >= y_prev && mval[1] <= xy[1])) {