[Xfce4-commits] [apps/xfce4-terminal] 01/01: Bracketed paste mode support

noreply at xfce.org noreply at xfce.org
Tue Dec 27 12:55:13 CET 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit 4094b6bfdf30f48518a2e5bc7a84850fd732d61c
Author: Igor <f2404 at yandex.ru>
Date:   Tue Dec 27 14:52:19 2016 +0300

    Bracketed paste mode support
    
    Bracketed paste mode prevents contents pasted into the terminal from being
    autoexecuted. There's more info on the following links:
    https://cirw.in/blog/bracketed-paste
    http://thejh.net/misc/website-terminal-copy-paste
    
    Fixes https://bugzilla.xfce.org/show_bug.cgi?id=13252
---
 terminal/terminal-preferences.c | 13 ++++++++++++-
 terminal/terminal-screen.c      | 20 +++++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 851301a..e273f5b 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -103,6 +103,7 @@ enum
   PROP_MISC_REWRAP_ON_RESIZE,
   PROP_MISC_SHIFT_ARROWS_SCROLL,
   PROP_MISC_SLIM_TABS,
+  PROP_MISC_BRACKETED_PASTE,
   PROP_SCROLLING_BAR,
   PROP_SCROLLING_LINES,
   PROP_SCROLLING_ON_OUTPUT,
@@ -936,7 +937,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
-   * TerminalPreferences:misc-shift-arrows-scroll:
+   * TerminalPreferences:misc-slim-tabs:
    **/
   preferences_props[PROP_MISC_SLIM_TABS] =
       g_param_spec_boolean ("misc-slim-tabs",
@@ -946,6 +947,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:misc-bracketed-paste:
+   **/
+  preferences_props[PROP_MISC_BRACKETED_PASTE] =
+      g_param_spec_boolean ("misc-bracketed-paste",
+                            NULL,
+                            "MiscBracketedPaste",
+                            FALSE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:scrolling-bar:
    **/
   preferences_props[PROP_SCROLLING_BAR] =
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index c2069d5..4076cc9 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -1537,6 +1537,8 @@ terminal_screen_launch_child (TerminalScreen *screen)
   guint         i;
   VtePtyFlags   pty_flags = VTE_PTY_DEFAULT;
   GSpawnFlags   spawn_flags = G_SPAWN_CHILD_INHERITS_STDIN | G_SPAWN_SEARCH_PATH;
+  const gchar  *bracketed_paste = "\e[?2004h";
+  gboolean      enable_bracketed_paste;
 
   terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
 
@@ -1568,16 +1570,24 @@ terminal_screen_launch_child (TerminalScreen *screen)
         }
 
       if (!vte_terminal_spawn_sync (VTE_TERMINAL (screen->terminal),
-                                           pty_flags,
-                                           screen->working_directory, argv2, env,
-                                           spawn_flags,
-                                           NULL, NULL,
-                                           &screen->pid, NULL, &error))
+                                    pty_flags,
+                                    screen->working_directory, argv2, env,
+                                    spawn_flags,
+                                    NULL, NULL,
+                                    &screen->pid, NULL, &error))
         {
           xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (screen))),
                                   error, _("Failed to execute child"));
           g_error_free (error);
         }
+      else
+        {
+          g_object_get (G_OBJECT (screen->preferences),
+                        "misc-bracketed-paste", &enable_bracketed_paste,
+                        NULL);
+          if (enable_bracketed_paste)
+            vte_terminal_feed (VTE_TERMINAL (screen->terminal), bracketed_paste, strlen (bracketed_paste));
+        }
 
       g_free (argv2);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list