[vte] emulation: Make OSC replies with same terminator as request



commit 8717ef9d2ec206fe36b758fe9098387c0c3351b2
Author: Christian Persch <chpe src gnome org>
Date:   Sun Oct 28 19:44:28 2018 +0100

    emulation: Make OSC replies with same terminator as request
    
    When replying to an OSC request with an OSC reply, use
    the same string terminator (ST or BEL) as the request.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722446
    https://gitlab.gnome.org/GNOME/vte/issues/65

 src/parser-glue.hh |  2 ++
 src/vte.cc         | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/parser-glue.hh b/src/parser-glue.hh
index c07b0be3..ab495c4f 100644
--- a/src/parser-glue.hh
+++ b/src/parser-glue.hh
@@ -477,6 +477,8 @@ public:
         SequenceBuilder& operator= (SequenceBuilder const&) = delete;
         SequenceBuilder& operator= (SequenceBuilder&&) = delete;
 
+        inline constexpr unsigned int type() const noexcept { return m_seq.type; }
+
         inline void set_type(unsigned int type) noexcept
         {
                 m_seq.type = type;
diff --git a/src/vte.cc b/src/vte.cc
index f73594bd..323d6860 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -4115,10 +4115,22 @@ Terminal::send(vte::parser::u8SequenceBuilder const& builder,
 
 void
 Terminal::send(vte::parser::Sequence const& seq,
-                         vte::parser::u8SequenceBuilder const& builder) noexcept
-{
-        // FIXMEchpe take c1 & ST from @seq
-        send(builder, false);
+               vte::parser::u8SequenceBuilder const& builder) noexcept
+{
+        // FIXMEchpe always take c1 & ST from @seq?
+        if (seq.type() == VTE_SEQ_OSC &&
+            builder.type() == VTE_SEQ_OSC) {
+                /* If we reply to a BEL-terminated OSC, reply with BEL-terminated OSC
+                 * as well, see https://bugzilla.gnome.org/show_bug.cgi?id=722446 and
+                 * https://gitlab.gnome.org/GNOME/vte/issues/65 .
+                 */
+                send(builder, false,
+                     vte::parser::u8SequenceBuilder::Introducer::DEFAULT,
+                     seq.terminator() == 0x7 ? vte::parser::u8SequenceBuilder::ST::BEL
+                     : vte::parser::u8SequenceBuilder::ST::DEFAULT);
+        } else {
+                send(builder, false);
+        }
 }
 
 void


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