有没有一个.net库类似于GNU的readline? [英] Is there a .Net library similar to GNU readline?

查看:113
本文介绍了有没有一个.net库类似于GNU的readline?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在考虑写在C#控制台应用程序,我想结合的历史,完成和命令行编辑功能类似GNU的readline(但不一定是广泛的作为!)

I'm considering writing a console application in C# and I want to incorporate history, completion and command line editing features something like GNU readline (but not necessarily as extensive as that!)

是否有.NET现有的库,它提供了这种类型的功能?我想其中一个方案是使用互操作的服务调用GNU的readline。但有一个原生的选择吗?

Is there an existing library for .net which provides this type of functionality? I guess one option would be to use interop services to call GNU readline. But is there a native option?

推荐答案

您可能希望签米格尔·伊卡萨的的 getline.cs (在博客文章的链接被打破,code现在可以找到的这里)。根据readline的你实际需要的什么功能,它可能是足以让你的目的。

You may want to checkout Miguel de Icaza's getline.cs (the link in the blog post is broken, the code can now be found here). Depending on what features of readline you actually need, it might be enough for your purposes.

的好处是,它是所有包含在一个单一的(因此getline.cs)文件和MIT X11许可。

The nice thing is, that it is all contained in a single (hence getline.cs) file and MIT X11 licensed.

使用它是pretty的方便。

Using it is pretty easy.

如果你想给它尝试,只要下载该文件,并进行编译:

If you want to give it try, just download the file and compile it:

C:\> csc.exe /d:DEMO getline.cs 
C:\> getline.exe
shell>

的#ifdef DEMO 部分还展示了基本REPL:

The #ifdef DEMO part also shows the basic REPL:

var le = new LineEditor("whatever");
string s;

while ((s = le.Edit("my prompt> ", "")) != null)
{
    // User input from command line / prompt now in "s".
}

这篇关于有没有一个.net库类似于GNU的readline?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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