[pango/matthiasc/for-main: 4/5] pango-view: More careful numbering




commit 52db8f0802f6dde2be1af83006932dd2d8685c97
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 29 18:23:51 2021 -0400

    pango-view: More careful numbering
    
    Don't overwrite caret position numbers with
    different numbers.

 utils/viewer-pangocairo.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index ce1e1983..1083e33c 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -475,6 +475,7 @@ render_callback (PangoLayout *layout,
           const PangoLogAttr *attrs;
           int n_attrs;
           int offset;
+          int num = 0;
 
           /* draw the caret positions in purple */
           cairo_save (cr);
@@ -524,7 +525,7 @@ render_callback (PangoLayout *layout,
                       cairo_close_path (cr);
                       cairo_fill (cr);
 
-                      char *s = g_strdup_printf ("%d", i + trailing);
+                      char *s = g_strdup_printf ("%d", num);
                       cairo_set_source_rgb (cr, 0, 0, 0);
                       cairo_move_to (cr, x / PANGO_SCALE - 5, y / PANGO_SCALE + 15);
                       cairo_show_text (cr, s);
@@ -532,9 +533,13 @@ render_callback (PangoLayout *layout,
                    }
 
                   if (i < run->item->num_chars)
-                    p = g_utf8_next_char (p);
+                    {
+                      num++;
+                      p = g_utf8_next_char (p);
+                    }
                   else
                     trailing = TRUE;
+
                 }
             }
           while (pango_layout_iter_next_run (iter));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]