80f531b
From c809170f42582f3f02fbcc10e5157ebae9efd0ce Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Wed, 7 Jan 2015 16:01:00 +0100
80f531b
Subject: [PATCH 01/11] Add sequences and signals for desktop notification
Debarshi Ray 7308132
Debarshi Ray 7308132
Add sequences
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ; BODY BEL
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY BEL
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ; BODY ST
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ST
Debarshi Ray 7308132
Debarshi Ray 7308132
that let terminal applications send a notification to the desktop
Debarshi Ray 7308132
environment.
Debarshi Ray 7308132
Debarshi Ray 7308132
Based on Enlightenment's Terminology:
Debarshi Ray 7308132
https://phab.enlightenment.org/T1765
Debarshi Ray 7308132
Debarshi Ray 7308132
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 7308132
---
Debarshi Ray 3069778
 src/marshal.list      |  1 +
Debarshi Ray 2fdd15b
 src/vte.cc            |  8 ++++++++
Debarshi Ray 12738e9
 src/vte/vteterminal.h |  4 +++-
Debarshi Ray 12738e9
 src/vtegtk.cc         | 21 +++++++++++++++++++++
Debarshi Ray 2952472
 src/vtegtk.hh         |  1 +
Debarshi Ray 12738e9
 src/vteinternal.hh    |  8 ++++++++
Debarshi Ray 3a1a7ca
 src/vteseq.cc         | 32 +++++++++++++++++++++++++++++++-
Debarshi Ray 2fdd15b
 7 files changed, 73 insertions(+), 2 deletions(-)
Debarshi Ray 7308132
Debarshi Ray 7308132
diff --git a/src/marshal.list b/src/marshal.list
daec9ca
index 241128c3..4412cf3d 100644
Debarshi Ray 7308132
--- a/src/marshal.list
Debarshi Ray 7308132
+++ b/src/marshal.list
acdaf4f
@@ -1,3 +1,4 @@
9cb9eda
 VOID:STRING,BOXED
Debarshi Ray 7308132
+VOID:STRING,STRING
Debarshi Ray 7308132
 VOID:STRING,UINT
Debarshi Ray 7308132
 VOID:UINT,UINT
Debarshi Ray 3069778
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index 8b75883f..05cc5589 100644
Debarshi Ray 3069778
--- a/src/vte.cc
Debarshi Ray 3069778
+++ b/src/vte.cc
ead1cef
@@ -10032,6 +10032,14 @@ Terminal::emit_pending_signals()
Debarshi Ray 7308132
 
Debarshi Ray 2952472
 	emit_adjustment_changed();
Debarshi Ray 7308132
 
Debarshi Ray 2fdd15b
+        if (m_pending_changes & vte::to_integral(PendingChanges::NOTIFICATION)) {
Debarshi Ray 2952472
+                _vte_debug_print (VTE_DEBUG_SIGNALS,
Debarshi Ray 2952472
+                                  "Emitting `notification-received'.\n");
Debarshi Ray b6699a2
+                g_signal_emit(freezer.get(), signals[SIGNAL_NOTIFICATION_RECEIVED], 0,
Debarshi Ray 12738e9
+                              m_notification_summary.c_str(),
Debarshi Ray 12738e9
+                              m_notification_body.c_str());
Debarshi Ray 355cf28
+        }
Debarshi Ray 7308132
+
Debarshi Ray 2fdd15b
 	if (m_pending_changes & vte::to_integral(PendingChanges::TITLE)) {
Debarshi Ray 12738e9
                 if (m_window_title != m_window_title_pending) {
Debarshi Ray 12738e9
                         m_window_title.swap(m_window_title_pending);
Debarshi Ray 3069778
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
ead1cef
index 41f153d0..1e9a737a 100644
Debarshi Ray 3069778
--- a/src/vte/vteterminal.h
Debarshi Ray 3069778
+++ b/src/vte/vteterminal.h
ead1cef
@@ -108,10 +108,12 @@ struct _VteTerminalClass {
Debarshi Ray 1c815c0
 
Debarshi Ray 3069778
 	void (*bell)(VteTerminal* terminal);
Debarshi Ray 3069778
 
Debarshi Ray 1c815c0
+	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 1c815c0
+
ead1cef
 #if _VTE_GTK == 3
ead1cef
         /* Compatibility padding due to fedora patches intruding on our ABI */
ead1cef
         /*< private >*/
ead1cef
-        gpointer _extra_padding[3];
ead1cef
+        gpointer _extra_padding[2];
ead1cef
 #endif /* _VTE_GTK == 3 */
Debarshi Ray 3069778
 
ead1cef
         /* Add new vfuncs here, and subtract from the padding below. */
Debarshi Ray 2952472
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
ead1cef
index 05b82294..a09a2f75 100644
Debarshi Ray 2952472
--- a/src/vtegtk.cc
Debarshi Ray 2952472
+++ b/src/vtegtk.cc
daec9ca
@@ -1242,6 +1242,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 2952472
 	klass->child_exited = NULL;
Debarshi Ray 2952472
 	klass->encoding_changed = NULL;
Debarshi Ray 2952472
 	klass->char_size_changed = NULL;
Debarshi Ray 2952472
+	klass->notification_received = NULL;
Debarshi Ray 2952472
 	klass->window_title_changed = NULL;
Debarshi Ray 2952472
 	klass->icon_title_changed = NULL;
Debarshi Ray 2952472
 	klass->selection_changed = NULL;
daec9ca
@@ -1325,6 +1326,26 @@ vte_terminal_class_init(VteTerminalClass *klass)
acdaf4f
                                    G_OBJECT_CLASS_TYPE(klass),
acdaf4f
                                    g_cclosure_marshal_VOID__INTv);
Debarshi Ray 2952472
 
Debarshi Ray 7dce419
+        /**
Debarshi Ray 2952472
+         * VteTerminal::notification-received:
Debarshi Ray 2952472
+         * @vteterminal: the object which received the signal
Debarshi Ray 2952472
+         * @summary: The summary
Debarshi Ray 2952472
+         * @body: (allow-none): Extra optional text
Debarshi Ray 2952472
+         *
Debarshi Ray 2952472
+         * Emitted when a process running in the terminal wants to
Debarshi Ray 2952472
+         * send a notification to the desktop environment.
Debarshi Ray 2952472
+         */
Debarshi Ray 2952472
+        signals[SIGNAL_NOTIFICATION_RECEIVED] =
Debarshi Ray 2952472
+                g_signal_new(I_("notification-received"),
Debarshi Ray 2952472
+                             G_OBJECT_CLASS_TYPE(klass),
Debarshi Ray 2952472
+                             G_SIGNAL_RUN_LAST,
Debarshi Ray 2952472
+                             G_STRUCT_OFFSET(VteTerminalClass, notification_received),
Debarshi Ray 2952472
+                             NULL,
Debarshi Ray 2952472
+                             NULL,
Debarshi Ray 2952472
+                             _vte_marshal_VOID__STRING_STRING,
Debarshi Ray 2952472
+                             G_TYPE_NONE,
Debarshi Ray 2952472
+                             2, G_TYPE_STRING, G_TYPE_STRING);
Debarshi Ray 2952472
+
Debarshi Ray 7dce419
         /**
Debarshi Ray 2952472
          * VteTerminal::window-title-changed:
Debarshi Ray 2952472
          * @vteterminal: the object which received the signal
Debarshi Ray 2952472
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
daec9ca
index 6b7a1ea2..8ba10395 100644
Debarshi Ray 2952472
--- a/src/vtegtk.hh
Debarshi Ray 2952472
+++ b/src/vtegtk.hh
daec9ca
@@ -52,6 +52,7 @@ enum {
daec9ca
         SIGNAL_RESIZE_WINDOW,
daec9ca
         SIGNAL_RESTORE_WINDOW,
daec9ca
         SIGNAL_SELECTION_CHANGED,
Debarshi Ray 2952472
+        SIGNAL_NOTIFICATION_RECEIVED,
Debarshi Ray 2952472
         SIGNAL_WINDOW_TITLE_CHANGED,
8f57b4a
         LAST_SIGNAL
8f57b4a
 };
Debarshi Ray 3069778
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
ead1cef
index eb95ad68..69a32276 100644
Debarshi Ray 3069778
--- a/src/vteinternal.hh
Debarshi Ray 3069778
+++ b/src/vteinternal.hh
ead1cef
@@ -660,6 +660,10 @@ public:
Debarshi Ray a9aabb4
         gboolean m_cursor_moved_pending;
Debarshi Ray a9aabb4
         gboolean m_contents_changed_pending;
Debarshi Ray 3069778
 
Debarshi Ray 12738e9
+        /* desktop notification */
Debarshi Ray 12738e9
+        std::string m_notification_summary;
Debarshi Ray 12738e9
+        std::string m_notification_body;
Debarshi Ray 12738e9
+
Debarshi Ray 12738e9
         std::string m_window_title{};
Debarshi Ray 12738e9
         std::string m_current_directory_uri{};
Debarshi Ray 12738e9
         std::string m_current_file_uri{};
ead1cef
@@ -673,6 +677,7 @@ public:
Debarshi Ray 2fdd15b
                 TITLE = 1u << 0,
Debarshi Ray 2fdd15b
                 CWD   = 1u << 1,
Debarshi Ray 2fdd15b
                 CWF   = 1u << 2,
Debarshi Ray 2fdd15b
+                NOTIFICATION = 1u << 3,
Debarshi Ray 2fdd15b
         };
Debarshi Ray 2fdd15b
         unsigned m_pending_changes{0};
Debarshi Ray 2fdd15b
 
daec9ca
@@ -1488,6 +1493,9 @@ public:
Debarshi Ray 12738e9
                              int osc) noexcept;
Debarshi Ray 12738e9
 
Debarshi Ray 12738e9
         /* OSC handlers */
Debarshi Ray 12738e9
+        void handle_urxvt_extension(vte::parser::Sequence const& seq,
Debarshi Ray 12738e9
+                                    vte::parser::StringTokeniser::const_iterator& token,
Debarshi Ray 12738e9
+                                    vte::parser::StringTokeniser::const_iterator const& endtoken) noexcept;
Debarshi Ray 12738e9
         void set_color(vte::parser::Sequence const& seq,
Debarshi Ray 12738e9
                        vte::parser::StringTokeniser::const_iterator& token,
Debarshi Ray 12738e9
                        vte::parser::StringTokeniser::const_iterator const& endtoken,
Debarshi Ray 3069778
diff --git a/src/vteseq.cc b/src/vteseq.cc
ead1cef
index 874d2405..537e8e13 100644
Debarshi Ray 3069778
--- a/src/vteseq.cc
Debarshi Ray 3069778
+++ b/src/vteseq.cc
daec9ca
@@ -1376,6 +1376,33 @@ Terminal::delete_lines(vte::grid::row_t param)
Debarshi Ray 12738e9
         m_text_deleted_flag = TRUE;
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 959a864
+void
Debarshi Ray 270dd15
+Terminal::handle_urxvt_extension(vte::parser::Sequence const& seq,
Debarshi Ray 270dd15
+                                 vte::parser::StringTokeniser::const_iterator& token,
Debarshi Ray 270dd15
+                                 vte::parser::StringTokeniser::const_iterator const& endtoken) noexcept
Debarshi Ray 7308132
+{
Debarshi Ray 3a1a7ca
+        if (token == endtoken)
Debarshi Ray 12738e9
+                return;
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
+        if (*token == "notify") {
Debarshi Ray 12738e9
+                ++token;
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
+                if (token == endtoken)
Debarshi Ray 12738e9
+                        return;
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
+                m_notification_summary = *token;
Debarshi Ray 12738e9
+                m_notification_body.clear();
Debarshi Ray 2fdd15b
+                m_pending_changes |= vte::to_integral(PendingChanges::NOTIFICATION);
Debarshi Ray 12738e9
+                ++token;
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
+                if (token == endtoken)
Debarshi Ray 12738e9
+                        return;
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
+                m_notification_body = *token;
Debarshi Ray 12738e9
+                return;
Debarshi Ray 12738e9
+        }
Debarshi Ray 7308132
+}
Debarshi Ray 7308132
+
Debarshi Ray 12738e9
 bool
Debarshi Ray 270dd15
 Terminal::get_osc_color_index(int osc,
Debarshi Ray 12738e9
                                         int value,
ead1cef
@@ -6541,6 +6568,10 @@ Terminal::OSC(vte::parser::Sequence const& seq)
Debarshi Ray 12738e9
                 reset_color(VTE_HIGHLIGHT_FG, VTE_COLOR_SOURCE_ESCAPE);
Debarshi Ray 12738e9
                 break;
Debarshi Ray 12738e9
 
Debarshi Ray 12738e9
+        case VTE_OSC_URXVT_EXTENSION:
Debarshi Ray 12738e9
+                handle_urxvt_extension(seq, it, cend);
Debarshi Ray 12738e9
+                break;
Debarshi Ray 12738e9
+
Debarshi Ray 12738e9
         case VTE_OSC_XTERM_SET_ICON_TITLE:
Debarshi Ray 12738e9
         case VTE_OSC_XTERM_SET_XPROPERTY:
Debarshi Ray 12738e9
         case VTE_OSC_XTERM_SET_COLOR_MOUSE_CURSOR_FG:
ead1cef
@@ -6582,7 +6613,6 @@ Terminal::OSC(vte::parser::Sequence const& seq)
Debarshi Ray 12738e9
         case VTE_OSC_URXVT_SET_FONT_BOLD_ITALIC:
Debarshi Ray 12738e9
         case VTE_OSC_URXVT_VIEW_UP:
Debarshi Ray 12738e9
         case VTE_OSC_URXVT_VIEW_DOWN:
Debarshi Ray 12738e9
-        case VTE_OSC_URXVT_EXTENSION:
Debarshi Ray 12738e9
         case VTE_OSC_YF_RQGWR:
Debarshi Ray 12738e9
         default:
Debarshi Ray 12738e9
                 break;
Debarshi Ray 7308132
-- 
ead1cef
2.35.1
Debarshi Ray 7308132
Debarshi Ray 7308132
80f531b
From 05a642746f1c3985ea204571e0179a1147dda1a9 Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Thu, 29 Jan 2015 13:09:17 +0100
80f531b
Subject: [PATCH 02/11] vte.sh: Emit OSC 777 from PROMPT_COMMAND
Debarshi Ray 7308132
Debarshi Ray 94ec580
For some reason, the three consecutive backslashes break the parsing.
Debarshi Ray 94ec580
As Christian Persch suggested, replacing the double quotes with
Debarshi Ray 94ec580
singles fixes it.
Debarshi Ray 94ec580
Debarshi Ray 7308132
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 7308132
---
Debarshi Ray 22ab67e
 src/vte.sh.in | 4 +++-
Debarshi Ray 7308132
 1 file changed, 3 insertions(+), 1 deletion(-)
Debarshi Ray 7308132
Debarshi Ray 22ab67e
diff --git a/src/vte.sh.in b/src/vte.sh.in
daec9ca
index 242d6c42..50242223 100644
Debarshi Ray 22ab67e
--- a/src/vte.sh.in
Debarshi Ray 22ab67e
+++ b/src/vte.sh.in
daec9ca
@@ -33,10 +33,12 @@ __vte_osc7 () {
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
 __vte_prompt_command() {
Debarshi Ray 7308132
+  local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//')
Debarshi Ray 7308132
+  command="${command//;/ }"
Debarshi Ray 7308132
   local pwd='~'
Debarshi Ray 7308132
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
acdaf4f
   pwd="${pwd//[[:cntrl:]]}"
Debarshi Ray 22ab67e
-  printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
Debarshi Ray 22ab67e
+  printf '\033]777;notify;Command completed;%s\033\\\033]0;%s@%s:%s\033\\' "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
Debarshi Ray 22ab67e
   __vte_osc7
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
-- 
ead1cef
2.35.1
Debarshi Ray 7308132
Debarshi Ray 7308132
80f531b
From d0cca4421d0108b0f9e23ea03ea5e99f745646a6 Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Thu, 22 Jan 2015 16:37:10 +0100
80f531b
Subject: [PATCH 03/11] Test the notification-received signal
Debarshi Ray 7308132
Debarshi Ray 7308132
---
Debarshi Ray acefea5
 bindings/vala/app.vala |  7 +++++++
Debarshi Ray 959a864
 src/app/app.cc         | 10 ++++++++++
Debarshi Ray acefea5
 2 files changed, 17 insertions(+)
Debarshi Ray 7308132
Debarshi Ray d2ede39
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
ead1cef
index 4bcb5804..06546440 100644
Debarshi Ray d2ede39
--- a/bindings/vala/app.vala
Debarshi Ray d2ede39
+++ b/bindings/vala/app.vala
Debarshi Ray 1c815c0
@@ -309,6 +309,8 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 355cf28
     if (Options.object_notifications)
Debarshi Ray 7308132
       terminal.notify.connect(notify_cb);
Debarshi Ray 7308132
 
Debarshi Ray 7308132
+    terminal.notification_received.connect(notification_received_cb);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
     /* Settings */
Debarshi Ray 355cf28
     if (Options.no_double_buffer)
Debarshi Ray 8639850
       terminal.set_double_buffered(false);
9cb9eda
@@ -780,6 +782,11 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 7308132
     set_title(terminal.get_window_title());
Debarshi Ray 7308132
   }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
+  private void notification_received_cb(Vte.Terminal terminal, string summary, string? body)
Debarshi Ray 7308132
+  {
Debarshi Ray 7308132
+    print ("[%s]: %s\n", summary, body);
Debarshi Ray 7308132
+  }
Debarshi Ray 7308132
+
Debarshi Ray 7308132
 } /* class Window */
Debarshi Ray 7308132
 
Debarshi Ray 7308132
 class App : Gtk.Application
Debarshi Ray 959a864
diff --git a/src/app/app.cc b/src/app/app.cc
ead1cef
index 3b7835aa..fc8220a5 100644
Debarshi Ray 959a864
--- a/src/app/app.cc
Debarshi Ray 959a864
+++ b/src/app/app.cc
ead1cef
@@ -2209,6 +2209,14 @@ window_window_title_changed_cb(VteTerminal* terminal,
77371af
         gtk_window_set_title(GTK_WINDOW(window), title && title[0] ? title : "Terminal");
Debarshi Ray 959a864
 }
Debarshi Ray acefea5
 
Debarshi Ray 7dce419
+static void
Debarshi Ray 959a864
+notification_received_cb(VteTerminal *terminal,
Debarshi Ray 959a864
+                         const gchar *summary,
Debarshi Ray 959a864
+                         const gchar *body)
Debarshi Ray acefea5
+{
Debarshi Ray 959a864
+        g_print("[%s]: %s\n", summary, body);
Debarshi Ray acefea5
+}
Debarshi Ray acefea5
+
Debarshi Ray 7dce419
 static void
Debarshi Ray 959a864
 window_lower_window_cb(VteTerminal* terminal,
Debarshi Ray 959a864
                        VteappWindow* window)
ead1cef
@@ -2505,6 +2513,8 @@ vteapp_window_constructed(GObject *object)
Debarshi Ray 959a864
         if (options.object_notifications)
Debarshi Ray 959a864
                 g_signal_connect(window->terminal, "notify", G_CALLBACK(window_notify_cb), window);
Debarshi Ray acefea5
 
Debarshi Ray 959a864
+        g_signal_connect(window->terminal, "notification-received", G_CALLBACK(notification_received_cb), NULL);
Debarshi Ray acefea5
+
Debarshi Ray 959a864
         /* Settings */
daec9ca
 #if VTE_GTK == 3
Debarshi Ray 511ade8
         if (options.no_double_buffer) {
Debarshi Ray 7308132
-- 
ead1cef
2.35.1
Debarshi Ray 525ec1b
Debarshi Ray 525ec1b
80f531b
From e87bc628fdecf7480c12b861ba3fb98b03abe4d9 Mon Sep 17 00:00:00 2001
Debarshi Ray 955c24e
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray f1ae7f9
Date: Fri, 13 May 2016 17:53:54 +0200
80f531b
Subject: [PATCH 04/11] Add a property to configure the scroll speed
Debarshi Ray 955c24e
Debarshi Ray f1ae7f9
By default, it is set to zero which gives the current behaviour of
Debarshi Ray f1ae7f9
moving the buffer by a function of the number of visible rows.
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
Debarshi Ray 955c24e
---
daec9ca
 doc/reference/vte-sections.txt.in |  1 +
daec9ca
 src/vte.cc                        | 19 +++++++++++-
daec9ca
 src/vte/vteterminal.h             |  4 +++
daec9ca
 src/vtegtk.cc                     | 51 +++++++++++++++++++++++++++++++
daec9ca
 src/vtegtk.hh                     |  1 +
daec9ca
 src/vteinternal.hh                |  2 ++
Debarshi Ray fb1f5bc
 6 files changed, 77 insertions(+), 1 deletion(-)
Debarshi Ray 955c24e
daec9ca
diff --git a/doc/reference/vte-sections.txt.in b/doc/reference/vte-sections.txt.in
ead1cef
index 283dd056..64907389 100644
daec9ca
--- a/doc/reference/vte-sections.txt.in
daec9ca
+++ b/doc/reference/vte-sections.txt.in
ead1cef
@@ -58,6 +58,7 @@ vte_terminal_get_cursor_blink_mode
Debarshi Ray f1ae7f9
 vte_terminal_set_cursor_blink_mode
Debarshi Ray 959a864
 vte_terminal_get_text_blink_mode
Debarshi Ray 959a864
 vte_terminal_set_text_blink_mode
Debarshi Ray f1ae7f9
+vte_terminal_set_scroll_speed
Debarshi Ray f1ae7f9
 vte_terminal_set_scrollback_lines
Debarshi Ray 959a864
 vte_terminal_get_scrollback_lines
Debarshi Ray f1ae7f9
 vte_terminal_set_font
Debarshi Ray f1ae7f9
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index 05cc5589..a4e6069d 100644
Debarshi Ray f1ae7f9
--- a/src/vte.cc
Debarshi Ray f1ae7f9
+++ b/src/vte.cc
ead1cef
@@ -9239,6 +9239,7 @@ vte_cairo_get_clip_region(cairo_t *cr)
Debarshi Ray b6699a2
 bool
Debarshi Ray 2fdd15b
 Terminal::widget_mouse_scroll(vte::platform::ScrollEvent const& event)
Debarshi Ray f1ae7f9
 {
Debarshi Ray f1ae7f9
+	gdouble scroll_speed;
Debarshi Ray f1ae7f9
 	gdouble v;
Debarshi Ray f1ae7f9
 	gint cnt, i;
Debarshi Ray f1ae7f9
 	int button;
ead1cef
@@ -9273,7 +9274,13 @@ Terminal::widget_mouse_scroll(vte::platform::ScrollEvent const& event)
Debarshi Ray b6699a2
 		return true;
Debarshi Ray f1ae7f9
 	}
Debarshi Ray f1ae7f9
 
daec9ca
-        v = MAX (1., ceil (m_row_count /* page increment */ / 10.));
Debarshi Ray f1ae7f9
+	if (m_scroll_speed == 0) {
daec9ca
+		scroll_speed = ceil (m_row_count /* page increment */ / 10.);
Debarshi Ray f1ae7f9
+	} else {
Debarshi Ray f1ae7f9
+		scroll_speed = m_scroll_speed;
Debarshi Ray f1ae7f9
+	}
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+	v = MAX (1., scroll_speed);
Debarshi Ray f1ae7f9
 	_vte_debug_print(VTE_DEBUG_EVENTS,
Debarshi Ray f1ae7f9
 			"Scroll speed is %d lines per non-smooth scroll unit\n",
Debarshi Ray f1ae7f9
 			(int) v);
ead1cef
@@ -9583,6 +9590,16 @@ Terminal::decscusr_cursor_shape() const noexcept
Debarshi Ray 7dce419
         }
Debarshi Ray f1ae7f9
 }
Debarshi Ray f1ae7f9
 
Debarshi Ray 7dce419
+bool
Debarshi Ray 270dd15
+Terminal::set_scroll_speed(unsigned int scroll_speed)
Debarshi Ray f1ae7f9
+{
Debarshi Ray f1ae7f9
+        if (scroll_speed == m_scroll_speed)
Debarshi Ray f1ae7f9
+                return false;
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        m_scroll_speed = scroll_speed;
Debarshi Ray f1ae7f9
+        return true;
Debarshi Ray f1ae7f9
+}
Debarshi Ray f1ae7f9
+
Debarshi Ray 7dce419
 bool
Debarshi Ray 270dd15
 Terminal::set_scrollback_lines(long lines)
Debarshi Ray f1ae7f9
 {
Debarshi Ray 955c24e
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
ead1cef
index 1e9a737a..b63967a3 100644
Debarshi Ray 955c24e
--- a/src/vte/vteterminal.h
Debarshi Ray 955c24e
+++ b/src/vte/vteterminal.h
ead1cef
@@ -330,6 +330,10 @@ void vte_terminal_set_cursor_shape(VteTerminal *terminal,
Debarshi Ray f1ae7f9
 _VTE_PUBLIC
Debarshi Ray b6699a2
 VteCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 955c24e
 
Debarshi Ray f1ae7f9
+_VTE_PUBLIC
Debarshi Ray f1ae7f9
+void vte_terminal_set_scroll_speed(VteTerminal *terminal,
Debarshi Ray fb1f5bc
+                                   guint scroll_speed) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
 /* Set the number of scrollback lines, above or at an internal minimum. */
Debarshi Ray f1ae7f9
 _VTE_PUBLIC
Debarshi Ray f1ae7f9
 void vte_terminal_set_scrollback_lines(VteTerminal *terminal,
Debarshi Ray f1ae7f9
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
ead1cef
index a09a2f75..ab1de923 100644
Debarshi Ray f1ae7f9
--- a/src/vtegtk.cc
Debarshi Ray f1ae7f9
+++ b/src/vtegtk.cc
daec9ca
@@ -993,6 +993,9 @@ try
Debarshi Ray f1ae7f9
                 case PROP_REWRAP_ON_RESIZE:
Debarshi Ray f1ae7f9
                         g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
Debarshi Ray f1ae7f9
                         break;
Debarshi Ray f1ae7f9
+                case PROP_SCROLL_SPEED:
Debarshi Ray f1ae7f9
+                        g_value_set_uint (value, impl->m_scroll_speed);
Debarshi Ray f1ae7f9
+                        break;
Debarshi Ray f1ae7f9
                 case PROP_SCROLLBACK_LINES:
Debarshi Ray 959a864
                         g_value_set_uint (value, vte_terminal_get_scrollback_lines(terminal));
Debarshi Ray f1ae7f9
                         break;
daec9ca
@@ -1114,6 +1117,9 @@ try
Debarshi Ray f1ae7f9
                 case PROP_REWRAP_ON_RESIZE:
Debarshi Ray f1ae7f9
                         vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
Debarshi Ray f1ae7f9
                         break;
Debarshi Ray f1ae7f9
+                case PROP_SCROLL_SPEED:
Debarshi Ray f1ae7f9
+                        vte_terminal_set_scroll_speed (terminal, g_value_get_uint (value));
Debarshi Ray f1ae7f9
+                        break;
Debarshi Ray f1ae7f9
                 case PROP_SCROLLBACK_LINES:
Debarshi Ray f1ae7f9
                         vte_terminal_set_scrollback_lines (terminal, g_value_get_uint (value));
Debarshi Ray f1ae7f9
                         break;
daec9ca
@@ -2210,6 +2216,21 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 7dce419
                                       TRUE,
Debarshi Ray f1ae7f9
                                       (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 955c24e
 
Debarshi Ray 7dce419
+        /**
Debarshi Ray f1ae7f9
+         * VteTerminal:scroll-speed:
Debarshi Ray f1ae7f9
+         *
Debarshi Ray f1ae7f9
+         * The number of lines by which the buffer is moved when
Debarshi Ray f1ae7f9
+         * scrolling with a mouse wheel on top of the terminal
Debarshi Ray f1ae7f9
+         * Setting it to zero will cause the buffer to be moved by an
Debarshi Ray f1ae7f9
+         * amount depending on the number of visible rows the widget
Debarshi Ray f1ae7f9
+         * can display.
Debarshi Ray f1ae7f9
+         */
Debarshi Ray f1ae7f9
+        pspecs[PROP_SCROLL_SPEED] =
Debarshi Ray f1ae7f9
+                g_param_spec_uint ("scroll-speed", NULL, NULL,
Debarshi Ray f1ae7f9
+                                   0, G_MAXUINT,
Debarshi Ray f1ae7f9
+                                   0,
Debarshi Ray f1ae7f9
+                                   (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 955c24e
+
Debarshi Ray 7dce419
         /**
Debarshi Ray f1ae7f9
          * VteTerminal:scrollback-lines:
Debarshi Ray f1ae7f9
          *
ead1cef
@@ -5726,6 +5747,36 @@ catch (...)
Debarshi Ray b6699a2
         return -1;
Debarshi Ray f1ae7f9
 }
Debarshi Ray f1ae7f9
 
Debarshi Ray 7dce419
+/**
Debarshi Ray f1ae7f9
+ * vte_terminal_set_scroll_speed:
Debarshi Ray f1ae7f9
+ * @terminal: a #VteTerminal
Debarshi Ray f1ae7f9
+ * @scroll_speed: move the buffer by this number of lines while scrolling
Debarshi Ray f1ae7f9
+ *
Debarshi Ray f1ae7f9
+ * Sets the number of lines by which the buffer is moved when
Debarshi Ray f1ae7f9
+ * scrolling with a mouse wheel. Setting it to zero will cause the
Debarshi Ray f1ae7f9
+ * buffer to be moved by an amount depending on the number of visible
Debarshi Ray f1ae7f9
+ * rows the widget can display.
Debarshi Ray f1ae7f9
+ */
Debarshi Ray f1ae7f9
+void
Debarshi Ray fb1f5bc
+vte_terminal_set_scroll_speed(VteTerminal *terminal,
Debarshi Ray fb1f5bc
+                              guint scroll_speed) noexcept
Debarshi Ray fb1f5bc
+try
Debarshi Ray f1ae7f9
+{
Debarshi Ray f1ae7f9
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        GObject *object = G_OBJECT(terminal);
Debarshi Ray f1ae7f9
+        g_object_freeze_notify(object);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        if (IMPL(terminal)->set_scroll_speed(scroll_speed))
Debarshi Ray f1ae7f9
+                g_object_notify_by_pspec(object, pspecs[PROP_SCROLL_SPEED]);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        g_object_thaw_notify(object);
Debarshi Ray f1ae7f9
+}
Debarshi Ray fb1f5bc
+catch (...)
Debarshi Ray fb1f5bc
+{
Debarshi Ray fb1f5bc
+        vte::log_exception();
Debarshi Ray fb1f5bc
+}
Debarshi Ray f1ae7f9
+
Debarshi Ray 7dce419
 /**
Debarshi Ray f1ae7f9
  * vte_terminal_set_scrollback_lines:
Debarshi Ray f1ae7f9
  * @terminal: a #VteTerminal
Debarshi Ray f1ae7f9
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
daec9ca
index 8ba10395..f6cd891b 100644
Debarshi Ray f1ae7f9
--- a/src/vtegtk.hh
Debarshi Ray f1ae7f9
+++ b/src/vtegtk.hh
daec9ca
@@ -86,6 +86,7 @@ enum {
Debarshi Ray f1ae7f9
         PROP_MOUSE_POINTER_AUTOHIDE,
Debarshi Ray f1ae7f9
         PROP_PTY,
Debarshi Ray f1ae7f9
         PROP_REWRAP_ON_RESIZE,
Debarshi Ray f1ae7f9
+        PROP_SCROLL_SPEED,
Debarshi Ray f1ae7f9
         PROP_SCROLLBACK_LINES,
Debarshi Ray f1ae7f9
         PROP_SCROLL_ON_KEYSTROKE,
Debarshi Ray f1ae7f9
         PROP_SCROLL_ON_OUTPUT,
Debarshi Ray f1ae7f9
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
ead1cef
index 69a32276..d3e25179 100644
Debarshi Ray f1ae7f9
--- a/src/vteinternal.hh
Debarshi Ray f1ae7f9
+++ b/src/vteinternal.hh
ead1cef
@@ -426,6 +426,7 @@ public:
Debarshi Ray 2fdd15b
         bool m_fallback_scrolling{true};
Debarshi Ray 22ab67e
         bool m_scroll_on_output{false};
Debarshi Ray 22ab67e
         bool m_scroll_on_keystroke{true};
Debarshi Ray f1ae7f9
+        guint m_scroll_speed;
Debarshi Ray 22ab67e
         vte::grid::row_t m_scrollback_lines{0};
Debarshi Ray f1ae7f9
 
daec9ca
         inline auto scroll_limit_lower() const noexcept
daec9ca
@@ -1363,6 +1364,7 @@ public:
Debarshi Ray 22ab67e
         bool set_input_enabled(bool enabled);
Debarshi Ray 22ab67e
         bool set_mouse_autohide(bool autohide);
Debarshi Ray f1ae7f9
         bool set_rewrap_on_resize(bool rewrap);
Debarshi Ray f1ae7f9
+        bool set_scroll_speed(unsigned int scroll_speed);
Debarshi Ray f1ae7f9
         bool set_scrollback_lines(long lines);
Debarshi Ray 2fdd15b
         bool set_fallback_scrolling(bool set);
Debarshi Ray 2fdd15b
         auto fallback_scrolling() const noexcept { return m_fallback_scrolling; }
Debarshi Ray f1ae7f9
-- 
ead1cef
2.35.1
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
80f531b
From f8a8d2adf1000720f269adb80473e8971bc51135 Mon Sep 17 00:00:00 2001
Debarshi Ray f1ae7f9
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray f1ae7f9
Date: Fri, 13 May 2016 17:54:57 +0200
80f531b
Subject: [PATCH 05/11] Test the scroll-speed property
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
Debarshi Ray f1ae7f9
---
Debarshi Ray d2ede39
 bindings/vala/app.vala | 4 ++++
Debarshi Ray 959a864
 src/app/app.cc         | 4 ++++
Debarshi Ray 959a864
 2 files changed, 8 insertions(+)
Debarshi Ray f1ae7f9
Debarshi Ray d2ede39
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
ead1cef
index 06546440..552a702d 100644
Debarshi Ray d2ede39
--- a/bindings/vala/app.vala
Debarshi Ray d2ede39
+++ b/bindings/vala/app.vala
9cb9eda
@@ -335,6 +335,7 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 355cf28
     terminal.set_rewrap_on_resize(!Options.no_rewrap);
Debarshi Ray f1ae7f9
     terminal.set_scroll_on_output(false);
Debarshi Ray f1ae7f9
     terminal.set_scroll_on_keystroke(true);
Debarshi Ray 355cf28
+    terminal.set_scroll_speed(Options.scroll_speed);
Debarshi Ray 355cf28
     terminal.set_scrollback_lines(Options.scrollback_lines);
Debarshi Ray 955c24e
 
Debarshi Ray f1ae7f9
     /* Style */
Debarshi Ray 355cf28
@@ -857,6 +858,7 @@ class App : Gtk.Application
Debarshi Ray f1ae7f9
     public static bool object_notifications = false;
Debarshi Ray f1ae7f9
     public static string? output_filename = null;
Debarshi Ray f1ae7f9
     public static bool reverse = false;
Debarshi Ray f1ae7f9
+    public static uint scroll_speed = 0;
Debarshi Ray f1ae7f9
     public static int scrollback_lines = 512;
Debarshi Ray f1ae7f9
     public static int transparency_percent = 0;
Debarshi Ray f1ae7f9
     public static bool version = false;
Debarshi Ray 355cf28
@@ -1050,6 +1052,8 @@ class App : Gtk.Application
Debarshi Ray f1ae7f9
         "Save terminal contents to file at exit", null },
Debarshi Ray f1ae7f9
       { "reverse", 0, 0, OptionArg.NONE, ref reverse,
Debarshi Ray f1ae7f9
         "Reverse foreground/background colors", null },
Debarshi Ray 1c815c0
+      { "scroll-speed", 0, 0, OptionArg.INT, ref scroll_speed,
Debarshi Ray f1ae7f9
+        "Specify the scroll speed", null },
Debarshi Ray f1ae7f9
       { "scrollback-lines", 'n', 0, OptionArg.INT, ref scrollback_lines,
Debarshi Ray f1ae7f9
         "Specify the number of scrollback-lines", null },
Debarshi Ray f1ae7f9
       { "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
Debarshi Ray 959a864
diff --git a/src/app/app.cc b/src/app/app.cc
ead1cef
index fc8220a5..c6f5cc0b 100644
Debarshi Ray 959a864
--- a/src/app/app.cc
Debarshi Ray 959a864
+++ b/src/app/app.cc
ead1cef
@@ -118,6 +118,7 @@ public:
Debarshi Ray 959a864
         int verbosity{0};
Debarshi Ray 959a864
         double cell_height_scale{1.0};
Debarshi Ray 959a864
         double cell_width_scale{1.0};
Debarshi Ray 959a864
+        unsigned int scroll_speed{0};
Debarshi Ray 959a864
         VteCursorBlinkMode cursor_blink_mode{VTE_CURSOR_BLINK_SYSTEM};
Debarshi Ray 959a864
         VteCursorShape cursor_shape{VTE_CURSOR_SHAPE_BLOCK};
Debarshi Ray 959a864
         VteTextBlinkMode text_blink_mode{VTE_TEXT_BLINK_ALWAYS};
ead1cef
@@ -620,6 +621,8 @@ public:
Debarshi Ray 959a864
                           "Reverse foreground/background colors", nullptr },
Debarshi Ray 22ab67e
                         { "require-systemd-scope", 0, 0, G_OPTION_ARG_NONE, &require_systemd_scope,
Debarshi Ray 22ab67e
                           "Require use of a systemd user scope", nullptr },
Debarshi Ray 959a864
+                        { "scroll-speed", 0, 0, G_OPTION_ARG_INT, &scroll_speed,
Debarshi Ray 959a864
+                          "Specify the scroll speed", nullptr },
daec9ca
                         { "scroll-unit-is-pixels", 0, 0, G_OPTION_ARG_NONE, &scroll_unit_is_pixels,
daec9ca
                           "Use pixels as scroll unit", nullptr },
Debarshi Ray 959a864
                         { "scrollback-lines", 'n', 0, G_OPTION_ARG_INT, &scrollback_lines,
ead1cef
@@ -2549,6 +2552,7 @@ vteapp_window_constructed(GObject *object)
Debarshi Ray 959a864
         vte_terminal_set_rewrap_on_resize(window->terminal, !options.no_rewrap);
Debarshi Ray 959a864
         vte_terminal_set_scroll_on_output(window->terminal, false);
Debarshi Ray 959a864
         vte_terminal_set_scroll_on_keystroke(window->terminal, true);
Debarshi Ray 959a864
+        vte_terminal_set_scroll_speed(window->terminal, options.scroll_speed);
daec9ca
         vte_terminal_set_scroll_unit_is_pixels(window->terminal, options.scroll_unit_is_pixels);
Debarshi Ray 959a864
         vte_terminal_set_scrollback_lines(window->terminal, options.scrollback_lines);
Debarshi Ray 959a864
         vte_terminal_set_text_blink_mode(window->terminal, options.text_blink_mode);
Debarshi Ray 955c24e
-- 
ead1cef
2.35.1
Debarshi Ray 53d075d
Debarshi Ray 53d075d
80f531b
From 60d5670e793d2aa2ccda489e4e468bbc9c120908 Mon Sep 17 00:00:00 2001
Debarshi Ray 53d075d
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 53d075d
Date: Wed, 7 Jan 2015 16:01:00 +0100
80f531b
Subject: [PATCH 06/11] Support preexec notifications from an interactive shell
Debarshi Ray 53d075d
Debarshi Ray 53d075d
Add sequences
Debarshi Ray 53d075d
  OSC 777 ; preexec BEL
Debarshi Ray 53d075d
  OSC 777 ; preexec ST
Debarshi Ray 53d075d
Debarshi Ray 53d075d
that can be used from an interactive shell's preexec hook to notify
Debarshi Ray 53d075d
the terminal emulator that a new command is about to be executed.
Debarshi Ray 53d075d
Examples of such hooks are Bash's PS0 and Zsh's preexec.
Debarshi Ray 53d075d
Debarshi Ray 53d075d
The OSC 777 escape sequence is taken from Enlightenment's Terminology:
Debarshi Ray 53d075d
https://phab.enlightenment.org/T1765
Debarshi Ray 53d075d
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711060
Debarshi Ray 53d075d
---
Debarshi Ray 2fdd15b
 src/vte.cc            |  6 ++++++
daec9ca
 src/vte.sh.in         |  4 ++--
Debarshi Ray 53d075d
 src/vte/vteterminal.h |  3 ++-
Debarshi Ray 53d075d
 src/vtegtk.cc         | 18 ++++++++++++++++++
Debarshi Ray 53d075d
 src/vtegtk.hh         |  1 +
Debarshi Ray 2fdd15b
 src/vteinternal.hh    |  1 +
Debarshi Ray 53d075d
 src/vteseq.cc         |  4 ++++
daec9ca
 7 files changed, 34 insertions(+), 3 deletions(-)
Debarshi Ray 53d075d
Debarshi Ray 53d075d
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index a4e6069d..6d8ab2bb 100644
Debarshi Ray 53d075d
--- a/src/vte.cc
Debarshi Ray 53d075d
+++ b/src/vte.cc
ead1cef
@@ -10057,6 +10057,12 @@ Terminal::emit_pending_signals()
Debarshi Ray 2fdd15b
                               m_notification_body.c_str());
Debarshi Ray 355cf28
         }
Debarshi Ray 53d075d
 
Debarshi Ray 2fdd15b
+        if (m_pending_changes & vte::to_integral(PendingChanges::SHELL_PREEXEC)) {
Debarshi Ray 53d075d
+                _vte_debug_print (VTE_DEBUG_SIGNALS,
Debarshi Ray 53d075d
+                                  "Emitting `shell-preexec'.\n");
Debarshi Ray b6699a2
+                g_signal_emit(freezer.get(), signals[SIGNAL_SHELL_PREEXEC], 0);
Debarshi Ray 53d075d
+        }
Debarshi Ray 53d075d
+
Debarshi Ray 2fdd15b
 	if (m_pending_changes & vte::to_integral(PendingChanges::TITLE)) {
Debarshi Ray 53d075d
                 if (m_window_title != m_window_title_pending) {
Debarshi Ray 53d075d
                         m_window_title.swap(m_window_title_pending);
Debarshi Ray 22ab67e
diff --git a/src/vte.sh.in b/src/vte.sh.in
daec9ca
index 50242223..01b44e23 100644
Debarshi Ray 22ab67e
--- a/src/vte.sh.in
Debarshi Ray 22ab67e
+++ b/src/vte.sh.in
daec9ca
@@ -51,9 +51,9 @@ if [[ -n "${BASH_VERSION:-}" ]]; then
daec9ca
     # use the __vte_prompt_command function which also sets the title.
daec9ca
 
daec9ca
     if [[ "$(declare -p PROMPT_COMMAND 2>&1)" =~ "declare -a" ]]; then
daec9ca
-	PROMPT_COMMAND+=(__vte_osc7)
daec9ca
+	PROMPT_COMMAND+=(__vte_osc7) && PS0=$(printf "\033]777;preexec\033\\")
daec9ca
     else
daec9ca
-	PROMPT_COMMAND="__vte_prompt_command"
daec9ca
+	PROMPT_COMMAND="__vte_prompt_command" && PS0=$(printf "\033]777;preexec\033\\")
daec9ca
     fi
daec9ca
 
daec9ca
 elif [[ -n "${ZSH_VERSION:-}" ]]; then
Debarshi Ray 53d075d
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
ead1cef
index b63967a3..062b6694 100644
Debarshi Ray 53d075d
--- a/src/vte/vteterminal.h
Debarshi Ray 53d075d
+++ b/src/vte/vteterminal.h
ead1cef
@@ -109,11 +109,12 @@ struct _VteTerminalClass {
Debarshi Ray 53d075d
 	void (*bell)(VteTerminal* terminal);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
 	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 53d075d
+	void (*shell_preexec)(VteTerminal* terminal);
Debarshi Ray 53d075d
 
ead1cef
 #if _VTE_GTK == 3
ead1cef
         /* Compatibility padding due to fedora patches intruding on our ABI */
ead1cef
         /*< private >*/
ead1cef
-        gpointer _extra_padding[2];
ead1cef
+        gpointer _extra_padding[1];
ead1cef
 #endif /* _VTE_GTK == 3 */
Debarshi Ray 53d075d
 
ead1cef
         /* Add new vfuncs here, and subtract from the padding below. */
Debarshi Ray 53d075d
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
ead1cef
index ab1de923..a4d51bfb 100644
Debarshi Ray 53d075d
--- a/src/vtegtk.cc
Debarshi Ray 53d075d
+++ b/src/vtegtk.cc
daec9ca
@@ -1249,6 +1249,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 53d075d
 	klass->encoding_changed = NULL;
Debarshi Ray 53d075d
 	klass->char_size_changed = NULL;
Debarshi Ray 53d075d
 	klass->notification_received = NULL;
Debarshi Ray 53d075d
+	klass->shell_preexec = NULL;
Debarshi Ray 53d075d
 	klass->window_title_changed = NULL;
Debarshi Ray 53d075d
 	klass->icon_title_changed = NULL;
Debarshi Ray 53d075d
 	klass->selection_changed = NULL;
daec9ca
@@ -1352,6 +1353,23 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 53d075d
                              G_TYPE_NONE,
Debarshi Ray 53d075d
                              2, G_TYPE_STRING, G_TYPE_STRING);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+        /**
Debarshi Ray 53d075d
+         * VteTerminal::shell-preexec:
Debarshi Ray 53d075d
+         * @vteterminal: the object which received the signal
Debarshi Ray 53d075d
+         *
Debarshi Ray 53d075d
+         * Emitted when the interactive shell has read in a complete
Debarshi Ray 53d075d
+         * command and is about to execute it.
Debarshi Ray 53d075d
+         */
Debarshi Ray 53d075d
+        signals[SIGNAL_SHELL_PREEXEC] =
Debarshi Ray 53d075d
+                g_signal_new(I_("shell-preexec"),
Debarshi Ray 53d075d
+                             G_OBJECT_CLASS_TYPE(klass),
Debarshi Ray 53d075d
+                             G_SIGNAL_RUN_LAST,
Debarshi Ray 53d075d
+                             G_STRUCT_OFFSET(VteTerminalClass, shell_preexec),
Debarshi Ray 53d075d
+                             NULL,
Debarshi Ray 53d075d
+                             NULL,
Debarshi Ray 53d075d
+                             g_cclosure_marshal_VOID__VOID,
Debarshi Ray 53d075d
+                             G_TYPE_NONE, 0);
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
         /**
Debarshi Ray 53d075d
          * VteTerminal::window-title-changed:
Debarshi Ray 53d075d
          * @vteterminal: the object which received the signal
Debarshi Ray 53d075d
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
daec9ca
index f6cd891b..bf85bdf4 100644
Debarshi Ray 53d075d
--- a/src/vtegtk.hh
Debarshi Ray 53d075d
+++ b/src/vtegtk.hh
Debarshi Ray 53d075d
@@ -52,6 +52,7 @@ enum {
Debarshi Ray 53d075d
         SIGNAL_RESIZE_WINDOW,
Debarshi Ray 53d075d
         SIGNAL_RESTORE_WINDOW,
Debarshi Ray 53d075d
         SIGNAL_SELECTION_CHANGED,
Debarshi Ray 53d075d
+        SIGNAL_SHELL_PREEXEC,
daec9ca
         SIGNAL_NOTIFICATION_RECEIVED,
daec9ca
         SIGNAL_WINDOW_TITLE_CHANGED,
daec9ca
         LAST_SIGNAL
Debarshi Ray 53d075d
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
ead1cef
index d3e25179..b4f1b4c9 100644
Debarshi Ray 53d075d
--- a/src/vteinternal.hh
Debarshi Ray 53d075d
+++ b/src/vteinternal.hh
ead1cef
@@ -679,6 +679,7 @@ public:
Debarshi Ray 2fdd15b
                 CWD   = 1u << 1,
Debarshi Ray 2fdd15b
                 CWF   = 1u << 2,
Debarshi Ray 2fdd15b
                 NOTIFICATION = 1u << 3,
Debarshi Ray 2fdd15b
+                SHELL_PREEXEC = 1u << 4,
Debarshi Ray 2fdd15b
         };
Debarshi Ray 2fdd15b
         unsigned m_pending_changes{0};
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
diff --git a/src/vteseq.cc b/src/vteseq.cc
ead1cef
index 537e8e13..dbc6276f 100644
Debarshi Ray 53d075d
--- a/src/vteseq.cc
Debarshi Ray 53d075d
+++ b/src/vteseq.cc
daec9ca
@@ -1401,6 +1401,10 @@ Terminal::handle_urxvt_extension(vte::parser::Sequence const& seq,
Debarshi Ray 53d075d
                 m_notification_body = *token;
Debarshi Ray 53d075d
                 return;
Debarshi Ray 53d075d
         }
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
+        if (*token == "preexec") {
Debarshi Ray 2fdd15b
+                m_pending_changes |= vte::to_integral(PendingChanges::SHELL_PREEXEC);
Debarshi Ray 53d075d
+        }
Debarshi Ray 53d075d
 }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
 bool
Debarshi Ray 53d075d
-- 
ead1cef
2.35.1
Debarshi Ray 53d075d
Debarshi Ray 53d075d
80f531b
From 9fe74c4f17f1fb708a90f22a64fd2b5f4aa794a9 Mon Sep 17 00:00:00 2001
Debarshi Ray 53d075d
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 53d075d
Date: Fri, 20 Apr 2018 18:21:53 +0200
80f531b
Subject: [PATCH 07/11] Test the shell-preexec signal
Debarshi Ray 53d075d
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711060
Debarshi Ray 53d075d
---
Debarshi Ray 53d075d
 bindings/vala/app.vala | 6 ++++++
Debarshi Ray 53d075d
 src/app/app.cc         | 7 +++++++
Debarshi Ray 53d075d
 2 files changed, 13 insertions(+)
Debarshi Ray 53d075d
Debarshi Ray 53d075d
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
ead1cef
index 552a702d..cc30f9ad 100644
Debarshi Ray 53d075d
--- a/bindings/vala/app.vala
Debarshi Ray 53d075d
+++ b/bindings/vala/app.vala
Debarshi Ray 53d075d
@@ -310,6 +310,7 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 53d075d
       terminal.notify.connect(notify_cb);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
     terminal.notification_received.connect(notification_received_cb);
Debarshi Ray 53d075d
+    terminal.shell_preexec.connect(shell_preexec_cb);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
     /* Settings */
Debarshi Ray 355cf28
     if (Options.no_double_buffer)
Debarshi Ray 53d075d
@@ -788,6 +789,11 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 53d075d
     print ("[%s]: %s\n", summary, body);
Debarshi Ray 53d075d
   }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+  private void shell_preexec_cb(Vte.Terminal terminal)
Debarshi Ray 53d075d
+  {
Debarshi Ray 53d075d
+    print("[shell] executing command\n");
Debarshi Ray 53d075d
+  }
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
 } /* class Window */
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
 class App : Gtk.Application
Debarshi Ray 53d075d
diff --git a/src/app/app.cc b/src/app/app.cc
ead1cef
index c6f5cc0b..33a9481e 100644
Debarshi Ray 53d075d
--- a/src/app/app.cc
Debarshi Ray 53d075d
+++ b/src/app/app.cc
ead1cef
@@ -2220,6 +2220,12 @@ notification_received_cb(VteTerminal *terminal,
Debarshi Ray 53d075d
         g_print("[%s]: %s\n", summary, body);
Debarshi Ray 53d075d
 }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+static void
Debarshi Ray 53d075d
+shell_preexec_cb(VteTerminal *terminal)
Debarshi Ray 53d075d
+{
Debarshi Ray 53d075d
+        g_print("[shell] executing command\n");
Debarshi Ray 53d075d
+}
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
 static void
Debarshi Ray 53d075d
 window_lower_window_cb(VteTerminal* terminal,
Debarshi Ray 53d075d
                        VteappWindow* window)
ead1cef
@@ -2517,6 +2523,7 @@ vteapp_window_constructed(GObject *object)
Debarshi Ray 53d075d
                 g_signal_connect(window->terminal, "notify", G_CALLBACK(window_notify_cb), window);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
         g_signal_connect(window->terminal, "notification-received", G_CALLBACK(notification_received_cb), NULL);
Debarshi Ray 53d075d
+        g_signal_connect(window->terminal, "shell-preexec", G_CALLBACK(shell_preexec_cb), NULL);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
         /* Settings */
daec9ca
 #if VTE_GTK == 3
Debarshi Ray 53d075d
-- 
ead1cef
2.35.1
Debarshi Ray 53d075d
Debarshi Ray 53d075d
80f531b
From ed2a83fbf034f79f7c08e8d5e4eeaaea2599e484 Mon Sep 17 00:00:00 2001
Debarshi Ray 53d075d
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 53d075d
Date: Wed, 2 May 2018 17:20:30 +0200
80f531b
Subject: [PATCH 08/11] Support precmd notifications from an interactive shell
Debarshi Ray 53d075d
Debarshi Ray 53d075d
Add sequences
Debarshi Ray 53d075d
  OSC 777 ; precmd BEL
Debarshi Ray 53d075d
  OSC 777 ; precmd ST
Debarshi Ray 53d075d
Debarshi Ray 53d075d
that can be used from an interactive shell's precmd hook to notify the
Debarshi Ray 53d075d
terminal emulator that a first level prompt is about to be shown.
Debarshi Ray 53d075d
Examples of such hooks are Bash's PROMPT_COMMAND and Zsh's precmd.
Debarshi Ray 53d075d
Debarshi Ray 53d075d
The OSC 777 escape sequence is taken from Enlightenment's Terminology:
Debarshi Ray 53d075d
https://phab.enlightenment.org/T1765
Debarshi Ray 53d075d
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711060
Debarshi Ray 53d075d
---
Debarshi Ray 2fdd15b
 src/vte.cc            |  6 ++++++
Debarshi Ray 22ab67e
 src/vte.sh.in         |  2 +-
ead1cef
 src/vte/vteterminal.h |  7 +------
Debarshi Ray 53d075d
 src/vtegtk.cc         | 18 ++++++++++++++++++
Debarshi Ray 53d075d
 src/vtegtk.hh         |  1 +
Debarshi Ray 53d075d
 src/vteinternal.hh    |  1 +
Debarshi Ray 53d075d
 src/vteseq.cc         |  4 +++-
ead1cef
 7 files changed, 31 insertions(+), 8 deletions(-)
Debarshi Ray 53d075d
Debarshi Ray 53d075d
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index 6d8ab2bb..e8a344ee 100644
Debarshi Ray 53d075d
--- a/src/vte.cc
Debarshi Ray 53d075d
+++ b/src/vte.cc
ead1cef
@@ -10063,6 +10063,12 @@ Terminal::emit_pending_signals()
Debarshi Ray 2fdd15b
                 g_signal_emit(freezer.get(), signals[SIGNAL_SHELL_PREEXEC], 0);
Debarshi Ray 53d075d
         }
Debarshi Ray 53d075d
 
Debarshi Ray 2fdd15b
+        if (m_pending_changes & vte::to_integral(PendingChanges::SHELL_PRECMD)) {
Debarshi Ray 53d075d
+                _vte_debug_print (VTE_DEBUG_SIGNALS,
Debarshi Ray 53d075d
+                                  "Emitting `shell-precmd'.\n");
Debarshi Ray b6699a2
+                g_signal_emit(freezer.get(), signals[SIGNAL_SHELL_PRECMD], 0);
Debarshi Ray 53d075d
+        }
Debarshi Ray 53d075d
+
Debarshi Ray 2fdd15b
 	if (m_pending_changes & vte::to_integral(PendingChanges::TITLE)) {
Debarshi Ray 53d075d
                 if (m_window_title != m_window_title_pending) {
Debarshi Ray 53d075d
                         m_window_title.swap(m_window_title_pending);
Debarshi Ray 22ab67e
diff --git a/src/vte.sh.in b/src/vte.sh.in
daec9ca
index 01b44e23..877fe93d 100644
Debarshi Ray 22ab67e
--- a/src/vte.sh.in
Debarshi Ray 22ab67e
+++ b/src/vte.sh.in
daec9ca
@@ -38,7 +38,7 @@ __vte_prompt_command() {
Debarshi Ray 53d075d
   local pwd='~'
Debarshi Ray 53d075d
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
acdaf4f
   pwd="${pwd//[[:cntrl:]]}"
Debarshi Ray 22ab67e
-  printf '\033]777;notify;Command completed;%s\033\\\033]0;%s@%s:%s\033\\' "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
Debarshi Ray 22ab67e
+  printf '\033]777;notify;Command completed;%s\033\\\033]777;precmd\033\\\033]0;%s@%s:%s\033\\' "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
Debarshi Ray 22ab67e
   __vte_osc7
Debarshi Ray 53d075d
 }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
ead1cef
index 062b6694..ed08880d 100644
Debarshi Ray 53d075d
--- a/src/vte/vteterminal.h
Debarshi Ray 53d075d
+++ b/src/vte/vteterminal.h
ead1cef
@@ -109,14 +109,9 @@ struct _VteTerminalClass {
Debarshi Ray 53d075d
 	void (*bell)(VteTerminal* terminal);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
 	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 53d075d
+	void (*shell_precmd)(VteTerminal* terminal);
Debarshi Ray 53d075d
 	void (*shell_preexec)(VteTerminal* terminal);
Debarshi Ray 53d075d
 
ead1cef
-#if _VTE_GTK == 3
ead1cef
-        /* Compatibility padding due to fedora patches intruding on our ABI */
ead1cef
-        /*< private >*/
ead1cef
-        gpointer _extra_padding[1];
ead1cef
-#endif /* _VTE_GTK == 3 */
ead1cef
-
ead1cef
         /* Add new vfuncs here, and subtract from the padding below. */
Debarshi Ray 53d075d
 
ead1cef
         /* Padding for future expansion. */
Debarshi Ray 53d075d
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
ead1cef
index a4d51bfb..7020c2af 100644
Debarshi Ray 53d075d
--- a/src/vtegtk.cc
Debarshi Ray 53d075d
+++ b/src/vtegtk.cc
daec9ca
@@ -1249,6 +1249,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 53d075d
 	klass->encoding_changed = NULL;
Debarshi Ray 53d075d
 	klass->char_size_changed = NULL;
Debarshi Ray 53d075d
 	klass->notification_received = NULL;
Debarshi Ray 53d075d
+	klass->shell_precmd = NULL;
Debarshi Ray 53d075d
 	klass->shell_preexec = NULL;
Debarshi Ray 53d075d
 	klass->window_title_changed = NULL;
Debarshi Ray 53d075d
 	klass->icon_title_changed = NULL;
daec9ca
@@ -1353,6 +1354,23 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 53d075d
                              G_TYPE_NONE,
Debarshi Ray 53d075d
                              2, G_TYPE_STRING, G_TYPE_STRING);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+        /**
Debarshi Ray 53d075d
+         * VteTerminal::shell-precmd:
Debarshi Ray 53d075d
+         * @vteterminal: the object which received the signal
Debarshi Ray 53d075d
+         *
Debarshi Ray 53d075d
+         * Emitted right before an interactive shell shows a
Debarshi Ray 53d075d
+         * first-level prompt.
Debarshi Ray 53d075d
+         */
Debarshi Ray 53d075d
+        signals[SIGNAL_SHELL_PRECMD] =
Debarshi Ray 53d075d
+                g_signal_new(I_("shell-precmd"),
Debarshi Ray 53d075d
+                             G_OBJECT_CLASS_TYPE(klass),
Debarshi Ray 53d075d
+                             G_SIGNAL_RUN_LAST,
Debarshi Ray 53d075d
+                             G_STRUCT_OFFSET(VteTerminalClass, shell_precmd),
Debarshi Ray 53d075d
+                             NULL,
Debarshi Ray 53d075d
+                             NULL,
Debarshi Ray 53d075d
+                             g_cclosure_marshal_VOID__VOID,
Debarshi Ray 53d075d
+                             G_TYPE_NONE, 0);
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
         /**
Debarshi Ray 53d075d
          * VteTerminal::shell-preexec:
Debarshi Ray 53d075d
          * @vteterminal: the object which received the signal
Debarshi Ray 53d075d
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
daec9ca
index bf85bdf4..cee56b65 100644
Debarshi Ray 53d075d
--- a/src/vtegtk.hh
Debarshi Ray 53d075d
+++ b/src/vtegtk.hh
Debarshi Ray 53d075d
@@ -52,6 +52,7 @@ enum {
Debarshi Ray 53d075d
         SIGNAL_RESIZE_WINDOW,
Debarshi Ray 53d075d
         SIGNAL_RESTORE_WINDOW,
Debarshi Ray 53d075d
         SIGNAL_SELECTION_CHANGED,
Debarshi Ray 53d075d
+        SIGNAL_SHELL_PRECMD,
Debarshi Ray 53d075d
         SIGNAL_SHELL_PREEXEC,
daec9ca
         SIGNAL_NOTIFICATION_RECEIVED,
daec9ca
         SIGNAL_WINDOW_TITLE_CHANGED,
Debarshi Ray 53d075d
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
ead1cef
index b4f1b4c9..eabc0062 100644
Debarshi Ray 53d075d
--- a/src/vteinternal.hh
Debarshi Ray 53d075d
+++ b/src/vteinternal.hh
ead1cef
@@ -680,6 +680,7 @@ public:
Debarshi Ray 2fdd15b
                 CWF   = 1u << 2,
Debarshi Ray 2fdd15b
                 NOTIFICATION = 1u << 3,
Debarshi Ray 2fdd15b
                 SHELL_PREEXEC = 1u << 4,
Debarshi Ray 2fdd15b
+                SHELL_PRECMD = 1u << 5,
Debarshi Ray 2fdd15b
         };
Debarshi Ray 2fdd15b
         unsigned m_pending_changes{0};
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
diff --git a/src/vteseq.cc b/src/vteseq.cc
ead1cef
index dbc6276f..4de2a6f1 100644
Debarshi Ray 53d075d
--- a/src/vteseq.cc
Debarshi Ray 53d075d
+++ b/src/vteseq.cc
daec9ca
@@ -1402,7 +1402,9 @@ Terminal::handle_urxvt_extension(vte::parser::Sequence const& seq,
Debarshi Ray 53d075d
                 return;
Debarshi Ray 53d075d
         }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
-        if (*token == "preexec") {
Debarshi Ray 53d075d
+        if (*token == "precmd") {
Debarshi Ray 2fdd15b
+                m_pending_changes |= vte::to_integral(PendingChanges::SHELL_PRECMD);
Debarshi Ray 53d075d
+        } else if (*token == "preexec") {
Debarshi Ray 2fdd15b
                 m_pending_changes |= vte::to_integral(PendingChanges::SHELL_PREEXEC);
Debarshi Ray 53d075d
         }
Debarshi Ray 53d075d
 }
Debarshi Ray 53d075d
-- 
ead1cef
2.35.1
Debarshi Ray 53d075d
Debarshi Ray 53d075d
80f531b
From 2f3ea5834f7ae8c946724c3aef05964383088ec0 Mon Sep 17 00:00:00 2001
Debarshi Ray 53d075d
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 53d075d
Date: Wed, 2 May 2018 17:30:48 +0200
80f531b
Subject: [PATCH 09/11] Test the shell-precmd signal
Debarshi Ray 53d075d
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 53d075d
https://bugzilla.gnome.org/show_bug.cgi?id=711060
Debarshi Ray 53d075d
---
Debarshi Ray 53d075d
 bindings/vala/app.vala | 6 ++++++
Debarshi Ray 53d075d
 src/app/app.cc         | 7 +++++++
Debarshi Ray 53d075d
 2 files changed, 13 insertions(+)
Debarshi Ray 53d075d
Debarshi Ray 53d075d
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
ead1cef
index cc30f9ad..ecc4b769 100644
Debarshi Ray 53d075d
--- a/bindings/vala/app.vala
Debarshi Ray 53d075d
+++ b/bindings/vala/app.vala
Debarshi Ray 53d075d
@@ -310,6 +310,7 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 53d075d
       terminal.notify.connect(notify_cb);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
     terminal.notification_received.connect(notification_received_cb);
Debarshi Ray 53d075d
+    terminal.shell_precmd.connect(shell_precmd_cb);
Debarshi Ray 53d075d
     terminal.shell_preexec.connect(shell_preexec_cb);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
     /* Settings */
Debarshi Ray 53d075d
@@ -789,6 +790,11 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 53d075d
     print ("[%s]: %s\n", summary, body);
Debarshi Ray 53d075d
   }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+  private void shell_precmd_cb(Vte.Terminal terminal)
Debarshi Ray 53d075d
+  {
Debarshi Ray 53d075d
+    print("[shell] showing command prompt\n");
Debarshi Ray 53d075d
+  }
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
   private void shell_preexec_cb(Vte.Terminal terminal)
Debarshi Ray 53d075d
   {
Debarshi Ray 53d075d
     print("[shell] executing command\n");
Debarshi Ray 53d075d
diff --git a/src/app/app.cc b/src/app/app.cc
ead1cef
index 33a9481e..d30f8bd7 100644
Debarshi Ray 53d075d
--- a/src/app/app.cc
Debarshi Ray 53d075d
+++ b/src/app/app.cc
ead1cef
@@ -2220,6 +2220,12 @@ notification_received_cb(VteTerminal *terminal,
Debarshi Ray 53d075d
         g_print("[%s]: %s\n", summary, body);
Debarshi Ray 53d075d
 }
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
+static void
Debarshi Ray 53d075d
+shell_precmd_cb(VteTerminal *terminal)
Debarshi Ray 53d075d
+{
Debarshi Ray 53d075d
+        g_print("[shell] showing command prompt\n");
Debarshi Ray 53d075d
+}
Debarshi Ray 53d075d
+
Debarshi Ray 53d075d
 static void
Debarshi Ray 53d075d
 shell_preexec_cb(VteTerminal *terminal)
Debarshi Ray 53d075d
 {
ead1cef
@@ -2523,6 +2529,7 @@ vteapp_window_constructed(GObject *object)
Debarshi Ray 53d075d
                 g_signal_connect(window->terminal, "notify", G_CALLBACK(window_notify_cb), window);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
         g_signal_connect(window->terminal, "notification-received", G_CALLBACK(notification_received_cb), NULL);
Debarshi Ray 53d075d
+        g_signal_connect(window->terminal, "shell-precmd", G_CALLBACK(shell_precmd_cb), NULL);
Debarshi Ray 53d075d
         g_signal_connect(window->terminal, "shell-preexec", G_CALLBACK(shell_preexec_cb), NULL);
Debarshi Ray 53d075d
 
Debarshi Ray 53d075d
         /* Settings */
Debarshi Ray 53d075d
-- 
ead1cef
2.35.1
Debarshi Ray 955c24e
Debarshi Ray 3a1a7ca
80f531b
From 08d50a8599dad3ac60f54cb0aeeadb3ca26c214d Mon Sep 17 00:00:00 2001
Debarshi Ray 3a1a7ca
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 3a1a7ca
Date: Mon, 10 Jun 2019 20:30:18 +0200
80f531b
Subject: [PATCH 10/11] Support tracking the active container inside the
Debarshi Ray 3a1a7ca
 terminal
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
Add sequences
Debarshi Ray de28387
Debarshi Ray de28387
  OSC 777 ; container ; push ; NAME ; RUNTIME ; UID BEL
Debarshi Ray de28387
  OSC 777 ; container ; push ; NAME ; RUNTIME ; UID ST
Debarshi Ray de28387
  OSC 777 ; container ; pop ; NAME ; RUNTIME ; UID BEL
Debarshi Ray de28387
  OSC 777 ; container ; pop ; NAME ; RUNTIME ; UID ST
Debarshi Ray de28387
Debarshi Ray 3a1a7ca
  OSC 777 ; container ; push ; NAME ; RUNTIME BEL
Debarshi Ray 3a1a7ca
  OSC 777 ; container ; push ; NAME ; RUNTIME ST
Debarshi Ray 3a1a7ca
  OSC 777 ; container ; pop ; NAME ; RUNTIME BEL
Debarshi Ray 3a1a7ca
  OSC 777 ; container ; pop ; NAME ; RUNTIME ST
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
that let container tools notify the terminal emulator when entering and
Debarshi Ray 3a1a7ca
leaving a container environment. The RUNTIME argument namespaces the
Debarshi Ray 3a1a7ca
NAME and identifies the container tooling being used. eg., docker,
Debarshi Ray de28387
flatpak, podman, toolbox, etc.. The UID argument is the real UID of the
Debarshi Ray de28387
container tools. Only those containers that are used with the same real
Debarshi Ray de28387
UID as the VTE process are tracked.
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
The OSC 777 escape sequence is taken from Enlightenment's Terminology:
Debarshi Ray 3a1a7ca
https://phab.enlightenment.org/T1765
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
It's a VTE-specific extension until a standard escape sequence is
Debarshi Ray 3a1a7ca
agreed upon across multiple different terminal emulators [1].
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
[1] https://gitlab.freedesktop.org/terminal-wg/specifications/issues/17
Debarshi Ray 3a1a7ca
---
Debarshi Ray 2fdd15b
 src/vte.cc            |  8 ++++
Debarshi Ray de28387
 src/vte/vteterminal.h |  4 ++
Debarshi Ray de28387
 src/vtegtk.cc         | 77 ++++++++++++++++++++++++++++++++++++++
Debarshi Ray de28387
 src/vtegtk.hh         |  2 +
Debarshi Ray de28387
 src/vteinternal.hh    | 16 ++++++++
Debarshi Ray de28387
 src/vteseq.cc         | 86 +++++++++++++++++++++++++++++++++++++++++++
Debarshi Ray 2fdd15b
 6 files changed, 193 insertions(+)
Debarshi Ray 3a1a7ca
Debarshi Ray 3a1a7ca
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index e8a344ee..a3ca5108 100644
Debarshi Ray 3a1a7ca
--- a/src/vte.cc
Debarshi Ray 3a1a7ca
+++ b/src/vte.cc
ead1cef
@@ -10082,6 +10082,14 @@ Terminal::emit_pending_signals()
Debarshi Ray 2fdd15b
                 m_window_title_pending.clear();
Debarshi Ray 3a1a7ca
 	}
Debarshi Ray 3a1a7ca
 
Debarshi Ray 2fdd15b
+	if (m_pending_changes & vte::to_integral(PendingChanges::CONTAINERS)) {
Debarshi Ray 3a1a7ca
+                _vte_debug_print(VTE_DEBUG_SIGNALS,
Debarshi Ray 3a1a7ca
+                                 "Notifying `current-container-name' and `current-container-runtime'.\n");
Debarshi Ray 3a1a7ca
+
Debarshi Ray b6699a2
+                g_object_notify_by_pspec(freezer.get(), pspecs[PROP_CURRENT_CONTAINER_NAME]);
Debarshi Ray b6699a2
+                g_object_notify_by_pspec(freezer.get(), pspecs[PROP_CURRENT_CONTAINER_RUNTIME]);
Debarshi Ray 3a1a7ca
+        }
Debarshi Ray 3a1a7ca
+
Debarshi Ray 2fdd15b
 	if (m_pending_changes & vte::to_integral(PendingChanges::CWD)) {
Debarshi Ray 3a1a7ca
                 if (m_current_directory_uri != m_current_directory_uri_pending) {
Debarshi Ray 3a1a7ca
                         m_current_directory_uri.swap(m_current_directory_uri_pending);
Debarshi Ray 3a1a7ca
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
ead1cef
index ed08880d..d25eb93a 100644
Debarshi Ray 3a1a7ca
--- a/src/vte/vteterminal.h
Debarshi Ray 3a1a7ca
+++ b/src/vte/vteterminal.h
daec9ca
@@ -511,6 +511,10 @@ glong vte_terminal_get_column_count(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VT
Debarshi Ray 3a1a7ca
 _VTE_PUBLIC
Debarshi Ray b6699a2
 const char *vte_terminal_get_window_title(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 3a1a7ca
 _VTE_PUBLIC
Debarshi Ray b6699a2
+const char *vte_terminal_get_current_container_name(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 3a1a7ca
+_VTE_PUBLIC
Debarshi Ray b6699a2
+const char *vte_terminal_get_current_container_runtime(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 3a1a7ca
+_VTE_PUBLIC
Debarshi Ray b6699a2
 const char *vte_terminal_get_current_directory_uri(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 3a1a7ca
 _VTE_PUBLIC
Debarshi Ray b6699a2
 const char *vte_terminal_get_current_file_uri(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
Debarshi Ray 3a1a7ca
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
ead1cef
index 7020c2af..2ee5b029 100644
Debarshi Ray 3a1a7ca
--- a/src/vtegtk.cc
Debarshi Ray 3a1a7ca
+++ b/src/vtegtk.cc
daec9ca
@@ -942,6 +942,12 @@ try
Debarshi Ray 3a1a7ca
                 case PROP_CURSOR_BLINK_MODE:
Debarshi Ray 3a1a7ca
                         g_value_set_enum (value, vte_terminal_get_cursor_blink_mode (terminal));
Debarshi Ray 3a1a7ca
                         break;
Debarshi Ray 3a1a7ca
+                case PROP_CURRENT_CONTAINER_NAME:
Debarshi Ray 3a1a7ca
+                        g_value_set_string (value, vte_terminal_get_current_container_name (terminal));
Debarshi Ray 3a1a7ca
+                        break;
Debarshi Ray 3a1a7ca
+                case PROP_CURRENT_CONTAINER_RUNTIME:
Debarshi Ray 3a1a7ca
+                        g_value_set_string (value, vte_terminal_get_current_container_runtime (terminal));
Debarshi Ray 3a1a7ca
+                        break;
Debarshi Ray 3a1a7ca
                 case PROP_CURRENT_DIRECTORY_URI:
Debarshi Ray 3a1a7ca
                         g_value_set_string (value, vte_terminal_get_current_directory_uri (terminal));
Debarshi Ray 3a1a7ca
                         break;
daec9ca
@@ -2357,6 +2363,27 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 3a1a7ca
                                      NULL,
Debarshi Ray 3a1a7ca
                                      (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
+        /**
Debarshi Ray 3a1a7ca
+         * VteTerminal:current-container-name:
Debarshi Ray 3a1a7ca
+         *
Debarshi Ray 3a1a7ca
+         * The name of the current container, or %NULL if unset.
Debarshi Ray 3a1a7ca
+         */
Debarshi Ray 3a1a7ca
+        pspecs[PROP_CURRENT_CONTAINER_NAME] =
Debarshi Ray 3a1a7ca
+                g_param_spec_string ("current-container-name", NULL, NULL,
Debarshi Ray 3a1a7ca
+                                     NULL,
Debarshi Ray 3a1a7ca
+                                     (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+        /**
Debarshi Ray 3a1a7ca
+         * VteTerminal:current-container-runtime:
Debarshi Ray 3a1a7ca
+         *
Debarshi Ray 3a1a7ca
+         * The name of the runtime toolset used to set up the current
Debarshi Ray 3a1a7ca
+         * container, or %NULL if unset.
Debarshi Ray 3a1a7ca
+         */
Debarshi Ray 3a1a7ca
+        pspecs[PROP_CURRENT_CONTAINER_RUNTIME] =
Debarshi Ray 3a1a7ca
+                g_param_spec_string ("current-container-runtime", NULL, NULL,
Debarshi Ray 3a1a7ca
+                                     NULL,
Debarshi Ray 3a1a7ca
+                                     (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
         /**
Debarshi Ray 3a1a7ca
          * VteTerminal:current-directory-uri:
Debarshi Ray 3a1a7ca
          *
ead1cef
@@ -4929,6 +4956,56 @@ catch (...)
Debarshi Ray b6699a2
         return -1;
Debarshi Ray 3a1a7ca
 }
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
+/**
Debarshi Ray 3a1a7ca
+ * vte_terminal_get_current_container_name:
Debarshi Ray 3a1a7ca
+ * @terminal: a #VteTerminal
Debarshi Ray 3a1a7ca
+ *
Debarshi Ray 3a1a7ca
+ * Returns: (nullable) (transfer none): the name of the current
Debarshi Ray 3a1a7ca
+ *   container, or %NULL
Debarshi Ray 3a1a7ca
+ */
Debarshi Ray 3a1a7ca
+const char *
Debarshi Ray b6699a2
+vte_terminal_get_current_container_name(VteTerminal *terminal) noexcept
Debarshi Ray b6699a2
+try
Debarshi Ray 3a1a7ca
+{
Debarshi Ray 3a1a7ca
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
Debarshi Ray 3a1a7ca
+        auto impl = IMPL(terminal);
Debarshi Ray 3a1a7ca
+        if (impl->m_containers.empty())
Debarshi Ray 3a1a7ca
+                return NULL;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+        const VteContainer &container = impl->m_containers.top();
Debarshi Ray 3a1a7ca
+        return container.m_name.c_str();
Debarshi Ray 3a1a7ca
+}
Debarshi Ray b6699a2
+catch (...)
Debarshi Ray b6699a2
+{
Debarshi Ray b6699a2
+        vte::log_exception();
Debarshi Ray b6699a2
+        return NULL;
Debarshi Ray b6699a2
+}
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+/**
Debarshi Ray 3a1a7ca
+ * vte_terminal_get_current_container_runtime:
Debarshi Ray 3a1a7ca
+ * @terminal: a #VteTerminal
Debarshi Ray 3a1a7ca
+ *
Debarshi Ray 3a1a7ca
+ * Returns: (nullable) (transfer none): the name of the runtime
Debarshi Ray 3a1a7ca
+ *   toolset used to set up the current container, or %NULL
Debarshi Ray 3a1a7ca
+ */
Debarshi Ray 3a1a7ca
+const char *
Debarshi Ray b6699a2
+vte_terminal_get_current_container_runtime(VteTerminal *terminal) noexcept
Debarshi Ray b6699a2
+try
Debarshi Ray 3a1a7ca
+{
Debarshi Ray 3a1a7ca
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
Debarshi Ray 3a1a7ca
+        auto impl = IMPL(terminal);
Debarshi Ray 3a1a7ca
+        if (impl->m_containers.empty())
Debarshi Ray 3a1a7ca
+                return NULL;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+        const VteContainer &container = impl->m_containers.top();
Debarshi Ray 3a1a7ca
+        return container.m_runtime.c_str();
Debarshi Ray 3a1a7ca
+}
Debarshi Ray b6699a2
+catch (...)
Debarshi Ray b6699a2
+{
Debarshi Ray b6699a2
+        vte::log_exception();
Debarshi Ray b6699a2
+        return NULL;
Debarshi Ray b6699a2
+}
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
 /**
Debarshi Ray 3a1a7ca
  * vte_terminal_get_current_directory_uri:
Debarshi Ray 3a1a7ca
  * @terminal: a #VteTerminal
Debarshi Ray 3a1a7ca
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
daec9ca
index cee56b65..e41f2f3a 100644
Debarshi Ray 3a1a7ca
--- a/src/vtegtk.hh
Debarshi Ray 3a1a7ca
+++ b/src/vtegtk.hh
daec9ca
@@ -72,6 +72,8 @@ enum {
Debarshi Ray 3a1a7ca
         PROP_CJK_AMBIGUOUS_WIDTH,
Debarshi Ray 3a1a7ca
         PROP_CURSOR_BLINK_MODE,
Debarshi Ray 3a1a7ca
         PROP_CURSOR_SHAPE,
Debarshi Ray 3a1a7ca
+        PROP_CURRENT_CONTAINER_NAME,
Debarshi Ray 3a1a7ca
+        PROP_CURRENT_CONTAINER_RUNTIME,
Debarshi Ray 3a1a7ca
         PROP_CURRENT_DIRECTORY_URI,
Debarshi Ray 3a1a7ca
         PROP_CURRENT_FILE_URI,
Debarshi Ray 3a1a7ca
         PROP_DELETE_BINDING,
Debarshi Ray 3a1a7ca
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
ead1cef
index eabc0062..dcb6a6fc 100644
Debarshi Ray 3a1a7ca
--- a/src/vteinternal.hh
Debarshi Ray 3a1a7ca
+++ b/src/vteinternal.hh
Debarshi Ray 2fdd15b
@@ -59,6 +59,7 @@
Debarshi Ray 3a1a7ca
 #include <list>
Debarshi Ray 3a1a7ca
 #include <queue>
Debarshi Ray 22ab67e
 #include <optional>
Debarshi Ray 3a1a7ca
+#include <stack>
Debarshi Ray 3a1a7ca
 #include <string>
Debarshi Ray 511ade8
 #include <variant>
Debarshi Ray 3a1a7ca
 #include <vector>
daec9ca
@@ -110,6 +111,18 @@ typedef enum _VteCharacterReplacement {
Debarshi Ray 22ab67e
         VTE_CHARACTER_REPLACEMENT_LINE_DRAWING
Debarshi Ray 3a1a7ca
 } VteCharacterReplacement;
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
+struct VteContainer {
Debarshi Ray 3a1a7ca
+public:
Debarshi Ray 3a1a7ca
+        VteContainer(const std::string &name, const std::string &runtime) :
Debarshi Ray 3a1a7ca
+                m_name{name},
Debarshi Ray 3a1a7ca
+                m_runtime{runtime}
Debarshi Ray 3a1a7ca
+        {
Debarshi Ray 3a1a7ca
+        }
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+        std::string m_name;
Debarshi Ray 3a1a7ca
+        std::string m_runtime;
Debarshi Ray 3a1a7ca
+};
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
 typedef struct _VtePaletteColor {
Debarshi Ray 3a1a7ca
 	struct {
Debarshi Ray 3a1a7ca
 		vte::color::rgb color;
ead1cef
@@ -661,6 +674,8 @@ public:
Debarshi Ray 3a1a7ca
         gboolean m_cursor_moved_pending;
Debarshi Ray 3a1a7ca
         gboolean m_contents_changed_pending;
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
+        std::stack<VteContainer> m_containers;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
         /* desktop notification */
Debarshi Ray 3a1a7ca
         std::string m_notification_summary;
Debarshi Ray 2fdd15b
         std::string m_notification_body;
ead1cef
@@ -681,6 +696,7 @@ public:
Debarshi Ray 2fdd15b
                 NOTIFICATION = 1u << 3,
Debarshi Ray 2fdd15b
                 SHELL_PREEXEC = 1u << 4,
Debarshi Ray 2fdd15b
                 SHELL_PRECMD = 1u << 5,
Debarshi Ray 2fdd15b
+                CONTAINERS = 1u << 6,
Debarshi Ray 2fdd15b
         };
Debarshi Ray 2fdd15b
         unsigned m_pending_changes{0};
Debarshi Ray 2fdd15b
 
Debarshi Ray 3a1a7ca
diff --git a/src/vteseq.cc b/src/vteseq.cc
ead1cef
index 4de2a6f1..18c0d89c 100644
Debarshi Ray 3a1a7ca
--- a/src/vteseq.cc
Debarshi Ray 3a1a7ca
+++ b/src/vteseq.cc
Debarshi Ray 2fdd15b
@@ -19,10 +19,14 @@
Debarshi Ray de28387
 
Debarshi Ray de28387
 #include "config.h"
Debarshi Ray de28387
 
Debarshi Ray de28387
+#include <string>
Debarshi Ray de28387
+
Debarshi Ray de28387
 #include <search.h>
Debarshi Ray de28387
 #include <stdlib.h>
Debarshi Ray de28387
 #include <string.h>
Debarshi Ray de28387
 #include <limits.h>
Debarshi Ray de28387
+#include <unistd.h>
Debarshi Ray de28387
+#include <sys/types.h>
Debarshi Ray de28387
 #ifdef HAVE_SYS_SYSLIMITS_H
Debarshi Ray de28387
 #include <sys/syslimits.h>
Debarshi Ray de28387
 #endif
daec9ca
@@ -1384,6 +1388,88 @@ Terminal::handle_urxvt_extension(vte::parser::Sequence const& seq,
Debarshi Ray 3a1a7ca
         if (token == endtoken)
Debarshi Ray 3a1a7ca
                 return;
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
+        if (*token == "container") {
Debarshi Ray 3a1a7ca
+                ++token;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                if (token == endtoken)
Debarshi Ray 3a1a7ca
+                        return;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                const std::string sub_command = *token;
Debarshi Ray 3a1a7ca
+                ++token;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                if (sub_command == "pop") {
Debarshi Ray de28387
+                        if (token == endtoken)
Debarshi Ray de28387
+                                return;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        ++token;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        if (token == endtoken)
Debarshi Ray de28387
+                                return;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        ++token;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        if (token == endtoken) {
Debarshi Ray de28387
+                                if (!m_containers.empty()) {
Debarshi Ray de28387
+                                        m_containers.pop();
Debarshi Ray 2fdd15b
+                                        m_pending_changes |= vte::to_integral(PendingChanges::CONTAINERS);
Debarshi Ray de28387
+                                }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                                return;
Debarshi Ray de28387
+                        }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        const std::string uid_token = *token;
Debarshi Ray de28387
+                        ++token;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        const uid_t uid = getuid();
Debarshi Ray de28387
+                        const std::string uid_str = std::to_string(uid);
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        if (uid_token == uid_str) {
Debarshi Ray de28387
+                                if (!m_containers.empty()) {
Debarshi Ray de28387
+                                        m_containers.pop();
Debarshi Ray 2fdd15b
+                                        m_pending_changes |= vte::to_integral(PendingChanges::CONTAINERS);
Debarshi Ray de28387
+                                }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                                return;
Debarshi Ray 3a1a7ca
+                        }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        return;
Debarshi Ray 3a1a7ca
+                } else if (sub_command == "push") {
Debarshi Ray 3a1a7ca
+                        if (token == endtoken)
Debarshi Ray 3a1a7ca
+                                return;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                        const std::string name = *token;
Debarshi Ray 3a1a7ca
+                        ++token;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                        if (token == endtoken)
Debarshi Ray 3a1a7ca
+                                return;
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
+                        const std::string runtime = *token;
Debarshi Ray de28387
+                        ++token;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        if (token == endtoken) {
Debarshi Ray de28387
+                                m_containers.emplace(name, runtime);
Debarshi Ray 2fdd15b
+                                m_pending_changes |= vte::to_integral(PendingChanges::CONTAINERS);
Debarshi Ray de28387
+                                return;
Debarshi Ray de28387
+                        }
Debarshi Ray 3a1a7ca
+
Debarshi Ray de28387
+                        const std::string uid_token = *token;
Debarshi Ray de28387
+                        ++token;
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        const uid_t uid = getuid();
Debarshi Ray de28387
+                        const std::string uid_str = std::to_string(uid);
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        if (uid_token == uid_str) {
Debarshi Ray de28387
+                                m_containers.emplace(name, runtime);
Debarshi Ray 2fdd15b
+                                m_pending_changes |= vte::to_integral(PendingChanges::CONTAINERS);
Debarshi Ray de28387
+                                return;
Debarshi Ray de28387
+                        }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                        return;
Debarshi Ray 3a1a7ca
+                }
Debarshi Ray de28387
+
Debarshi Ray de28387
+                return;
Debarshi Ray 3a1a7ca
+        }
Debarshi Ray 3a1a7ca
+
Debarshi Ray 3a1a7ca
         if (*token == "notify") {
Debarshi Ray 3a1a7ca
                 ++token;
Debarshi Ray 3a1a7ca
 
Debarshi Ray 3a1a7ca
-- 
ead1cef
2.35.1
Debarshi Ray 2fdd15b
Debarshi Ray 2fdd15b
80f531b
From 62df90e5147c8be4e12bcf5ce99679c1fb2390d0 Mon Sep 17 00:00:00 2001
Debarshi Ray 2fdd15b
From: Kalev Lember <klember@redhat.com>
Debarshi Ray 2fdd15b
Date: Tue, 16 Feb 2021 16:30:44 +0100
80f531b
Subject: [PATCH 11/11] Revert "widget: Limit select-all to the writable region
Debarshi Ray 2fdd15b
 not including the scrollback"
Debarshi Ray 2fdd15b
Debarshi Ray 2fdd15b
... as decided by Fedora Workstation WG.
Debarshi Ray 2fdd15b
Debarshi Ray 2fdd15b
https://pagure.io/fedora-workstation/issue/216
Debarshi Ray 2fdd15b
Debarshi Ray 2fdd15b
This reverts commit 73713ec0644e232fb740170e399282be778d97f9.
Debarshi Ray 2fdd15b
---
Debarshi Ray 2fdd15b
 src/vte.cc | 9 +++------
Debarshi Ray 2fdd15b
 1 file changed, 3 insertions(+), 6 deletions(-)
Debarshi Ray 2fdd15b
Debarshi Ray 2fdd15b
diff --git a/src/vte.cc b/src/vte.cc
ead1cef
index a3ca5108..1834b090 100644
Debarshi Ray 2fdd15b
--- a/src/vte.cc
Debarshi Ray 2fdd15b
+++ b/src/vte.cc
ead1cef
@@ -6497,10 +6497,7 @@ Terminal::maybe_end_selection()
Debarshi Ray 2fdd15b
 /*
Debarshi Ray 2fdd15b
  * Terminal::select_all:
Debarshi Ray 2fdd15b
  *
Debarshi Ray 2fdd15b
- * Selects all text within the terminal. Note that we only select the writable
Debarshi Ray 2fdd15b
- * region, *not* the scrollback buffer, due to this potentially selecting so
Debarshi Ray 2fdd15b
- * much data that putting it on the clipboard either hangs the process for a long
Debarshi Ray 2fdd15b
- * time or even crash it directly. (FIXME!)
Debarshi Ray 2fdd15b
+ * Selects all text within the terminal (including the scrollback buffer).
Debarshi Ray 2fdd15b
  */
Debarshi Ray 2fdd15b
 void
Debarshi Ray 2fdd15b
 Terminal::select_all()
ead1cef
@@ -6509,8 +6506,8 @@ Terminal::select_all()
Debarshi Ray 2fdd15b
 
Debarshi Ray 2fdd15b
 	m_selecting_had_delta = TRUE;
Debarshi Ray 2fdd15b
 
Debarshi Ray 2fdd15b
-        m_selection_resolved.set({m_screen->insert_delta, 0},
Debarshi Ray 2fdd15b
-                                 {_vte_ring_next(m_screen->row_data), 0});
Debarshi Ray 2fdd15b
+        m_selection_resolved.set ({ _vte_ring_delta (m_screen->row_data), 0 },
Debarshi Ray 2fdd15b
+                                  { _vte_ring_next  (m_screen->row_data), 0 });
Debarshi Ray 2fdd15b
 
Debarshi Ray 2fdd15b
 	_vte_debug_print(VTE_DEBUG_SELECTION, "Selecting *all* text.\n");
Debarshi Ray 2fdd15b
 
Debarshi Ray 2fdd15b
-- 
ead1cef
2.35.1
Debarshi Ray 89a8627