Mono-Readline 0.0.1 review
DownloadMono-Readline is a simple little assembly for .Net (specifically Mono) that provides support for GNU Readline support within Mono app
|
|
Mono-Readline is a simple little assembly for .Net (specifically Mono) that provides support for GNU Readline support within Mono applications.
Mono-Readline project is based on the code of Martin Baulig in the Mono debugger. I just took it and made it all nice and autoconf/automake enabled.
It's pretty straight forward, but here is a short sample program:
using Mono.ReadLine;
using System;
using System.Reflection;
public class Test {
public static void Main(string[] args) {
GnuReadLine readline = new GnuReadLine();
Console.WriteLine("Monkeys!");
string the_prompt = "This is a test: ";
string result;
while (true) {
result = readline.ReadLine(the_prompt);
if (result != null) {
readline.AddHistory(result);
} else {
break;
}
}
}
}
You should be able to compile this with mcs -r:mono.readline test.cs and get a little executable program that keeps going until you hit CTRL-D. There is lots of other fun you could do such as setting up continuation prompts and what not. Basically, most of this is ripped from Martin's code in the mono debugger.
But wait, odds are you're going to get some funky error saying it can't find the package or something like that. If that's the case, make sure you have MONO_PATH="/usr/local/lib" set before running the program and compiling. For example to compile run:
MONO_PATH="/usr/local/lib" mcs -r:mono.readline test.cs
And then to run type:
MONO_PATH="/usr/local/lib" mono test.exe
I'm not a real Mono pro, but my hope is that this could possibly help someone else out. I'm thinking that in the future I may also include a patch for IronPython.
As always, if you have comments or patches, please let me know.
Mono-Readline 0.0.1 search tags