简体   繁体   English

轻量级 GNU readline 替代品

[英]Lightweight GNU readline alternative

I am looking for a GNU readline alternative.我正在寻找 GNU readline 替代方案。 It comes with a lot of features but only couple of them are useful to me as explained below -它具有很多功能,但只有几个对我有用,如下所述 -

I am working on a interactive command prompt application (display prompt and accept next user command to be run).我正在开发交互式命令提示应用程序(显示提示并接受要运行的下一个用户命令)。 I want to implement some editing and history feature for the prompt.我想为提示实现一些编辑和历史记录功能。 So when the user presses UP key it should show the last run command.因此,当用户按下 UP 键时,它应该显示上次运行的命令。 Also, user should be able to navigate using arrow keys if he need to edit any typo or command switches etc.此外,如果用户需要编辑任何拼写错误或命令开关等,他应该能够使用箭头键进行导航。

On windows something similar already exists, if you use fgets or scanf to get the input on cmd prompt it already maintains history and also lets you edit.在 windows 上已经存在类似的东西,如果您使用fgetsscanf获取 cmd 提示上的输入,它已经维护历史记录并允许您编辑。

Is there a good option available on linux? linux有没有好的选择?

This is an admirable goal I think :-) 我认为这是一个令人钦佩的目标:-)

Perhaps Linenoise , libedit/editline or tecla would fit the bill? 也许Linenoiselibedit / editlinetecla符合要求?

Of those probably libedit is the most widely used - eg postgreqsql client shell and various BSD utilities for Kerberos and ntp (although for the upstream sources it may not be the default line editing library for compilation due the to widespread use of libreadline on Linux). 其中libedit可能是最广泛使用的 - 例如postgreqsql客户端shell和Kerberos和ntp各种BSD实用程序(尽管对于上游源它可能不是用于编译的默认行编辑库,因为在Linux上广泛使用libreadline)。 There are a couple of slightly different versions of libedit/editline as you'll see if you read some of those references and do some further research. 有一些略有不同的libedit / editline版本,你会看到你是否阅读了一些这些参考文献并做了一些进一步的研究。

Cheers, and good luck with your project. 干杯,祝你的项目好运。

There is replxx , a BSD licensed alternative to readline. replxx ,BSD许可的readline替代品。 It works in Linux, BSD, Solaris and Windows. 它适用于Linux,BSD,Solaris和Windows。 It has support for features you expect from interactive console programs, namely: 它支持您期望从交互式控制台程序中获得的功能,即:

  • line editing 行编辑
  • history 历史
  • syntax highlighting 语法高亮
  • hints 提示
  • UTF-8 UTF-8
  • user defined key bindings (supporting (shift/ctrl)F1 - F12) 用户定义的键绑定(支持(shift / ctrl)F1 - F12)
  • multi-threaded print 多线程打印

I think the modern alternative of GNU Readline is Jupyter Notebook.我认为 GNU Readline 的现代替代品是 Jupyter Notebook。 The idea is that you don't create an executable that links to a line editor library.这个想法是您不创建链接到行编辑器库的可执行文件。 Instead, you should just provide the kernel and the users can choose their own notebook UI, either CUI, web based GUI, or even an IDE like VS Code.相反,您应该只提供 kernel,用户可以选择自己的笔记本 UI,CUI、基于 web 的 GUI,甚至是 IDE,如 VS Code。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM