jline / jline3

JLine is a Java library for handling console input.
Other
1.49k stars 218 forks source link

Home key and End key not supported #396

Closed fqliao closed 5 years ago

fqliao commented 5 years ago

Hello, pressing home key print "[1~" and end key print "[4~". Could you provide parsing for home key and end key?

mattirn commented 5 years ago

Which is the OS and terminal emulator you are using? In linux and Windows/gitbash home and end keys are working ok.

fqliao commented 5 years ago

linux

gnodet commented 5 years ago

Your key bindings should match the information given by infocmp. Check infocmp -L1 | grep -e 'key.*home' -e 'key.*end' which should gives you \E[1~ and \E[4~. If that's the case, there's a bug in jline else there's a problem in your terminal settings. If the problem is in your terminal configuration, one way around is to explicitely bind the keys:

KeyMap<Binding> keymap = reader.getKeyMaps().get(LineReader.MAIN);
keymap.bind(new Reference("beginning-of-line"), "\033[1~");
keymap.bind(new Reference("end-of-line"), "\033[4~");
fqliao commented 5 years ago

Thank you very much! It works for linux.