[gtksourceview] SpaceDrawer: do not have duplicated code for line-wrap handling



commit 70c39a7da203ece0529d95ac5cb674e968e3e8bb
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Jul 22 23:16:52 2016 +0200

    SpaceDrawer: do not have duplicated code for line-wrap handling

 gtksourceview/gtksourcespacedrawer.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/gtksourceview/gtksourcespacedrawer.c b/gtksourceview/gtksourcespacedrawer.c
index 7e48a10..9fb053f 100644
--- a/gtksourceview/gtksourcespacedrawer.c
+++ b/gtksourceview/gtksourcespacedrawer.c
@@ -180,10 +180,7 @@ draw_space_at_pos (cairo_t      *cr,
        x = rect.x;
        y = rect.y + rect.height * 2 / 3;
 
-       /* If the space is at a line-wrap position we get 0 width
-        * so we fallback to the height.
-        */
-       w = rect.width != 0 ? rect.width : rect.height;
+       w = rect.width;
 
        cairo_save (cr);
        cairo_move_to (cr, x + w * 0.5, y);
@@ -201,10 +198,7 @@ draw_tab_at_pos (cairo_t      *cr,
        x = rect.x;
        y = rect.y + rect.height * 2 / 3;
 
-       /* If the space is at a line-wrap position we get 0 width
-        * so we fallback to the height.
-        */
-       w = rect.width != 0 ? rect.width : rect.height;
+       w = rect.width;
        h = rect.height;
 
        cairo_save (cr);
@@ -226,8 +220,7 @@ draw_newline_at_pos (cairo_t      *cr,
        x = rect.x;
        y = rect.y + rect.height / 3;
 
-       /* width for new line is 0, we use 2 * h */
-       w = 2 * rect.height;
+       w = 2 * rect.width;
        h = rect.height;
 
        cairo_save (cr);
@@ -264,10 +257,7 @@ draw_nbsp_at_pos (cairo_t      *cr,
        x = rect.x;
        y = rect.y + rect.height / 2;
 
-       /* If the space is at a line-wrap position we get 0 width
-        * so we fallback to the height.
-        */
-       w = rect.width != 0 ? rect.width : rect.height;
+       w = rect.width;
        h = rect.height;
 
        cairo_save (cr);
@@ -298,6 +288,14 @@ draw_whitespace_at_iter (GtkTextView *text_view,
 
        gtk_text_view_get_iter_location (text_view, iter, &rect);
 
+       /* If the space is at a line-wrap position, or if the character is a
+        * newline, we get 0 width so we fallback to the height.
+        */
+       if (rect.width == 0)
+       {
+               rect.width = rect.height;
+       }
+
        c = gtk_text_iter_get_char (iter);
 
        if (c == '\t')


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