Ctrl-Backspace Not Working as Expected

87 views
Skip to first unread message

mightymalakai

unread,
Jul 4, 2019, 9:08:28 PM7/4/19
to jline-users
I've been looking at using JLine 3 to handle some completion that I want to put into an app I'm building. One thing I noticed in the limited time that I've been working on a small demo is that ctrl-backspace doesn't delete whole words. When I'm using the normal Windows 10 cmd prompt it works and so does using Java System.in, but when I use a JLine 3 LineReader ctrl-backspace only deletes a single character.

Just so it's clear, I'm talking about typing "hello world" and then pressing ctrl-backspace which changes it to "hello ". JLine 3 shows "hello worl".

Is there a way to enable ctrl-backspace functionality for deleting words, or is this a limitation?

Thanks

Guillaume Nodet

unread,
Jul 4, 2019, 9:16:21 PM7/4/19
to jline...@googlegroups.com
The default binding for the BACKWARD_KILL_WORD action are Ctrl+W, Alt+Ctrl+H, Alt+Backspace.
You can add a mapping for the same operation to Ctrl+Backspace easily. 

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jline-users/b2207551-93ab-48a4-bab4-d39a80972942%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mightymalakai

unread,
Jul 4, 2019, 11:19:10 PM7/4/19
to jline-users
The following worked like a charm once I figured out how you properly add key bindings. Thanks!

KeyMap<Binding> main = lineReader.getKeyMaps().get(LineReader.MAIN);
main.bind(new Reference(LineReader.BACKWARD_KILL_WORD), KeyMap.ctrl('\u0008'));



On Thursday, July 4, 2019 at 9:16:21 PM UTC-4, gnodet wrote:
The default binding for the BACKWARD_KILL_WORD action are Ctrl+W, Alt+Ctrl+H, Alt+Backspace.
You can add a mapping for the same operation to Ctrl+Backspace easily. 

On Fri, Jul 5, 2019 at 3:08 AM mightymalakai <mightym...@gmail.com> wrote:
I've been looking at using JLine 3 to handle some completion that I want to put into an app I'm building. One thing I noticed in the limited time that I've been working on a small demo is that ctrl-backspace doesn't delete whole words. When I'm using the normal Windows 10 cmd prompt it works and so does using Java System.in, but when I use a JLine 3 LineReader ctrl-backspace only deletes a single character.

Just so it's clear, I'm talking about typing "hello world" and then pressing ctrl-backspace which changes it to "hello ". JLine 3 shows "hello worl".

Is there a way to enable ctrl-backspace functionality for deleting words, or is this a limitation?

Thanks

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline...@googlegroups.com.

mightymalakai

unread,
Jul 5, 2019, 12:08:35 AM7/5/19
to jline-users
Correction, that code does work but it also makes backspace without ctrl pressed also execute BACKWARD_KILL_WORD. Not exactly useful...

Do you have any tips on how to provide the right sequence of characters for the key binding? I can't find a way to use ctrl + backspace.
Reply all
Reply to author
Forward
0 new messages