.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.if !\nF .nr F 0
.if \nF>0 \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    if !\nF==2 \{\
.        nr % 0
.        nr F 2
.    \}
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Term::ReadLine 3pm"
.TH Term::ReadLine 3pm "2025-07-28" "perl v5.26.3" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Term::ReadLine \- Perl interface to various "readline" packages.
If no real package is found, substitutes stubs instead of basic functions.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 10
\&  use Term::ReadLine;
\&  my $term = Term::ReadLine\->new(\*(AqSimple Perl calc\*(Aq);
\&  my $prompt = "Enter your arithmetic expression: ";
\&  my $OUT = $term\->OUT || \e*STDOUT;
\&  while ( defined ($_ = $term\->readline($prompt)) ) {
\&    my $res = eval($_);
\&    warn $@ if $@;
\&    print $OUT $res, "\en" unless $@;
\&    $term\->addhistory($_) if /\eS/;
\&  }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This package is just a front end to some other packages. It's a stub to
set up a common interface to the various ReadLine implementations found on
\&\s-1CPAN\s0 (under the \f(CW\*(C`Term::ReadLine::*\*(C'\fR namespace).
.SH "Minimal set of supported functions"
.IX Header "Minimal set of supported functions"
All the supported functions should be called as methods, i.e., either as
.PP
.Vb 1
\&  $term = Term::ReadLine\->new(\*(Aqname\*(Aq);
.Ve
.PP
or as
.PP
.Vb 1
\&  $term\->addhistory(\*(Aqrow\*(Aq);
.Ve
.PP
where \f(CW$term\fR is a return value of Term::ReadLine\->\fInew()\fR.
.ie n .IP """ReadLine""" 12
.el .IP "\f(CWReadLine\fR" 12
.IX Item "ReadLine"
returns the actual package that executes the commands. Among possible
values are \f(CW\*(C`Term::ReadLine::Gnu\*(C'\fR, \f(CW\*(C`Term::ReadLine::Perl\*(C'\fR,
\&\f(CW\*(C`Term::ReadLine::Stub\*(C'\fR.
.ie n .IP """new""" 12
.el .IP "\f(CWnew\fR" 12
.IX Item "new"
returns the handle for subsequent calls to following
functions. Argument is the name of the application. Optionally can be
followed by two arguments for \f(CW\*(C`IN\*(C'\fR and \f(CW\*(C`OUT\*(C'\fR filehandles. These
arguments should be globs.
.ie n .IP """readline""" 12
.el .IP "\f(CWreadline\fR" 12
.IX Item "readline"
gets an input line, \fIpossibly\fR with actual \f(CW\*(C`readline\*(C'\fR
support. Trailing newline is removed. Returns \f(CW\*(C`undef\*(C'\fR on \f(CW\*(C`EOF\*(C'\fR.
.ie n .IP """addhistory""" 12
.el .IP "\f(CWaddhistory\fR" 12
.IX Item "addhistory"
adds the line to the history of input, from where it can be used if
the actual \f(CW\*(C`readline\*(C'\fR is present.
.ie n .IP """IN"", ""OUT""" 12
.el .IP "\f(CWIN\fR, \f(CWOUT\fR" 12
.IX Item "IN, OUT"
return the filehandles for input and output or \f(CW\*(C`undef\*(C'\fR if \f(CW\*(C`readline\*(C'\fR
input and output cannot be used for Perl.
.ie n .IP """MinLine""" 12
.el .IP "\f(CWMinLine\fR" 12
.IX Item "MinLine"
If argument is specified, it is an advice on minimal size of line to
be included into history.  \f(CW\*(C`undef\*(C'\fR means do not include anything into
history. Returns the old value.
.ie n .IP """findConsole""" 12
.el .IP "\f(CWfindConsole\fR" 12
.IX Item "findConsole"
returns an array with two strings that give most appropriate names for
files for input and output using conventions \f(CW"<$in"\fR, \f(CW">out"\fR.
.Sp
The strings returned may not be useful for 3\-argument \fIopen()\fR.
.IP "Attribs" 12
.IX Item "Attribs"
returns a reference to a hash which describes internal configuration
of the package. Names of keys in this hash conform to standard
conventions with the leading \f(CW\*(C`rl_\*(C'\fR stripped.
.ie n .IP """Features""" 12
.el .IP "\f(CWFeatures\fR" 12
.IX Item "Features"
Returns a reference to a hash with keys being features present in
current implementation. Several optional features are used in the
minimal interface: \f(CW\*(C`appname\*(C'\fR should be present if the first argument
to \f(CW\*(C`new\*(C'\fR is recognized, and \f(CW\*(C`minline\*(C'\fR should be present if
\&\f(CW\*(C`MinLine\*(C'\fR method is not dummy.  \f(CW\*(C`autohistory\*(C'\fR should be present if
lines are put into history automatically (maybe subject to
\&\f(CW\*(C`MinLine\*(C'\fR), and \f(CW\*(C`addhistory\*(C'\fR if \f(CW\*(C`addhistory\*(C'\fR method is not dummy.
.Sp
If \f(CW\*(C`Features\*(C'\fR method reports a feature \f(CW\*(C`attribs\*(C'\fR as present, the
method \f(CW\*(C`Attribs\*(C'\fR is not dummy.
.SH "Additional supported functions"
.IX Header "Additional supported functions"
Actually \f(CW\*(C`Term::ReadLine\*(C'\fR can use some other package, that will
support a richer set of commands.
.PP
All these commands are callable via method interface and have names
which conform to standard conventions with the leading \f(CW\*(C`rl_\*(C'\fR stripped.
.PP
The stub package included with the perl distribution allows some
additional methods:
.ie n .IP """tkRunning""" 12
.el .IP "\f(CWtkRunning\fR" 12
.IX Item "tkRunning"
makes Tk event loop run when waiting for user input (i.e., during
\&\f(CW\*(C`readline\*(C'\fR method).
.ie n .IP """event_loop""" 12
.el .IP "\f(CWevent_loop\fR" 12
.IX Item "event_loop"
Registers call-backs to wait for user input (i.e., during \f(CW\*(C`readline\*(C'\fR
method).  This supersedes tkRunning.
.Sp
The first call-back registered is the call back for waiting.  It is
expected that the callback will call the current event loop until
there is something waiting to get on the input filehandle.  The parameter
passed in is the return value of the second call back.
.Sp
The second call-back registered is the call back for registration.  The
input filehandle (often \s-1STDIN,\s0 but not necessarily) will be passed in.
.Sp
For example, with AnyEvent:
.Sp
.Vb 10
\&  $term\->event_loop(sub {
\&    my $data = shift;
\&    $data\->[1] = AE::cv();
\&    $data\->[1]\->recv();
\&  }, sub {
\&    my $fh = shift;
\&    my $data = [];
\&    $data\->[0] = AE::io($fh, 0, sub { $data\->[1]\->send() });
\&    $data;
\&  });
.Ve
.Sp
The second call-back is optional if the call back is registered prior to
the call to \f(CW$term\fR\->readline.
.Sp
Deregistration is done in this case by calling event_loop with \f(CW\*(C`undef\*(C'\fR
as its parameter:
.Sp
.Vb 1
\&    $term\->event_loop(undef);
.Ve
.Sp
This will cause the data array ref to be removed, allowing normal garbage
collection to clean it up.  With AnyEvent, that will cause \f(CW$data\fR\->[0] to
be cleaned up, and AnyEvent will automatically cancel the watcher at that
time.  If another loop requires more than that to clean up a file watcher,
that will be up to the caller to handle.
.ie n .IP """ornaments""" 12
.el .IP "\f(CWornaments\fR" 12
.IX Item "ornaments"
makes the command line stand out by using termcap data.  The argument
to \f(CW\*(C`ornaments\*(C'\fR should be 0, 1, or a string of a form
\&\f(CW"aa,bb,cc,dd"\fR.  Four components of this string should be names of
\&\fIterminal capacities\fR, first two will be issued to make the prompt
standout, last two to make the input line standout.
.ie n .IP """newTTY""" 12
.el .IP "\f(CWnewTTY\fR" 12
.IX Item "newTTY"
takes two arguments which are input filehandle and output filehandle.
Switches to use these filehandles.
.PP
One can check whether the currently loaded ReadLine package supports
these methods by checking for corresponding \f(CW\*(C`Features\*(C'\fR.
.SH "EXPORTS"
.IX Header "EXPORTS"
None
.SH "ENVIRONMENT"
.IX Header "ENVIRONMENT"
The environment variable \f(CW\*(C`PERL_RL\*(C'\fR governs which ReadLine clone is
loaded. If the value is false, a dummy interface is used. If the value
is true, it should be tail of the name of the package to use, such as
\&\f(CW\*(C`Perl\*(C'\fR or \f(CW\*(C`Gnu\*(C'\fR.
.PP
As a special case, if the value of this variable is space-separated,
the tail might be used to disable the ornaments by setting the tail to
be \f(CW\*(C`o=0\*(C'\fR or \f(CW\*(C`ornaments=0\*(C'\fR.  The head should be as described above, say
.PP
If the variable is not set, or if the head of space-separated list is
empty, the best available package is loaded.
.PP
.Vb 2
\&  export "PERL_RL=Perl o=0" # Use Perl ReadLine sans ornaments
\&  export "PERL_RL= o=0"     # Use best available ReadLine sans ornaments
.Ve
.PP
(Note that processing of \f(CW\*(C`PERL_RL\*(C'\fR for ornaments is in the discretion of the 
particular used \f(CW\*(C`Term::ReadLine::*\*(C'\fR package).
