SWI-Prolog / swipl

SWI-Prolog stable releases

Home Page:http://www.swi-prolog.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

swi-prolog

Here is how gprolog behaves:

gnu-prolog

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.

It seems that set_prolog_flag(readline, readline) does not help the situation.

swi-prolog-2

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.

Just want to confirm that this behavior is correct. This happens after setting prolog to readline.

swi-prolog-4