Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "Term::ReadLine 3" | |
132 | .TH Term::ReadLine 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | Term::ReadLine \- Perl interface to various \f(CW\*(C`readline\*(C'\fR packages. If | |
135 | no real package is found, substitutes stubs instead of basic functions. | |
136 | .SH "SYNOPSIS" | |
137 | .IX Header "SYNOPSIS" | |
138 | .Vb 10 | |
139 | \& use Term::ReadLine; | |
140 | \& my $term = new Term::ReadLine 'Simple Perl calc'; | |
141 | \& my $prompt = "Enter your arithmetic expression: "; | |
142 | \& my $OUT = $term->OUT || \e*STDOUT; | |
143 | \& while ( defined ($_ = $term->readline($prompt)) ) { | |
144 | \& my $res = eval($_), "\en"; | |
145 | \& warn $@ if $@; | |
146 | \& print $OUT $res, "\en" unless $@; | |
147 | \& $term->addhistory($_) if /\eS/; | |
148 | \& } | |
149 | .Ve | |
150 | .SH "DESCRIPTION" | |
151 | .IX Header "DESCRIPTION" | |
152 | This package is just a front end to some other packages. At the moment | |
153 | this description is written, the only such package is Term\-ReadLine, | |
154 | available on \s-1CPAN\s0 near you. The real target of this stub package is to | |
155 | set up a common interface to whatever Readline emerges with time. | |
156 | .SH "Minimal set of supported functions" | |
157 | .IX Header "Minimal set of supported functions" | |
158 | All the supported functions should be called as methods, i.e., either as | |
159 | .PP | |
160 | .Vb 1 | |
161 | \& $term = new Term::ReadLine 'name'; | |
162 | .Ve | |
163 | .PP | |
164 | or as | |
165 | .PP | |
166 | .Vb 1 | |
167 | \& $term->addhistory('row'); | |
168 | .Ve | |
169 | .PP | |
170 | where \f(CW$term\fR is a return value of Term::ReadLine\->Init. | |
171 | .ie n .IP """ReadLine""" 12 | |
172 | .el .IP "\f(CWReadLine\fR" 12 | |
173 | .IX Item "ReadLine" | |
174 | returns the actual package that executes the commands. Among possible | |
175 | values are \f(CW\*(C`Term::ReadLine::Gnu\*(C'\fR, \f(CW\*(C`Term::ReadLine::Perl\*(C'\fR, | |
176 | \&\f(CW\*(C`Term::ReadLine::Stub\*(C'\fR. | |
177 | .ie n .IP """new""" 12 | |
178 | .el .IP "\f(CWnew\fR" 12 | |
179 | .IX Item "new" | |
180 | returns the handle for subsequent calls to following | |
181 | functions. Argument is the name of the application. Optionally can be | |
182 | followed by two arguments for \f(CW\*(C`IN\*(C'\fR and \f(CW\*(C`OUT\*(C'\fR filehandles. These | |
183 | arguments should be globs. | |
184 | .ie n .IP """readline""" 12 | |
185 | .el .IP "\f(CWreadline\fR" 12 | |
186 | .IX Item "readline" | |
187 | gets an input line, \fIpossibly\fR with actual \f(CW\*(C`readline\*(C'\fR | |
188 | support. Trailing newline is removed. Returns \f(CW\*(C`undef\*(C'\fR on \f(CW\*(C`EOF\*(C'\fR. | |
189 | .ie n .IP """addhistory""" 12 | |
190 | .el .IP "\f(CWaddhistory\fR" 12 | |
191 | .IX Item "addhistory" | |
192 | adds the line to the history of input, from where it can be used if | |
193 | the actual \f(CW\*(C`readline\*(C'\fR is present. | |
194 | .ie n .IP """IN""\fR, $\f(CW""OUT""" 12 | |
195 | .el .IP "\f(CWIN\fR, $\f(CWOUT\fR" 12 | |
196 | .IX Item "IN, $OUT" | |
197 | return the filehandles for input and output or \f(CW\*(C`undef\*(C'\fR if \f(CW\*(C`readline\*(C'\fR | |
198 | input and output cannot be used for Perl. | |
199 | .ie n .IP """MinLine""" 12 | |
200 | .el .IP "\f(CWMinLine\fR" 12 | |
201 | .IX Item "MinLine" | |
202 | If argument is specified, it is an advice on minimal size of line to | |
203 | be included into history. \f(CW\*(C`undef\*(C'\fR means do not include anything into | |
204 | history. Returns the old value. | |
205 | .ie n .IP """findConsole""" 12 | |
206 | .el .IP "\f(CWfindConsole\fR" 12 | |
207 | .IX Item "findConsole" | |
208 | returns an array with two strings that give most appropriate names for | |
209 | files for input and output using conventions \f(CW"<$in"\fR, \f(CW">out"\fR. | |
210 | .IP "Attribs" 12 | |
211 | .IX Item "Attribs" | |
212 | returns a reference to a hash which describes internal configuration | |
213 | of the package. Names of keys in this hash conform to standard | |
214 | conventions with the leading \f(CW\*(C`rl_\*(C'\fR stripped. | |
215 | .ie n .IP """Features""" 12 | |
216 | .el .IP "\f(CWFeatures\fR" 12 | |
217 | .IX Item "Features" | |
218 | Returns a reference to a hash with keys being features present in | |
219 | current implementation. Several optional features are used in the | |
220 | minimal interface: \f(CW\*(C`appname\*(C'\fR should be present if the first argument | |
221 | to \f(CW\*(C`new\*(C'\fR is recognized, and \f(CW\*(C`minline\*(C'\fR should be present if | |
222 | \&\f(CW\*(C`MinLine\*(C'\fR method is not dummy. \f(CW\*(C`autohistory\*(C'\fR should be present if | |
223 | lines are put into history automatically (maybe subject to | |
224 | \&\f(CW\*(C`MinLine\*(C'\fR), and \f(CW\*(C`addhistory\*(C'\fR if \f(CW\*(C`addhistory\*(C'\fR method is not dummy. | |
225 | .Sp | |
226 | If \f(CW\*(C`Features\*(C'\fR method reports a feature \f(CW\*(C`attribs\*(C'\fR as present, the | |
227 | method \f(CW\*(C`Attribs\*(C'\fR is not dummy. | |
228 | .SH "Additional supported functions" | |
229 | .IX Header "Additional supported functions" | |
230 | Actually \f(CW\*(C`Term::ReadLine\*(C'\fR can use some other package, that will | |
231 | support reacher set of commands. | |
232 | .PP | |
233 | All these commands are callable via method interface and have names | |
234 | which conform to standard conventions with the leading \f(CW\*(C`rl_\*(C'\fR stripped. | |
235 | .PP | |
236 | The stub package included with the perl distribution allows some | |
237 | additional methods: | |
238 | .ie n .IP """tkRunning""" 12 | |
239 | .el .IP "\f(CWtkRunning\fR" 12 | |
240 | .IX Item "tkRunning" | |
241 | makes Tk event loop run when waiting for user input (i.e., during | |
242 | \&\f(CW\*(C`readline\*(C'\fR method). | |
243 | .ie n .IP """ornaments""" 12 | |
244 | .el .IP "\f(CWornaments\fR" 12 | |
245 | .IX Item "ornaments" | |
246 | makes the command line stand out by using termcap data. The argument | |
247 | to \f(CW\*(C`ornaments\*(C'\fR should be 0, 1, or a string of a form | |
248 | \&\f(CW"aa,bb,cc,dd"\fR. Four components of this string should be names of | |
249 | \&\fIterminal capacities\fR, first two will be issued to make the prompt | |
250 | standout, last two to make the input line standout. | |
251 | .ie n .IP """newTTY""" 12 | |
252 | .el .IP "\f(CWnewTTY\fR" 12 | |
253 | .IX Item "newTTY" | |
254 | takes two arguments which are input filehandle and output filehandle. | |
255 | Switches to use these filehandles. | |
256 | .PP | |
257 | One can check whether the currently loaded ReadLine package supports | |
258 | these methods by checking for corresponding \f(CW\*(C`Features\*(C'\fR. | |
259 | .SH "EXPORTS" | |
260 | .IX Header "EXPORTS" | |
261 | None | |
262 | .SH "ENVIRONMENT" | |
263 | .IX Header "ENVIRONMENT" | |
264 | The environment variable \f(CW\*(C`PERL_RL\*(C'\fR governs which ReadLine clone is | |
265 | loaded. If the value is false, a dummy interface is used. If the value | |
266 | is true, it should be tail of the name of the package to use, such as | |
267 | \&\f(CW\*(C`Perl\*(C'\fR or \f(CW\*(C`Gnu\*(C'\fR. | |
268 | .PP | |
269 | As a special case, if the value of this variable is space\-separated, | |
270 | the tail might be used to disable the ornaments by setting the tail to | |
271 | be \f(CW\*(C`o=0\*(C'\fR or \f(CW\*(C`ornaments=0\*(C'\fR. The head should be as described above, say | |
272 | .PP | |
273 | If the variable is not set, or if the head of space-separated list is | |
274 | empty, the best available package is loaded. | |
275 | .PP | |
276 | .Vb 2 | |
277 | \& export "PERL_RL=Perl o=0" # Use Perl ReadLine without ornaments | |
278 | \& export "PERL_RL= o=0" # Use best available ReadLine without ornaments | |
279 | .Ve | |
280 | .PP | |
281 | (Note that processing of \f(CW\*(C`PERL_RL\*(C'\fR for ornaments is in the discretion of the | |
282 | particular used \f(CW\*(C`Term::ReadLine::*\*(C'\fR package). | |
283 | .SH "CAVEATS" | |
284 | .IX Header "CAVEATS" | |
285 | It seems that using Term::ReadLine from Emacs minibuffer doesn't work | |
286 | quite right and one will get an error message like | |
287 | .PP | |
288 | .Vb 1 | |
289 | \& Cannot open /dev/tty for read at ... | |
290 | .Ve | |
291 | .PP | |
292 | One possible workaround for this is to explicitly open /dev/tty like this | |
293 | .PP | |
294 | .Vb 4 | |
295 | \& open (FH, "/dev/tty" ) | |
296 | \& or eval 'sub Term::ReadLine::findConsole { ("&STDIN", "&STDERR") }'; | |
297 | \& die $@ if $@; | |
298 | \& close (FH); | |
299 | .Ve | |
300 | .PP | |
301 | or you can try using the 4\-argument form of Term::ReadLine\->\fInew()\fR. |