How can I use the up / down history keys in the SWI-Prolog console?

When I push up / down, I should get - like unix - the previous commands, but instead get:

Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 6.0.0) Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). 1 ?- ['nc']. % nc compiled into nc 0.00 sec, 84 clauses true. 2 ?- listing. true. 

(I press the Up key to return the listing command .. then ..)

 3 ?- **^[[A** 

I compiled from the source without any additional "configure" or "make" options.

In a previous version of the swi prolog, I found that this worked erratically. Sometimes the console got into a mess, and I had to press ".". to make it finish the current line, then the story will start working again.

But this latest version .. nada .. I am using ubuntu linux, bash shell. This is like an os environmental issue or bug in swi-prolog. Keys / arrow history works great on Linux level.

+4
source share
3 answers

I do not know about swi-proog in particular, but I used rlwrap to solve this problem for other interpreters that didn The function is built into the editing functions. It is very easy to use; you just run the rlwrap command, not run it directly.

+1
source

You need to install the libreadline-dev package on your host before compiling swiprolog for the shooter to work.

+1
source

This is actually not an answer, rather a workaround, just in case someone else has a problem.

Despite the fact that the up / down arrow keys are displayed in 6.0.0 (and .1 just tried), the โ€œcommand historyโ€ based on the history works fine, so you can get the previous commands this way.

eg.

 3 ?- !!. listing. true. 4 ?- L='fred', integer(L). false. 5 ?- !!. L='fred', integer(L). false. 6 ?- h. 1 listing. 2 listing. 3 listing. 4 L='fred', integer(L). 5 L='fred', integer(L). 6 ?- !3. listing. true. 
0
source

Source: https://habr.com/ru/post/1398582/


All Articles