Thanks for the very comprehensive answer, William!

There are a few jlab issues asking about this (including
https://github.com/jupyterlab/jupyterlab/issues/4143,
https://github.com/jupyterlab/jupyterlab/issues/3011,
https://github.com/jupyterlab/jupyterlab/issues/1204,
https://github.com/jupyterlab/jupyterlab/issues/1146#issuecomment-394686488).
I'm going to point at least #1146 to your comment.

Jason


On Thu, Sep 20, 2018 at 1:24 PM William Stein <wst...@gmail.com> wrote:

> Hi,
>
> Jupyter (and Jupyter Lab) uses xterm.js to implement their terminal:
> https://github.com/xtermjs/xterm.js
> I've been looking into xterm.js a lot this week since I'm currently
> rewriting CoCalc to xterm.js instead of term.js.
>
> (NOTE term.js -- see https://github.com/chjj/term.js --  is Fabrice
> Bellard's terminal in Javascript so he could use his emscriptem linux
> in a browser, and xterm.js is a fork of term.js with all the code
> refactored and rewritten in Typescript, and with an additional Canvas
> renderer, a plugin system, etc., etc. I hadn't looked at xterm.js much
> and have been developing term.js a little over the last 5 years in
> parallel.)
>
> As far as I can tell, xterm.js is pretty amazing.  However,  I just
> searched through the xterm.js source code
> for a while, and it looks to me like "the copy/paste via the keyboard
> terminal problem" is not really fully solved in xterm.js itself.
> There's also no issue in the xterm.js issue tracker about implementing
> copy so maybe I'm missing something.  There's discussion claiming this
> is not a problem at all: "Copy & paste from and to xterm should just
> work fine without any extra code using CTRL+C and CTRL+V keyboard
> shortcuts."
> (see
> https://github.com/xtermjs/xterm.js/issues/1411#issuecomment-383916953)
>
> This is the sort of thing you would think if you don't do cross
> platform testing... e.g., you only use a mac, but is a big  problem
> for people using Linux (me) or maybe Windows.   Anyway, it looks to me
> like the only way copy can happen is via the code here:
>
> https://github.com/xtermjs/xterm.js/blob/master/src/Terminal.ts#L546
>
> This binds to the copy event I think of the hidden textarea.  So copy
> (and paste) via *right click and a menu* work fine in Windows and
> Linux with xterm.js.  However, copy via "Control+C" doesn't seem to
> trigger copy on the terminal, since that gets interpreted elsewhere,
> and results in an interrupt signal in bash.
>
> It's an interesting  UX problem how to deal with this, and most
> terminals on Windows/Linux have their own solution.   For example, the
> browser-based one in ChromeOS uses Control+Shift+C (and
> Control+Shift+V) for copy/paste, and also I think *just* highlighting
> causes the copy to happen in ChromeOS, even if you don't hit keys.  I
> think this control+shift+v choice is pretty common in Linux. VSCode
> also integrates xterm.js, and they
> have solved this problem as explained here:
>
>
> https://code.visualstudio.com/docs/editor/integrated-terminal#_copy-paste
>
> where they have control+shift+c on linux, control+c on Windows, and
> Cmd+c on OS X.  I didn't look into the vscode/xterm.js integration
> code to see how they did this (in electron/chromium).
>
> In CoCalc, with term.js, I took a different approach.  I made it so
> Control+C behaves as usual (sending an interrupt, say) if no text is
> selected.  If you select text and then hit Control+C then it does
> copy.   I've been using this for years, and I think it makes a ton of
> sense.  On the other hand, it's just a UX solution I completely made
> up, and I've never seen it anywhere else.  Our users don't complain
> about it -- they expect control+c to copy after all when they are
> doing a copy, and they expect it to interrupt when they are trying to
> stop something, and just never think about it.  Either I implement
> this same thing somehow for xterm.js, or I have to just stick with old
> term.js (which I really don't want to do).
>
>  -- William
>
> On Wed, Sep 19, 2018 at 3:33 PM, 'Tyler Erickson' via Project Jupyter
> <jupyter@googlegroups.com> wrote:
> > The copy and paste keyboard strokes are different depending on your
> > operating system.
> >
> > What operating system / browser are you using?
> >
> >
> > On Tuesday, September 18, 2018 at 3:11:16 AM UTC-7, 铁龙国 wrote:
> >>
> >> Jupyter lab Terminal can't copy and paste!
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Project Jupyter" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to jupyter+unsubscr...@googlegroups.com.
> > To post to this group, send email to jupyter@googlegroups.com.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/jupyter/493eb17e-ec01-4e7b-b03d-325e036be092%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> William (http://wstein.org)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+unsubscr...@googlegroups.com.
> To post to this group, send email to jupyter@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/CACLE5GACzU7dU5gKE-K0USguxdcD4TD_XcQ3S-Rt5oa9YM121w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAPDWZHxbZMK0voK6LuqbvVQBAFJhqi4PE0BufVHE%3D%2BfRW5qodg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to