Skip to content

mosh does not transmit OSC 52 sequence to client #637

Open
@sunaku

Description

@sunaku

Similar to #549 and #552, this limitation prevents me from copying text from remote shell sessions into my local terminal via the OSC 52 escape sequence. It's also the reason I still use SSH instead of Mosh. 😱

I tried to patch this but got stuck. 😢 Any hints on how to write a string to the raw terminal device?

diff --git a/src/terminal/terminalfunctions.cc b/src/terminal/terminalfunctions.cc
index 35c8055..1983aec 100644
--- a/src/terminal/terminalfunctions.cc
+++ b/src/terminal/terminalfunctions.cc
@@ -558,6 +558,46 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb )
        * 2: set window title */
       cmd_num = OSC_string[ 0 ] - L'0';
       offset = 2;
+    } else if ( (OSC_string.size() >= 3) && (OSC_string[ 2 ] == L';') ) {
+      /* OSC of the form "\033]XX;<Pt>\007" where XX can be:
+       * 10: Change VT100 text foreground color to Pt.
+       * 11: Change VT100 text background color to Pt.
+       * 12: Change text cursor color to Pt.
+       * 13: Change mouse foreground color to Pt.
+       * 14: Change mouse background color to Pt.
+       * 15: Change Tektronix foreground color to Pt.
+       * 16: Change Tektronix background color to Pt.
+       * 17: Change highlight background color to Pt.
+       * 18: Change Tektronix cursor color to Pt.
+       * 19: Change highlight foreground color to Pt.
+       * 46: Change Log File to Pt.  (This is normally disabled by a compile-time option).
+       * 50: Set Font to Pt.
+       * 51: reserved for Emacs shell.
+       * 52: Manipulate Selection Data.
+       */
+      cmd_num = 10 * (OSC_string[ 0 ] - L'0') +
+                     (OSC_string[ 1 ] - L'0');
+      offset = 3;
+    } else if ( (OSC_string.size() >= 4) && (OSC_string[ 3 ] == L';') ) {
+      /* OSC of the form "\033]XXX;<Pt>\007" where XXX can be:
+       * 104: Reset Color Number c.
+       * 105: Reset Special Color Number c.
+       * 106: Enable/disable Special Color Number c.
+       * 110: Reset VT100 text foreground color.
+       * 111: Reset VT100 text background color.
+       * 112: Reset text cursor color.
+       * 113: Reset mouse foreground color.
+       * 114: Reset mouse background color.
+       * 115: Reset Tektronix foreground color.
+       * 116: Reset Tektronix background color.
+       * 117: Reset highlight color.
+       * 118: Reset Tektronix cursor color.
+       * 119: Reset highlight foreground color.
+       */
+      cmd_num = 100 * (OSC_string[ 0 ] - L'0') +
+                 10 * (OSC_string[ 1 ] - L'0') +
+                      (OSC_string[ 2 ] - L'0');
+      offset = 4;
     }
     bool set_icon = (cmd_num == 0 || cmd_num == 1);
     bool set_title = (cmd_num == 0 || cmd_num == 2);
@@ -569,6 +609,9 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb )

       act->handled = true;
     }
+    else {
+      // HELP ME: how can I write the OSC_string as-is to the terminal device?
+    }
   }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions