[vte] emulation: Implement the window title stack



commit 23c44f1f18b7985d9fba3205500d8873ecde51aa
Author: Christian Persch <chpe src gnome org>
Date:   Tue Mar 27 19:40:12 2018 +0200

    emulation: Implement the window title stack
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699819

 src/vte.cc         |    5 +++++
 src/vtedefines.hh  |    3 +++
 src/vteinternal.hh |    5 +++++
 src/vteseq.cc      |   39 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 2d3a388..3e7ab4a 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -10541,6 +10541,11 @@ VteTerminalPrivate::reset(bool clear_tabstops,
         m_modes_private.clear_saved();
         m_modes_private.reset();
 
+        /* Window title stack */
+        if (clear_history) {
+                m_window_title_stack.clear();
+        }
+
         update_mouse_protocol();
 
        /* Reset the color palette. Only the 256 indexed colors, not the special ones, as per xterm. */
diff --git a/src/vtedefines.hh b/src/vtedefines.hh
index e8ffb62..67c26f1 100644
--- a/src/vtedefines.hh
+++ b/src/vtedefines.hh
@@ -139,3 +139,6 @@
  * Currently the hyperlink data is the ID and URI and a separator in between.
  * Make sure there are enough bits to store this in VteStreamCellAttr.hyperlink_length */
 #define VTE_HYPERLINK_TOTAL_LENGTH_MAX  (VTE_HYPERLINK_ID_LENGTH_MAX + 1 + VTE_HYPERLINK_URI_LENGTH_MAX)
+
+/* Max depth of title stack */
+#define VTE_WINDOW_TITLE_STACK_MAX_DEPTH (8)
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index e230600..361187c 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -33,6 +33,9 @@
 #include "vtepcre2.h"
 #include "vteregexinternal.hh"
 
+#include <string>
+#include <vector>
+
 typedef enum {
         VTE_REGEX_CURSOR_GDKCURSOR,
         VTE_REGEX_CURSOR_GDKCURSORTYPE,
@@ -525,6 +528,8 @@ public:
         bool m_current_directory_uri_changed{false};
         bool m_current_file_uri_changed{false};
 
+        std::vector<std::string> m_window_title_stack{};
+
        /* Background */
         double m_background_alpha;
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 5be0725..f94db82 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -5563,9 +5563,48 @@ VteTerminalPrivate::XTERM_WM(vte::parser::Sequence const& seq)
                 break;
 
         case VTE_XTERM_WM_TITLE_STACK_PUSH:
+                switch (seq.collect1(1)) {
+                case -1:
+                case VTE_OSC_XTERM_SET_WINDOW_AND_ICON_TITLE:
+                case VTE_OSC_XTERM_SET_WINDOW_TITLE:
+                        if (m_window_title_stack.size() >= VTE_WINDOW_TITLE_STACK_MAX_DEPTH) {
+                                /* Drop the bottommost item */
+                                m_window_title_stack.erase(m_window_title_stack.cbegin());
+                        }
+
+                        if (m_window_title_changed)
+                                m_window_title_stack.emplace(m_window_title_stack.cend(),
+                                                             m_window_title_pending);
+                        else
+                                m_window_title_stack.emplace(m_window_title_stack.cend(),
+                                                             m_window_title);
+
+                        g_assert_cmpuint(m_window_title_stack.size(), <=, VTE_WINDOW_TITLE_STACK_MAX_DEPTH);
+                        break;
+
+                case VTE_OSC_XTERM_SET_ICON_TITLE:
+                default:
+                        break;
+                }
                 break;
 
         case VTE_XTERM_WM_TITLE_STACK_POP:
+                switch (seq.collect1(1)) {
+                case -1:
+                case VTE_OSC_XTERM_SET_WINDOW_AND_ICON_TITLE:
+                case VTE_OSC_XTERM_SET_WINDOW_TITLE:
+                        if (m_window_title_stack.empty())
+                                break;
+
+                        m_window_title_changed = true;
+                        m_window_title_pending.swap(m_window_title_stack.back());
+                        m_window_title_stack.pop_back();
+                        break;
+
+                case VTE_OSC_XTERM_SET_ICON_TITLE:
+                default:
+                        break;
+                }
                 break;
 
         default:


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