Join GitHub today
Incorrect behavior on Home, End, etc. under screen #152
Reproduce steps: start screen, start Ammonite using
@ SyntaxError: found "\u001b[1~", expected Import | Prelude ~ BlockDef | Expr | End in
@ SyntaxError: found "\u001b[4~", expected Import | Prelude ~ BlockDef | Expr | End in
Same for Alt+arrow.
I can also reproduce this under
Workaround: use C-a/C-e (that is, Ctrl-a for Home, or Ctrl-e for End).
Makes total sense to me.
Background: Different terminal emulators use different escape sequences for the same commands, so native *x programs need to use libraries to interpret those escape sequences (that is, termcap/terminfo, or higher-level libraries wrapping those, such as readline or ncurses). Those libraries are hard to access on the JVM, hence I guess Ammonite doesn't use them. Indeed, escape sequences are hardcoded in
Working hypothesis: screen sends for Home/End a different escape sequence than xterm, hence Ammonite-REPL does not understand it.
Is termcap/terminfo accessible via shelling out? That would be the easiest, since we already shell out to get TTY height/width, set terminal state, etc. like we do here
If not we can add it to the list of hardcodes. I'm guessing JLine has fixed/doesn't-have this problem, so whatever they're doing probably works for us too.
(I know nothing about terminals and just hacked this stuff together, so don't take my word for anything, and feel free to tell me the code I have in terminal/ is totally wrong)
I just learned that commands
What I looked up:
But I don't fully get terminals either — I've carefully avoided entering that deep swamp
I'm also confused that you have those hardcodes and use JLine? Any chance this is also a quick hack because interfacing more to JLine is the right thing but hard to do, or is JLine too restrictive?
If you want to use JLine, go ahead!
// Ammonite on Linux/OSX and JLineWindows on Windows repl.frontEnd() = ammonite.repl.frontend.FrontEnd.JLineUnix
(Documented in http://lihaoyi.github.io/Ammonite/#Configuration)
Put it in your
I, for one, want my input-syntax-highlighting, and multiline editing capabilities, so I'm willing to beat through a few bugs to make it work =D
JLine is pretty restrictive. In particular, input highlighting and multiline editing/history are basically never going to happen. I've tried! So I went and made my own thing and left JLine as a fallback for people who like the old way
Thanks, I see.
I've seen some of the shelling out code that you pointed me to overlaps a lot with https://github.com/jline/jline2/blob/master/src/main/java/jline/UnixTerminal.java — and the interaction with
It seems like JLine has much of the logic around these terminal key things in this file https://github.com/jline/jline2/blob/92792c59a42713d55d434526ddf0361993d3f741/src/main/java/jline/internal/InfoCmp.java
The question is how can we use it to do the same thing...