fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.95k stars 286 forks source link

Cannot copy & paste from cell into xterm on Linux with X11 #2358

Open mgkuhn opened 1 year ago

mgkuhn commented 1 year ago

X11 Window System applications normally use two separate selections for copy & pasting text between windows: PRIMARY is whatever text has most recently been selected with the mouse, and CLIPBOARD is what has most recently been copied with Ctrl-C (in applications that support the Ctrl-XCV keys for cut/copy/paste).

In a Pluto notebook in e.g. Ubuntu Linux 20.04 running the X11 Windows System and Firefox 106, this does not work as expected in cells:

Expected behaviour: Selecting some text with the mouse from a cell should place the text into the PRIMARY selection. Afterwards, clicking the middle-mouse button in an xterm should then paste the text selected in the cell into stdin of the terminal application.

Actual behaviour: Selecting some text with the mouse from a cell does not place the selected text into the PRIMARY selection. Therefore, clicking the middle mouse-button in an xterm does not paste the text selected in the cell into the terminal application.

This problem only occurs when selecting text in cells. Selecting text from elsewhere on the notebook page correctly makes the selected text available to other applications in the PRIMARY selection. Selecting text in a cell followed by pressing Ctrl-C does correctly make the selected text available from the CLIPBOARD selection.

This is a problem for anyone who wants to copy selected text from a Pluto cell into a terminal application, such as xterm, because terminals cannot access the CLIPBOARD selection via the usual Ctrl-V key, because Ctrl-V is just one of the control codes that a terminal has to pass on to the terminal application. Terminal emulators usually can only paste the PRIMARY selection.

Simon Tatham's tool xcopy can be used to read both the PRIMARY selection (xcopy -r) and the CLIPBOARD selection (xcopy -r -b). At present, selecting text in a Pluto cell unexpectedly does not affect the output of xcopy -r.

fonsp commented 1 year ago

Related: #1141 and #649