|
PluginReadline
The readline plugin provides a minimal API for reading user input from the keyboard. It can be configured (via compile-time options) to use GNU Readline, BSD Editline, or plain stdin as its input source. The programming interface is the same, however. Getting the pluginThis plugin, due to its licensing (mixed-license with a GPL component), is stored as an add-on in a separate source tree. It's in the extra-plugins Subversion tree. Visit this page for instructions: http://code.google.com/p/v8-juice/source/checkout and check out the extra-plugins directory instead of trunk. Building/installingSee the plugins page for build instructions. Example usagevar my = {fn:"my.history"};
loadPlugin('v8-juice-readline',my);
if( my.readline.loadHistory(my.fn) ) {
print("Loaded history file",my.fn);
} else {
print("Couldn't load history file",my.fn);
}
var s;
while( undefined != (s = my.readline.read("Enter something (Ctrl-D quits): ")) )
{
print("Result:",s);
}
print(""); // kludge: ensure a newline after Ctrl-D
print("Done!");
// history will be auto-saved at shutdownThat demonstrates all of the functions except for clearHistory(), which clears the history list, and saveHistory(), which saves the history. If saveHistory() is passed no filename then it uses the name which was passed to loadHistory(). Points of note:
|