php-doc-en/functions/readline.xml
Hartmut Holzgraefe 7839d91186 added DO NOT EDIT noctice to old english functions files,
removing the others


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78562 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-17 19:58:46 +00:00

259 lines
7.9 KiB
XML

<!-- D O N O T E D I T T H I S F I L E ! ! !
it is still here for historical reasons only
(as translators may need to check old revision diffs)
if you want to change things documented in this file
you should now edit the files found under en/reference
instead -->
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.20 $ -->
<reference id="ref.readline">
<title>GNU Readline</title>
<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.
</simpara>
<section id="readline.requirements">
<title>Requirements</title>
<para>
To use the readline functions, you need to install libreadline and
compile PHP with support for readline.
</para>
</section>
<section id="readline.installation">
<title>Installation</title>
<para>
To compile PHP with readline support, you need to configure PHP
<option role="configure">--with-readline</option> after you've installed
libreadline. You can find libreadline on the home page of the GNU
Readline project, at <ulink url="&url.readline;">&url.readline;</ulink>.
It's maintained by Chet Ramey, who's also the author of Bash.
</para>
</section>
<section id="readline.configuration">
<title>Runtime Configuration</title>
&no.config;
</section>
<section id="readline.resources">
<title>Resource types</title>
&no.resource;
</section>
<section id="readline.constants">
<title>Predefined constants</title>
&no.constants;
</section>
</partintro>
<refentry id="function.readline">
<refnamediv>
<refname>readline</refname>
<refpurpose>Reads a line</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>readline</methodname>
<methodparam choice="opt"><type>string</type><parameter>prompt</parameter></methodparam>
</methodsynopsis>
<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>.
</para>
<example>
<title><function>readline</function></title>
<programlisting role="php">
<![CDATA[
//get 3 commands from user
for ($i=0; $i < 3; $i++) {
$line = readline ("Command: ");
readline_add_history ($line);
}
//dump history
print_r (readline_list_history());
//dump variables
print_r (readline_info());
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<refentry id="function.readline-add-history">
<refnamediv>
<refname>readline_add_history</refname>
<refpurpose>Adds a line to the history</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>readline_add_history</methodname>
<methodparam><type>string</type><parameter>line</parameter></methodparam>
</methodsynopsis>
<para>
This function adds a line to the command line history.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-clear-history">
<refnamediv>
<refname>readline_clear_history</refname>
<refpurpose>Clears the history</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>readline_clear_history</methodname>
<void/>
</methodsynopsis>
<para>
This function clears the entire command line history.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-completion-function">
<refnamediv>
<refname>readline_completion_function</refname>
<refpurpose>Registers a completion function</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>readline_completion_function</methodname>
<methodparam><type>string</type><parameter>line</parameter></methodparam>
</methodsynopsis>
<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.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-info">
<refnamediv>
<refname>readline_info</refname>
<refpurpose>Gets/sets various internal readline variables</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>mixed</type><methodname>readline_info</methodname>
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>newvalue</parameter></methodparam>
</methodsynopsis>
<para>
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.
</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.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-list-history">
<refnamediv>
<refname>readline_list_history</refname>
<refpurpose>Lists the history</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>readline_list_history</methodname>
<void/>
</methodsynopsis>
<para>
This function returns an array of the entire command line
history. The elements are indexed by integers starting at zero.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-read-history">
<refnamediv>
<refname>readline_read_history</refname>
<refpurpose>Reads the history</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>readline_read_history</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
This function reads a command history from a file.
</para>
</refsect1>
</refentry>
<refentry id="function.readline-write-history">
<refnamediv>
<refname>readline_write_history</refname>
<refpurpose>Writes the history</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>readline_write_history</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
This function writes the command history to a file.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->