Class Stdio.Readline

Inheritance graph
Stdio.Readline Tools.Install.Readline

Terminal-aware line-based input.


// Get a Readline object connected to Stdio.stdin/Stdio.stdout. Stdio.Readline readline = Stdio.Readline();

// Enable history. string|zero history_dump = Stdio.read_file(history_file); if (history_dump) { readline->enable_history(history_dump/"\n"); } else { readline->enable_history(512); // 512 lines of history. }

// Add a completion handler. readline->get_input_controller()->bind("\t", handle_completions);

// Output some message. readline->message("Welcome to some application.\n");

// Set a prompt. readline->set_prompt("> ");

// Read some input. string command = readline->read();

// Save the history. Stdio.write_file(history_file, readline->get_history()->encode());

See also

enable_history(), get_history(), get_input_controller(), message(), read(), set_prompt()

Method create

Stdio.Readline Stdio.Readline(object|void infd, object|string|void interm, object|void outfd, object|string|void outterm)


Creates a Readline object, that takes input from infd and has output on outfd.

Parameter infd

Defaults to Stdio.stdin.

Parameter interm

Defaults to Stdio.Terminfo.getTerm().

Parameter outfd

Defaults to infd, unless infd is 0, in which case outfd defaults to Stdio.stdout.

Parameter outterm

Defaults to interm.