Implement OSC 52 (both sides)

Following the discussion in https://github.com/contour-terminal/contour/issues/1761 , the terminal widget in the upcoming 2.0 release has an implementation of OSC 52 that behaves likes this:

  • 52 reported in DA1.
  • Applications can set any of the xterm buffers supported (c p q s 0-7). Whatever was previously set is reported back, but just on that terminal.
  • Writing to 's' and/or 'c' will copy to the Jexer clipboard, which is always available and shared across terminals.
  • Writing to 's' and/or 'c' will also copy to system clipboard, if available, and be paste-able to an outside application.
  • Reading from 's' and/or 'c' will report the contents of the Jexer clipboard, which will use the system clipboard (if available and has text). This will also overwrite that terminal's 's' and/or 'c' buffer.
  • Clearing 's' and/or 'c' will clear the Jexer clipboard. It will not clear the system clipboard -- Java limitation.
  • So basically, both copy and paste are both always enabled, always reported in DA1, and OSC 52 from the remote application will go as far as it can through terminal --> multiplexer --> end-user system.

On the application side, copying to the Jexer clipboard will copy to the system clipboard (if available) and send OSC 52 'c' to the host terminal, blindly. I currently don't check for 52 in DA1 from the host terminal because a) xterm does not send it, and b) any terminal that leaves artifacts from unhandled OSC sequences is one I want to report a defect in anyway or likely crashed earlier via their image support.

I have posted a question on the contour-terminal side to ask about the application support. Based on their feedback, I might adjust EMCA48Terminal to only send OSC 52 when 52 is present in DA1.

Edited by Autumn Lamonte