Enhanced readline.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@30631 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Egon Schmid 2000-08-20 16:29:46 +00:00
parent d1c75e0fee
commit 1cdf90fd04

View file

@ -1,16 +1,17 @@
<reference id="ref.readline">
<title>GNU Readline</title>
<titleabbrev>readline</titleabbrev>
<titleabbrev>Readline</titleabbrev>
<partintro>
<simpara>
The <function>readline</function> 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.
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.
</simpara>
<simpara>
The home page of the GNU Readline project is
@ -29,34 +30,34 @@
<funcsynopsis>
<funcprototype>
<funcdef>string <function>readline</function></funcdef>
<paramdef>string <parameter>
<optional>prompt</optional>
</parameter></paramdef>
<paramdef>string
<parameter><optional>prompt</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
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 <function>readline_add_history</function>.
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
<function>readline_add_history</function>.
</para>
<example>
<title><function>readline</function></title>
<programlisting role="php">
<example>
<title><function>Readline</function></title>
<programlisting role="php">
//get 3 commands from user
for($i=0; $i < 3; $i++)
{
$line = readline("Command: ");
readline_add_history($line);
for ($i=0; $i < 3; $i++) {
$line = readline ("Command: ");
readline_add_history ($line);
}
//dump history
print_r(readline_list_history());
print_r (readline_list_history());
//dump variables
print_r(readline_info());
</programlisting>
</example>
print_r (readline_info());
</programlisting>
</example>
</refsect1>
</refentry>
@ -89,7 +90,7 @@ print_r(readline_info());
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>readline_clear_history</function></funcdef>
<paramdef>void <parameter></parameter></paramdef>
<paramdef>void <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@ -107,15 +108,18 @@ print_r(readline_info());
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>readline_completion_function</function></funcdef>
<funcdef>boolean
<function>readline_completion_function</function>
</funcdef>
<paramdef>string <parameter>line</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
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.
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.
</para>
</refsect1>
</refentry>
@ -130,25 +134,25 @@ print_r(readline_info());
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>readline_info</function></funcdef>
<paramdef>string <parameter>
<optional>varname</optional>
</parameter></paramdef>
<paramdef>string <parameter>
<optional>newvalue</optional>
</parameter></paramdef>
<paramdef>string
<parameter><optional>varname</optional></parameter>
</paramdef>
<paramdef>string
<parameter><optional>newvalue</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
If called with no parameters, this function returns an array of values
for all the setting readline uses. The elements will 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 no parameters, this function returns an array of
values for all the setting readline uses. The elements will 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.
</para>
<para>
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.
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.
</para>
</refsect1>
</refentry>
@ -163,12 +167,12 @@ print_r(readline_info());
<funcsynopsis>
<funcprototype>
<funcdef>array <function>readline_list_history</function></funcdef>
<paramdef>void <parameter></parameter></paramdef>
<paramdef>void <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array of the entire command line history.
The elements are indexed by integers starting at zero.
This function returns an array of the entire command line
history. The elements are indexed by integers starting at zero.
</para>
</refsect1>
</refentry>
@ -182,7 +186,9 @@ print_r(readline_info());
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>readline_read_history</function></funcdef>
<funcdef>boolean
<function>readline_read_history</function>
</funcdef>
<paramdef>string <parameter>filename</parameter></paramdef>
</funcprototype>
</funcsynopsis>
@ -202,7 +208,9 @@ print_r(readline_info());
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>readline_write_history</function></funcdef>
<funcdef>boolean
<function>readline_write_history</function>
</funcdef>
<paramdef>string <parameter>filename</parameter></paramdef>
</funcprototype>
</funcsynopsis>