[vte/vte-0-36] widget: Add pref to control rewrapping on resize



commit a6a370872c592db2e1c1166a005688d71db3b4c0
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon Dec 16 22:23:15 2013 +0100

    widget: Add pref to control rewrapping on resize
    
    https://bugzilla.gnome.org/show_bug.cgi?id=336238

 doc/reference/vte-sections.txt |    2 +
 src/vte-private.h              |    1 +
 src/vte.c                      |   70 ++++++++++++++++++++++++++++++++++++++-
 src/vte.h                      |    2 +
 src/vteapp.c                   |    9 ++++-
 5 files changed, 81 insertions(+), 3 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 1bf7407..46a9cb5 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -28,6 +28,8 @@ vte_terminal_set_allow_bold
 vte_terminal_get_allow_bold
 vte_terminal_set_scroll_on_output
 vte_terminal_set_scroll_on_keystroke
+vte_terminal_set_rewrap_on_resize
+vte_terminal_get_rewrap_on_resize
 vte_terminal_set_color_bold
 vte_terminal_set_color_bold_rgba
 vte_terminal_set_color_foreground
diff --git a/src/vte-private.h b/src/vte-private.h
index daac9d4..9192fb3 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -275,6 +275,7 @@ struct _VteTerminalPrivate {
        gboolean text_modified_flag;
        gboolean text_inserted_flag;
        gboolean text_deleted_flag;
+       gboolean rewrap_on_resize;
 
        /* Scrolling options. */
        gboolean scroll_background;
diff --git a/src/vte.c b/src/vte.c
index 07b502f..a8337cb 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -185,6 +185,7 @@ enum {
         PROP_MOUSE_POINTER_AUTOHIDE,
         PROP_PTY,
         PROP_PTY_OBJECT,
+        PROP_REWRAP_ON_RESIZE,
         PROP_SCROLL_BACKGROUND,
         PROP_SCROLLBACK_LINES,
         PROP_SCROLL_ON_KEYSTROKE,
@@ -8246,8 +8247,8 @@ vte_terminal_set_size(VteTerminal *terminal, glong columns, glong rows)
                _vte_ring_set_visible_rows_hint(terminal->pvt->normal_screen.row_data, terminal->row_count);
                _vte_ring_set_visible_rows_hint(terminal->pvt->alternate_screen.row_data, 
terminal->row_count);
 
-               /* Always resize normal screen, even if alternate is visible: bug 415277 */
-               vte_terminal_screen_set_size(terminal, &terminal->pvt->normal_screen, old_columns, old_rows, 
TRUE);
+               /* Always resize normal screen (given that this feature is enabled), even if alternate is 
visible: bug 415277 */
+               vte_terminal_screen_set_size(terminal, &terminal->pvt->normal_screen, old_columns, old_rows, 
terminal->pvt->rewrap_on_resize);
                /* Resize the alternate screen if it's the current one, but never rewrap it: bug 336238 
comment 60 */
                if (terminal->pvt->screen == &terminal->pvt->alternate_screen)
                        vte_terminal_screen_set_size(terminal, &terminal->pvt->alternate_screen, old_columns, 
old_rows, FALSE);
@@ -8630,6 +8631,7 @@ vte_terminal_init(VteTerminal *terminal)
        pvt->allow_bold = TRUE;
        pvt->nrc_mode = TRUE;
         pvt->deccolm_mode = FALSE;
+        pvt->rewrap_on_resize = TRUE;
        vte_terminal_set_default_tabstops(terminal);
 
        /* Cursor shape. */
@@ -11741,6 +11743,9 @@ vte_terminal_get_property (GObject *object,
                 case PROP_PTY_OBJECT:
                         g_value_set_object (value, vte_terminal_get_pty_object(terminal));
                         break;
+                case PROP_REWRAP_ON_RESIZE:
+                        g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
+                        break;
                 case PROP_SCROLL_BACKGROUND:
                         g_value_set_boolean (value, pvt->scroll_background);
                         break;
@@ -11862,6 +11867,9 @@ vte_terminal_set_property (GObject *object,
                 case PROP_PTY_OBJECT:
                         vte_terminal_set_pty_object (terminal, g_value_get_object (value));
                         break;
+                case PROP_REWRAP_ON_RESIZE:
+                        vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
+                        break;
                 case PROP_SCROLL_BACKGROUND:
                         G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
                         vte_terminal_set_scroll_background (terminal, g_value_get_boolean (value));
@@ -12930,6 +12938,21 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                       G_PARAM_STATIC_STRINGS));
 
         /**
+         * VteTerminal:rewrap-on-resize:
+         *
+         * Controls whether or not the terminal will rewrap its contents, including
+         * the scrollback buffer, whenever the terminal's width changes.
+         * 
+         * Since: 0.36
+         */
+        g_object_class_install_property
+                (gobject_class,
+                 PROP_REWRAP_ON_RESIZE,
+                 g_param_spec_boolean ("rewrap-on-resize", NULL, NULL,
+                                       TRUE,
+                                       G_PARAM_READWRITE | STATIC_PARAMS));
+
+        /**
          * VteTerminal:scroll-background:
          *
          * Controls whether or not the terminal will scroll the background image (if
@@ -13340,6 +13363,49 @@ vte_terminal_set_alternate_screen_scroll(VteTerminal *terminal, gboolean scroll)
         /* We just want to export this symbol for compatibility */
 }
 
+/**
+ * vte_terminal_set_rewrap_on_resize:
+ * @terminal: a #VteTerminal
+ * @rewrap: %TRUE if the terminal should rewrap on resize
+ *
+ * Controls whether or not the terminal will rewrap its contents, including
+ * the scrollback history, whenever the terminal's width changes.
+ *
+ * Since: 0.36
+ */
+void
+vte_terminal_set_rewrap_on_resize(VteTerminal *terminal, gboolean rewrap)
+{
+        VteTerminalPrivate *pvt;
+
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        pvt = terminal->pvt;
+
+        if (rewrap == pvt->rewrap_on_resize)
+                return;
+
+        pvt->rewrap_on_resize = rewrap;
+        g_object_notify (G_OBJECT (terminal), "rewrap-on-resize");
+}
+
+/**
+ * vte_terminal_get_rewrap_on_resize:
+ * @terminal: a #VteTerminal
+ *
+ * Checks whether or not the terminal will rewrap its contents upon resize.
+ *
+ * Returns: %TRUE if rewrapping is enabled, %FALSE if not
+ *
+ * Since: 0.36
+ */
+gboolean
+vte_terminal_get_rewrap_on_resize(VteTerminal *terminal)
+{
+       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+       return terminal->pvt->rewrap_on_resize;
+}
+
 static void
 vte_terminal_real_copy_clipboard(VteTerminal *terminal)
 {
diff --git a/src/vte.h b/src/vte.h
index f120de0..1b892b9 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -309,6 +309,8 @@ gboolean vte_terminal_get_visible_bell(VteTerminal *terminal);
 void vte_terminal_set_scroll_on_output(VteTerminal *terminal, gboolean scroll);
 void vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal,
                                          gboolean scroll);
+void vte_terminal_set_rewrap_on_resize(VteTerminal *terminal, gboolean rewrap);
+gboolean vte_terminal_get_rewrap_on_resize(VteTerminal *terminal);
 
 /* Set the color scheme. */
 void vte_terminal_set_color_dim(VteTerminal *terminal,
diff --git a/src/vteapp.c b/src/vteapp.c
index 822d8c2..811ff8a 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -557,7 +557,7 @@ main(int argc, char **argv)
                 icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
                 cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE,
                 antialias = TRUE, use_scrolled_window = FALSE,
-                show_object_notifications = FALSE;
+                show_object_notifications = FALSE, rewrap = TRUE;
        char *geometry = NULL;
        gint lines = -1;
        const char *message = "Launching interactive shell...\r\n";
@@ -593,6 +593,11 @@ main(int argc, char **argv)
                        "Highlight URLs inside the terminal", NULL
                },
                {
+                       "no-rewrap", 'R', G_OPTION_FLAG_REVERSE,
+                       G_OPTION_ARG_NONE, &rewrap,
+                       "Disable rewrapping on resize", NULL
+               },
+               {
                        "shell", 'S', G_OPTION_FLAG_REVERSE,
                        G_OPTION_ARG_NONE, &shell,
                        "Disable spawning a shell inside the terminal", NULL
@@ -923,6 +928,8 @@ main(int argc, char **argv)
        }
        vte_terminal_set_cursor_shape(terminal, cursor_shape);
 
+       vte_terminal_set_rewrap_on_resize(terminal, rewrap);
+
        /* Set the default font. */
         G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
        vte_terminal_set_font_from_string_full(terminal, font,


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