3
votes

SBT-0.7.7 had JLine bundled in the launcher and it works OK. E.g.:

"C:\Program Files (x86)\Java\jre7\bin\java.exe"  -jar C:\scala\sbt-launch-0.7.7.jar

I can use cursor keys to navigate the command history. It does not work in SBT-0.13.5:

"C:\Program Files (x86)\Java\jre7\bin\java.exe"  -jar C:\scala\sbt_launch_135.jar

When I press cursor keys, printable characters appear instead, like "pHpP". In the target/.history file we see character codes to be "0xE0 0x48 0xE0 0x50". It is the same in Java8 and in 64-bit Java. I also tried various versions of SBT launcher and various values for jline.terminal like -Djline.terminal=jline.AnsiWindowsTerminal to no avail. I also tried -Djline.WindowsTerminal.directConsole=false -- then cursor keys perform no function at all. In all cases I can use CTRL+P and CTRL+N to navigate the history.

SBT-0.13.* loads JLine from an Ivy repository %HOMEPATH%.sbt\boot\scala-2.10.3\org.scala-sbt\sbt\0.13.1\jline-2.11.jar I inspected the source code of JLine. Version 2.10.3 has a primitive configuration file keybindings.properties and function readVirtualKey() in WindowsTerminal.java handles the cursor keys. All versions of JLine install a helper DLL in a temporary directory like %HOMEPATH%\AppData\Local\Temp\jline_.dll, which presumably works.

Why is it not working correctly? How to make the cursor keys work?

1

1 Answers

2
votes

try passing following property to sbt process, i.e.:

sbt -Dinput.encoding=Cp1252

as mentioned here