ctrl + arrow key combinations not working as expected
airglow923 opened this issue · comments
Previously opened in the wrong repository.
The ctrl
+ arrow keys (→
or ←
) combinations are used to move cursor by word in most terminals. But, it seems that these keys are not mapped in SWI-Prolog interpreter.
Below are the screen recordings to help understanding:
Here is how gprolog
behaves:
Which OS? Which terminal? On Unix-like systems systems command line editing is by default handled by libedit and optionally using GNU libreadline. The latter is activated using :- set_prolog_flag(readline, readline)
in your personal setup file provided GNU readline support is compiled into your version. The GNU readline library has a richer set of edit commands, but libedit does not compromise the SWI-Prolog BSD license and can do some stuff libreadline cannot, such as working for multiple devices at the same time and provide an interface to be programmed in Prolog (though the latter can theoretically also be done for libreadline).
The output of uname -r
:
4.19.128-microsoft-standard
The terminal currently in use is zsh 5.8
.
I'm currently using Ubuntu 20.04 on WSL 2 and haven't tested this on other platforms.
WSL is basically just slow Linux :) The shell doesn't matter. Linux itself doesn't do anything with ctrl-arrow. Some command line editors might. You can find the current command line editor using
?- current_prolog_flag(readine, X).
Both use Emacs bindings though, so the emacs bindings Alt-b (back) and Alt-f (forward) should work.
This flag only helps when used as a directive in ~/.config/swi-prolog/init.pl
. Runtime changes have no effect.
Thank you for your great help!
Adding the following line to ~/.config/swi-prolog/init.pl
:
:- set_prolog_flag(readline, readline).
resolved the issue.