readline

Robert Carr

API Reference

The readline module allows for basic usage of the GNU readline library, in Seed. More advanced features may be added a a later time. In order to use the readline module it must be first imported.

	readline = imports.readline;
      

readline.readline (prompt)

Prompts for one line of input on standard input using prompt as the prompt.

prompt

undefined

Returns

A string entered on standard input.


readline.bind (key, function)

Binds key to function causing the function to be invokved whenever key is pressed

key

undefined

function

undefined


readline.done ()

Indicates that readline should finish the current line, and return from readline.readline. Can be used in callbacks to implement features like multiline editing


readline.buffer()

Retrieve the current readline buffer

Returns

The current readline buffer


readline.insert (string)

Inserts string in to the current readline buffer

string

undefined

Examples

Below are several examples of using the Seed readline module. For additional resources, consult the examples/ folder of the Seed source

Example 14. 

This demonstrates a simple REPL using the readline module

readline = imports.readline;
while (1){
  try{
    eval(readline.readline("> "));
  }
  catch(e) {
    print(e.name + " " + e.message);
  }
}