GNU Readline
Readline
The readline functions implement an interface
to the GNU Readline library. These are functions that provide
editable command lines. An example being the way Bash allows you
to use the arrow keys to insert characters or scroll through
command history. Because of the interactive nature of this
library, it will be of little use for writing Web applications,
but may be useful when writing scripts meant to be run from a
shell.
The home page of the GNU Readline project is
&url.readline;. It's maintained
by Chet Ramey, who's also the author of Bash.
readline
Reads a line
Description
string readline
string
prompt
This function returns a single string from the user. You may
specify a string with which to prompt the user. The line
returned has the ending newline removed. You must add this line
to the history yourself using
readline_add_history.
readline
readline_add_history
Adds a line to the history
Description
void readline_add_history
string line
This function adds a line to the command line history.
readline_clear_history
Clears the history
Description
bool readline_clear_history
This function clears the entire command line history.
readline_completion_function
Registers a completion function
Description
bool
readline_completion_function
string line
This function registers a completion function. You must supply
the name of an existing function which accepts a partial command
line and returns an array of possible matches. This is the same
kind of functionality you'd get if you hit your tab key while
using Bash.
readline_info
Gets/sets various internal readline variables
Description
mixed readline_info
string
varname
string
newvalue
If called with no parameters, this function returns an array of
values for all the setting readline uses. The elements will
be indexed by the following values: done, end, erase_empty_line,
library_version, line_buffer, mark, pending_input, point, prompt,
readline_name, and terminal_name.
If called with one parameter, the value of that setting is
returned. If called with two parameters, the setting will be
changed to the given value.
readline_list_history
Lists the history
Description
array readline_list_history
This function returns an array of the entire command line
history. The elements are indexed by integers starting at zero.
readline_read_history
Reads the history
Description
bool
readline_read_history
string filename
This function reads a command history from a file.
readline_write_history
Writes the history
Description
bool
readline_write_history
string filename
This function writes the command history to a file.