4

当我按下上/下时,我应该得到 - 就像 unix 一样 - 以前的命令,但我得到:

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.

(我按“向上”箭头键以返回“列表”命令..然后..)

3 ?- **^[[A**

我从源代码编译,没有任何额外的“配置”或“制作”参数。

在以前版本的 swi-prolog 中,我发现这个工作很随意.. 有时控制台把自己弄得一团糟,我不得不按“。” 强制它终止当前行,那么历史将再次开始工作。

但是这个最新版本.. nada.. 我使用的是 ubuntu linux,bash shell。感觉像是操作系统环境问题,或者 swi-prolog 中的错误。箭头键/历史在 linux 级别上运行良好。

4

4 回答 4

2

libreadline-dev在编译 swiprolog 以使箭头工作之前,您必须在主机上安装软件包。

于 2013-02-23T14:23:55.340 回答
2

I don't know about swi-prolog in particular, but I have used rlwrap to solve this problem for other interpreters that didn't feature built in editing features. It's very simple to use; you just have rlwrap run the command instead of running it directly.

于 2012-03-22T15:53:23.497 回答
1

这实际上不是一个答案,更多的是一种解决方法,以防万一其他人遇到同样的问题。

尽管“向上/向下”箭头键在 6.0.0(和 .1 - 刚刚尝试过)中出现故障,但“基于命令”的历史召回似乎工作正常,因此可以通过这种方式检索以前的命令。

例如。

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.
于 2012-03-01T18:13:53.690 回答
0

我在 OSX 中遇到了同样的问题,我用这种方式修复了它:

brew install rlwrap

# every time when launching swipl:
rlwrap swipl
于 2020-01-16T20:44:01.793 回答