Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting in windows/linux #153

Closed
trptcolin opened this issue Jun 5, 2014 · 7 comments
Closed

Pasting in windows/linux #153

trptcolin opened this issue Jun 5, 2014 · 7 comments

Comments

@trptcolin
Copy link
Member

There's a bug report in Scala that pasting (via ctrl-v) doesn't work in Windows/Linux.

@adriaanm said (on this commit):


Could this explain why paste no longer works for our Scala REPL users now that we use jline 2.11? (See https://issues.scala-lang.org/browse/SI-8644) -- /opportunistic-cc @trptcolin


My reply:


I gather that it's only an issue for users on Linux & Windows from the comments there (I use OSX too, where command-v works).

On my Windows terminal clients (cygwin, cmd.exe, git bash), I can't find any evidence that ctrl-v works in any console app, including the shell - I always have to use the mouse, which works fine in jline master on my Windows VMs. A little googling says apparently there's an AutoHotKey script that lets you use ctrl-v, not sure if that's what people are using or if they're just surprised at ctrl-v not working by default?

On my Linux VM, the terminal uses ctrl-shift-v to paste, and that key combo also works fine for me in jline master.

The clipboard is an OS responsibility, so I'd expect the OS to be the thing sending that information down the STDIN stream. I guess I'm not getting how jline can help? Right now the only helpful possibility I'm seeing is the new KillRing/yank functionality that'll go out with the next release.

It looks like QUOTED_INSERT is the Operation that gets fired on Ctrl-V, for what it's worth.


@trptcolin
Copy link
Member Author

I'm closing this for now since it seems outside the scope of what jline can do, but please re-open if I'm wrong!

Thanks for letting us know, @adriaanm!

@bjornregnell
Copy link

it seems outside the scope of what jline can do

Well, it could do it before: Pasting with ctrl+v used to work just fine before with the old jline of Scala 2.10.3 but it stopped working in Scala 2.11.1. So I guess it is possible?

@nafg
Copy link

nafg commented Jun 11, 2014

"On my Linux VM, the terminal uses ctrl-shift-v to paste, and that key combo also works fine for me in jline master"

In the Scala REPL, Ctrl-V is very different than Ctrl-Shift-V. The latter essentially sends one character at a time, so it's as if you typed it. OTOH the first essentially activates the REPL's paste mode. Two differences:

  1. In paste mode you don't get a new "scala>" prompt at each line. Each line starts at the first column of the terminal. If you enter paste mode manually by typing :paste, you exit paste mode by pressing Ctrl-D. If you insert text by pressing Ctrl-V, it exits paste mode at the end of the clipboard contents. OTOH with ctrl-shift-v you see the scala> prompt for each line, just like when you type.
  2. In paste mode the entire input is processed together, so for instance line 1 could reference a class defined on line 2, and companions are recognized. In regular mode, each line needs to be valid on its own, and is wrapped in its own template.

@trptcolin
Copy link
Member Author

<ctrl-v> means a specific thing in readline (along w/ <ctrl-q>): the next entered text will be entered literally (quoted-insert). See http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html#SEC16

I see that we still have the old paste() implementation available, so I'm open to discussion if there's a patch that adds this to ConsoleReader.readLine()

case PASTE_FROM_CLIPBOARD:
    success = paste();
    break;

and any other required machinery so that consumers, if they like, can re-map <ctrl-v> to do this paste handling. If we can make this work in a cross-platform way, great. I don't think it should be the default, though, since it's not a readline feature.

A quick tweak locally appears to say that (at least on OSX, under zsh and bash) <ctrl-v> will never reach jline, unless I hit it twice (the first one to escape the second one). It's also annoying that since it uses AWT, it steals focus from the terminal and puts a java app in my cmd-tab menu. I'd want both of those issues to be addressed in a hypothetical implementation for this.

@trptcolin trptcolin reopened this Jun 11, 2014
@bjornregnell
Copy link

It would be really great if the old ctrl+v feature could be reimplemented. Was the old implementation behaving consistently across platforms? (I got the impression that ctrl+v "just worked" before on all platforms.)

@trptcolin
Copy link
Member Author

Another thought for a patch is to fix #149 and add a sample triggered action for the clipboard-accessing paste behavior that people could use (and Scala could wire up for this use case so end users don't need to know about it).

I'm kind of liking this idea because it makes explicit the fact that reaching into the clipboard isn't a typical readline feature, and puts the AWT dependencies outside of the core ConsoleReader. Of course since ConsoleReader.paste() is public, we'd at least need to leave some delegation in place.

gnodet added a commit that referenced this issue Jul 22, 2015
Add support for the paste-from-clipboard operation, even if there’s no default mapping for it.
Partial fix for #153
@gnodet
Copy link
Member

gnodet commented Jul 22, 2015

With the above 08ee342 fix, it is now simply a matter of adding a key mapping C-V: paste-from-clipboard in the inputrc file given to jline.

@gnodet gnodet closed this as completed Jul 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants