轻量级GNU readline替代 [英] Lightweight GNU readline alternative

查看:124
本文介绍了轻量级GNU readline替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找GNU readline替代方案.它具有很多功能,但只有其中几个对我有用,如下所述-

I am looking for a GNU readline alternative. It comes with a lot of features but only couple of them are useful to me as explained below -

我正在开发一个交互式命令提示符应用程序(显示提示符并接受要运行的下一个用户命令).我想为提示实现一些编辑和历史记录功能.因此,当用户按下UP键时,它应该显示最后一个运行命令.另外,如果用户需要编辑任何错字或命令开关等,则应该能够使用箭头键进行导航.

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. Also, user should be able to navigate using arrow keys if he need to edit any typo or command switches etc.

在Windows上已经存在类似的东西,如果您使用fgetsscanf在cmd提示符下获取输入,则它已经维护了历史记录,还可以让您进行编辑.

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.

在Linux上有不错的选择吗?

Is there a good option available on linux?

推荐答案

我认为这是一个令人钦佩的目标:-)

This is an admirable goal I think :-)

也许 Linenoise tecla 符合要求吗?

其中可能最广泛使用libedit-例如postgreqsql客户端外壳和用于Kerberos和ntp的各种BSD实用程序(尽管对于上游源而言,由于在Linux上广泛使用libreadline,它可能不是默认的行编辑库).如果您阅读了其中的一些参考资料并进行了进一步的研究,将会发现libedit/editline的版本略有不同.

Of those probably libedit is the most widely used - e.g. 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). 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.

为您的项目打起精神,祝您好运.

Cheers, and good luck with your project.

这篇关于轻量级GNU readline替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆