trptcolin / reply

REPL-y: A fitter, happier, more productive REPL for Clojure.
Eclipse Public License 1.0
337 stars 44 forks source link

Arrow keys don't work on Windows #121

Closed vmarcinko closed 10 years ago

vmarcinko commented 11 years ago

My environment is Windows 7 64-bit, and I use Leiningen 2.2.0 to start repl-y via "lein repl":from standard Windows terminal (cmd): nREPL server started on port 57197 REPL-y 0.2.0 Clojure 1.5.1

But when I try to navigate command history using up/down keys, it display some messy characters instead.

trptcolin commented 11 years ago

What are the messy characters, please?

trptcolin commented 11 years ago

The reason I'm asking for more detail, by the way, is because arrow keys work just fine on my Windows VM, on that same version of REPLy (which implies the same jline version).

You might take a look at this issue for some steps to see exactly what key codes are being emitted, and apparently not understood by jline: https://github.com/jline/jline2/issues/84 - this is the command that will build jline and print debug info:

mvn package && java -Djline.internal.Log.trace=true -cp target/jline-2.11-SNAPSHOT-tests.jar:target/jline-2.11-SNAPSHOT.jar jline.example.Example none

(You'll need to check those paths to account for the latest jline version, and maybe format the classpath using semicolons and backslashes, however Windows wants them.)

Also, if you have an .inputrc or jline.inputrc file in the directory that java finds for the user.home system property, the configurations there will take precedence over defaults.

vmarcinko commented 11 years ago

I tried the jLine testing procedure you suggested, and here is printout for all "broken" arrow keys in order up/down/left/right:

[DEBUG] Creating terminal; type=auto [DEBUG] Created Terminal: jline.AnsiWindowsTerminal@7e0df503 [DEBUG] Registering shutdown-hook: Thread[JLine Shutdown Hook,5,main] [DEBUG] Adding shutdown-hook task: jline.TerminalSupport$1@735cda3f [DEBUG] Ansi supported: true [DEBUG] Direct console: true [DEBUG] Echo enabled: false [DEBUG] NonBlockingInputStream start

"up":

prompt> [TRACE] Keystroke: 341 [TRACE] Binding: SELF_INSERT Ó[TRACE] Keystroke: 72 [TRACE] Binding: SELF_INSERT H

"down":

[TRACE] Keystroke: 341 [TRACE] Binding: SELF_INSERT Ó[TRACE] Keystroke: 80 [TRACE] Binding: SELF_INSERT P

"left":

[TRACE] Keystroke: 341 [TRACE] Binding: SELF_INSERT Ó[TRACE] Keystroke: 75 [TRACE] Binding: SELF_INSERT K

"right":

[TRACE] Keystroke: 341 [TRACE] Binding: SELF_INSERT Ó[TRACE] Keystroke: 77 [TRACE] Binding: SELF_INSERT M

timonwong commented 11 years ago

I have similar issue, the diagnostic program gives me following result:

[DEBUG] Creating terminal; type=auto
[DEBUG] Created Terminal: jline.AnsiWindowsTerminal@3612afd8
[DEBUG] Registering shutdown-hook: Thread[JLine Shutdown Hook,5,main]
[DEBUG] Adding shutdown-hook task: jline.TerminalSupport$1@70d00109
[DEBUG] Ansi supported: true
[DEBUG] Direct console: true
[DEBUG] Echo enabled: false
[DEBUG] NonBlockingInputStream start

>>>> UP

prompt> [TRACE] Keystroke: 37074
[TRACE] Binding: SELF_INSERT

>>>> DOWN

郒[TRACE] Keystroke: 37087
[TRACE] Binding: SELF_INSERT

>>>> LEFT
郟[TRACE] Keystroke: 37078
[TRACE] Binding: SELF_INSERT

>>>> RIGHT

郖[TRACE] Keystroke: 37081
[TRACE] Binding: SELF_INSERT

>>>> HOME

郙[TRACE] Keystroke: 37069
[TRACE] Binding: SELF_INSERT

>>>> END

郍[TRACE] Keystroke: 37086
[TRACE] Binding: SELF_INSERT
郞
trptcolin commented 10 years ago

Sorry to take so long getting back to y'all on this. Arrow keys are an even bigger mess across OSes and locales than I thought, it seems. I'm making a note on the upstream ticket. Thanks for reporting this!

trptcolin commented 10 years ago

To clarify what I meant by "upstream ticket", I have a note with a possible workaround on jline/jline2#100 and I'd love to hear whether you can work around this with $HOME/.inputrc or $HOME/jline.inputrc entries.

trptcolin commented 10 years ago

This will be fixed in the next release by the jline fix in https://github.com/jline/jline2/pull/134

trptcolin commented 10 years ago

Should be fixed in REPLy 0.3.1 (included in lein 2.4.2). Thanks!