gnuplot 交互式终端中的 Home 和 End 键不移动光标

gnuplot 交互式终端中的 Home 和 End 键不移动光标

当与 gnuplot 交互工作时,home 和 end 键不会将光标移动到行的开头和结尾,而是分别产生字符“OH”和“OF”。这是什么原因,如何让光标移动到命令的开头和结尾?

答案1

GNU 和 Ubuntu/Debian 之间存在有关 readline 库的许可问题。通过此修复,可以从源代码编译 gnuplot 并使用以下键:HOME、END、CTRL+左箭头、CTRL+右箭头

这不会创建 OH、OF、1;5D 或 1;3D 或其他任何形式。

./configure --with-readline=/lib/x86_64-linux-gnu/libreadline.so.6
make
make install

旁注:

./configure --with-readline=gnu

不适合我。

答案2

这是关于移动到行首和行尾的部分答案。看帮助行编辑,了解 gnuplot 中的正确快捷键。因此,使用CtrlA移动到行首和CtrlE行尾。

      `Line-editing`:
       ^B    moves back a single character.
       ^F    moves forward a single character.
       ^A    moves to the beginning of the line.
       ^E    moves to the end of the line.
       ^H    and DEL delete the previous character.
       ^D    deletes the current character.
       ^K    deletes from current position to the end of line.
       ^L,^R redraws line in case it gets trashed.
       ^U    deletes the entire line.
       ^W    deletes from the current word to the end of line.

我无法解释为什么它显示在您的情况下显示的内容,但是,链接页面显示(此消息似乎与版本相关)

(中的 readline 函数gnuplot与 GNU Bash 和 GNU Emacs 中使用的 readline 不同。如果需要 GNU 版本,可以选择它而不是gnuplot编译时的版本。)

答案3

gnuplot 不是一个 GNU 项目,尽管它从那时起就以该名称进行开发1986年,回顾 GNU 宣言(1985)发布后不久。实际的 GNU项目开始于那个时代的某个时候(我见过各种日期)。

由于不是 GNU 项目,因此没有理由使用 GNU 许可证。确实,版权声明是允许的,但对修改和联系信息有一些限制:

 Permission to modify the software is granted, but not the right to
 distribute the complete modified source code.  Modifications are to be
 distributed as patches to the released version.  Permission to distribute
 binaries produced by compiling modified sources is granted, provided you
   1. distribute the corresponding source modifications from the released
      version in the form of a patch file along with the binaries,
   2. add special version identification to distinguish your version in
      addition to the base release version number,
   3. provide your name and address as the primary contact for the support
      of your modified version, and
   4. retain our contact information in regard to use of the base software.
 Permission to distribute the released version of the source code along
 with corresponding source modifications in the form of a patch file is
 granted with same provisions 2 through 4 for binary distributions.

GPL 禁止任何限制(超出其本身的限制,包括事后动态链接解释),因此不允许使用 readline(当前为 GPLv3)为 gnuplot 分发可执行文件。

这个问题并不是 Debian 及其衍生产品(例如 Ubuntu)特有的,但 Debian 在许可方面恰好比其他一些组织更加谨慎。README.Debiangnuplot 注释的文件

Yes, the built in readline of gnuplot is bad. However, libreadline
cannot be used instead because it is licensed under the GPL, whereas
gnuplot has special licenses (patches only). Distribution of those
programs linked together is legally impossible but you may rebuild
your own custom package with readline. Please don't file bugs telling   
me to use libreadline in gnuplot...

Debian 将 gnuplot 与 libedit 链接,描述于詹姆斯·比格勒的页面作为

libedit 是 GNU readline 命令行编辑功能的替代或替代。 libedit 是根据 BSD 风格许可证发布的,因此您可以在您的专有代码中使用它。

对于简单的事情,比如问题中提出的问题,libedit 就足够了。但它读取的是不同的配置文件而不是 readline (~/.editrc而不是.inputrc)。相关的手册页会有所帮助(您可能有libedit-dev 包安装):

OP 面临的直接问题是无法识别 home/end 键。 libedit 尝试从终端数据库获取相关信息(与 readline 一样),但是某些 xterm 相似项与 xterm 的功能键不匹配,并且在任何情况下 readline 都不理解大约一半的终端描述使用应用程序键盘设置(一半的时间是错误的)。

人们没有改进库,而是通过将设置粘贴到.inputrc文件中来支撑事物。使用 libedit,您可以重新开始处理该.editrc文件。

进一步阅读:

答案4

这对我有用,但只有在安装之后读取行开发:

./configure --with-readline=gnu
make
make install

您可以检查LDD链接正确的 readline 库。

相关内容