[vte] widget: Fix display glitches with rectangular selection and wide characters



commit b446923caf746a18e4fa9eb298eacf751e53256f
Author: Egmont Koblinger <egmont gmail com>
Date:   Wed May 28 12:28:08 2014 +0200

    widget: Fix display glitches with rectangular selection and wide characters
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730800

 src/vte.c        |    4 ++--
 src/vterowdata.h |   11 ++++++-----
 src/vteseq.c     |   21 +++++++++------------
 3 files changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 1bda1a9..85e31c7 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -6759,14 +6759,14 @@ vte_terminal_extend_selection(VteTerminal *terminal, long x, long y,
                        /* The left band */
                        _vte_invalidate_region (terminal,
                                                MIN(sc->col, so->col),
-                                               MAX(sc->col, so->col) - 1,
+                                               MAX(sc->col, so->col) - 1 + (VTE_TAB_WIDTH_MAX - 1),
                                                MIN(sc->row, so->row),
                                                MAX(ec->row, eo->row),
                                                TRUE);
                        /* The right band */
                        _vte_invalidate_region (terminal,
                                                MIN(ec->col, eo->col) + 1,
-                                               MAX(ec->col, eo->col),
+                                               MAX(ec->col, eo->col) + (VTE_TAB_WIDTH_MAX - 1),
                                                MIN(sc->row, so->row),
                                                MAX(ec->row, eo->row),
                                                TRUE);
diff --git a/src/vterowdata.h b/src/vterowdata.h
index 6af9634..aed9412 100644
--- a/src/vterowdata.h
+++ b/src/vterowdata.h
@@ -26,6 +26,8 @@
 
 G_BEGIN_DECLS
 
+#define VTE_TAB_WIDTH_BITS             4  /* Has to be able to store the value of 8. */
+#define VTE_TAB_WIDTH_MAX              ((1 << VTE_TAB_WIDTH_BITS) - 1)
 
 #define VTE_DEFAULT_FG                 256
 #define VTE_DEFAULT_BG                 257
@@ -47,11 +49,10 @@ G_BEGIN_DECLS
 
 typedef struct _VteCellAttr {
        guint64 fragment: 1;    /* A continuation cell. */
-       guint64 columns: 4;     /* Number of visible columns
-                                  (as determined by g_unicode_iswide(c)).
-                                  Also abused for tabs; bug 353610
-                                  Keep at least 4 for tabs to work
-                                  */
+       guint64 columns: VTE_TAB_WIDTH_BITS;    /* Number of visible columns
+                                                  (as determined by g_unicode_iswide(c)).
+                                                  Also abused for tabs; bug 353610
+                                                  */
        guint64 bold: 1;
        guint64 italic: 1;
        guint64 fore: 25;       /* Index into color palette, or direct RGB, */
diff --git a/src/vteseq.c b/src/vteseq.c
index 8371ebb..3d76143 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -1717,22 +1717,19 @@ vte_sequence_handler_tab (VteTerminal *terminal, GValueArray *params)
                        }
                        /* Nothing found on the line after us, turn this into
                         * a smart tab */
-                       if (!found) {
+                       if (!found && newcol - col <= VTE_TAB_WIDTH_MAX) {
                                VteCell *cell = _vte_row_data_get_writable (rowdata, col);
                                VteCell tab = *cell;
                                tab.attr.columns = newcol - col;
                                tab.c = '\t';
-                               /* Check if it fits in columns */
-                               if (tab.attr.columns == newcol - col) {
-                                       /* Save tab char */
-                                       *cell = tab;
-                                       /* And adjust the fragments */
-                                       for (i = col + 1; i < newcol; i++) {
-                                               cell = _vte_row_data_get_writable (rowdata, i);
-                                               cell->c = '\t';
-                                               cell->attr.columns = 1;
-                                               cell->attr.fragment = 1;
-                                       }
+                               /* Save tab char */
+                               *cell = tab;
+                               /* And adjust the fragments */
+                               for (i = col + 1; i < newcol; i++) {
+                                       cell = _vte_row_data_get_writable (rowdata, i);
+                                       cell->c = '\t';
+                                       cell->attr.columns = 1;
+                                       cell->attr.fragment = 1;
                                }
                        }
                }


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