[vte] widget: Factor out underline and strikethrough position and thickness



commit dc870c1f3d1f61fc4a5bfdf164c5ada5bafea2d9
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Oct 29 14:43:40 2017 +0100

    widget: Factor out underline and strikethrough position and thickness
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781479

 src/vte.cc         |   45 +++++++++++++++++++++++++++------------------
 src/vteinternal.hh |    4 ++++
 2 files changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 90beb26..270ec95 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -7547,8 +7547,13 @@ VteTerminalPrivate::apply_font_metrics(int width,
                m_char_descent = descent;
        }
        m_line_thickness = MAX (MIN ((height - ascent) / 2, height / 14), 1);
+        /* FIXME take these from pango_font_metrics_get_{underline,strikethrough}_{position,thickness} */
        m_underline_position = MIN (ascent + m_line_thickness, height - m_line_thickness);
+        m_underline_thickness = m_line_thickness;
        m_strikethrough_position =  ascent - height / 4;
+        m_strikethrough_thickness = m_line_thickness;
+        m_regex_underline_position = height - 1;  /* FIXME */
+        m_regex_underline_thickness = 1;  /* FIXME */
 
        /* Queue a resize if anything's changed. */
        if (resize) {
@@ -8019,7 +8024,11 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
        m_char_descent = 1;
        m_line_thickness = 1;
        m_underline_position = 1;
+        m_underline_thickness = 1;
        m_strikethrough_position = 1;
+        m_strikethrough_thickness = 1;
+        m_regex_underline_position = 1;
+        m_regex_underline_thickness = 1;
 
         m_row_count = VTE_ROWS;
         m_column_count = VTE_COLUMNS;
@@ -8882,37 +8891,37 @@ VteTerminalPrivate::draw_cells(struct _vte_draw_text_request *items,
                        }
                        if (underline) {
                                 _vte_draw_draw_line(m_draw,
-                                               x,
-                                               y + m_underline_position,
-                                               x + (columns * column_width) - 1,
-                                                    y + m_underline_position + m_line_thickness - 1,
+                                                    x,
+                                                    y + m_underline_position,
+                                                    x + (columns * column_width) - 1,
+                                                    y + m_underline_position + m_underline_thickness - 1,
                                                     VTE_LINE_WIDTH,
                                                     &fg, VTE_DRAW_OPAQUE);
                        }
                        if (strikethrough) {
                                 _vte_draw_draw_line(m_draw,
-                                               x,
-                                               y + m_strikethrough_position,
-                                               x + (columns * column_width) - 1,
-                                                       y + m_strikethrough_position + m_line_thickness - 1,
-                                                       VTE_LINE_WIDTH,
-                                                       &fg, VTE_DRAW_OPAQUE);
+                                                    x,
+                                                    y + m_strikethrough_position,
+                                                    x + (columns * column_width) - 1,
+                                                    y + m_strikethrough_position + m_strikethrough_thickness 
- 1,
+                                                    VTE_LINE_WIDTH,
+                                                    &fg, VTE_DRAW_OPAQUE);
                        }
                        if (hilite) {
                                 _vte_draw_draw_line(m_draw,
-                                               x,
-                                               y + row_height - 1,
-                                               x + (columns * column_width) - 1,
-                                                       y + row_height - 1,
-                                                       VTE_LINE_WIDTH,
-                                                       &fg, VTE_DRAW_OPAQUE);
+                                                    x,
+                                                    y + m_regex_underline_position,
+                                                    x + (columns * column_width) - 1,
+                                                    y + m_regex_underline_position + 
m_regex_underline_thickness - 1,
+                                                    VTE_LINE_WIDTH,
+                                                    &fg, VTE_DRAW_OPAQUE);
                         } else if (hyperlink) {
                                 for (double j = 1.0 / 6.0; j < columns; j += 0.5) {
                                         _vte_draw_fill_rectangle(m_draw,
                                                                  x + j * column_width,
-                                                                 y + row_height - 1,
+                                                                 y + m_regex_underline_position,
                                                                  MAX(column_width / 6.0, 1.0),
-                                                                 1,
+                                                                 m_regex_underline_thickness,
                                                                  &fg, VTE_DRAW_OPAQUE);
                                 }
                         }
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index a275f2c..108ce20 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -520,7 +520,11 @@ public:
         gboolean m_has_fonts;
         long m_line_thickness;
         long m_underline_position;
+        long m_underline_thickness;
         long m_strikethrough_position;
+        long m_strikethrough_thickness;
+        long m_regex_underline_position;
+        long m_regex_underline_thickness;
 
         /* Style stuff */
         GtkBorder m_padding;


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