1Curses::UI::TextEditor(U3s)er Contributed Perl DocumentatCiuornses::UI::TextEditor(3)
2
3
4
6 Curses::UI::TextEditor - Create and manipulate texteditor widgets
7
9 Curses::UI::Widget
10 Curses::UI::Searchable
11 |
12 +----Curses::UI::TextEditor
13
15 use Curses::UI;
16 my $cui = new Curses::UI;
17 my $win = $cui->add('window_id', 'Window');
18
19 my $editor = $win->add(
20 'myeditor', 'TextEditor',
21 -vscrollbar => 1,
22 -wrapping => 1,
23 );
24
25 $editor->focus();
26 my $text = $editor->get();
27
29 Curses::UI::TextEditor is a widget that can be used to create a couple
30 of different kinds of texteditors. These are:
31
32 • multi-line texteditor
33
34 This is a multi-line text editor with features like word-wrapping,
35 maximum textlength and undo.
36
37 • single-line texteditor
38
39 The texteditor can be created as a single-line editor. Most of the
40 features of the default texteditor will remain. Only the multi-
41 line specific options will not be available (like moving up and
42 down in the text).
43
44 • read only texteditor
45
46 The texteditor can also be used in read only mode. In this mode,
47 the texteditor will function as a text viewer. The user can walk
48 through the text and search trough it.
49
50 See exampes/demo-Curses::UI::TextEditor in the distribution for a short
51 demo of these.
52
54 -parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop,
55 -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom,
56 -title, -titlefullwidth, -titlereverse, -onfocus, -onblur
57
58 For an explanation of these standard options, see Curses::UI::Widget.
59
61 • -text < TEXT >
62
63 This sets the initial text for the widget to TEXT.
64
65 • -pos < CURSOR_POSITION >
66
67 This sets the initial cursor position for the widget to
68 CURSOR_POSITION. -pos represents the character index within -text.
69 By default this option is set to 0.
70
71 • -readonly < BOOLEAN >
72
73 The texteditor widget will be created as a read only texteditor
74 (which is also called a textviewer) if BOOLEAN is true. By default
75 BOOLEAN is false.
76
77 • -singleline < BOOLEAN >
78
79 The texteditor widget will be created as a single line texteditor
80 (which is also called a textentry) if BOOLEAN is true. By default
81 BOOLEAN is false.
82
83 • -wrapping < BOOLEAN >
84
85 If BOOLEAN is true, the texteditor will have text wrapping enabled.
86 By default BOOLEAN is false.
87
88 • -showlines < BOOLEAN >
89
90 If BOOLEAN is set to a true value, each editable line in the editor
91 will show a line to type on. By default BOOLEAN is set to false.
92
93 • -maxlength < VALUE >
94
95 This sets the maximum allowed length of the text to VALUE. By
96 default VALUE is set to 0, which means that the text may be
97 infinitely long.
98
99 • -maxlines < VALUE >
100
101 This sets the maximum allowed number of lines for the text to
102 SCALAR. By default VALUE is set to 0, which means that the text may
103 contain an infinite number of lines.
104
105 • -password < CHARACTER >
106
107 Instead of showing the real text in the widget, every character of
108 the text will (on the screen) be replaced by CHARACTER. So creating
109 a standard password field can be done by setting:
110
111 -password => '*'
112
113 • -regexp < REGEXP >
114
115 If characters are added to the texteditor, the new text will be
116 matched against REGEXP. If the text does not match, the change will
117 be denied. This can for example be used to force digit-only input
118 on the texteditor:
119
120 -regexp => '/^\d*$/'
121
122 • -undolevels < VALUE >
123
124 This option determines how many undolevels should be kept in memory
125 for the texteditor widget. By default 10 levels are kept. If this
126 value is set to 0, the number of levels is infinite.
127
128 • -showoverflow < BOOLEAN >
129
130 If BOOLEAN is true, the text in the texteditor will be padded by an
131 overflow character ($) if there is text outside the screen (like
132 'pico' does). By default BOOLEAN is true.
133
134 • -showhardreturns < BOOLEAN >
135
136 If BOOLEAN is true, hard returns will be made visible by a diamond
137 character. By default BOOLEAN is false.
138
139 • -homeonblur < BOOLEAN >
140
141 If BOOLEAN is set to a true value, the cursor will move to the
142 start of the text if the widget loses focus.
143
144 • -toupper < BOOLEAN >
145
146 If BOOLEAN is true, all entered text will be converted to
147 uppercase. By default BOOLEAN is false.
148
149 • -tolower < BOOLEAN >
150
151 If BOOLEAN is true, all entered text will be converted to
152 lowercase. By default BOOLEAN is false.
153
154 • -onchange < CODEREF >
155
156 This sets the onChange event handler for the texteditor widget. If
157 the text is changed by typing, the code in CODEREF will be
158 executed. It will get the widget reference as its argument.
159
160 • -reverse < BOOLEAN >
161
162 Makes the text drawn in reverse font.
163
165 • new ( OPTIONS )
166
167 • layout ( )
168
169 • draw ( BOOLEAN )
170
171 • focus ( )
172
173 • onFocus ( CODEREF )
174
175 • onBlur ( CODEREF )
176
177 These are standard methods. See Curses::UI::Widget for an
178 explanation of these.
179
180 • text ( [TEXT] )
181
182 If TEXT is defined, this will set the text of the widget to TEXT.
183 To see the change, the widget needs to be redrawn by the draw
184 method. If TEXT is not defined, this method will return the
185 current contents of the texteditor.
186
187 • get ( )
188
189 This method will call text without any arguments, so it will return
190 the contents of the texteditor.
191
192 • onChange ( CODEREF )
193
194 This method can be used to set the -onchange event handler (see
195 above) after initialization of the texteditor.
196
197 • set_password_char ( $char )
198
199 This method can be used to change the password property. The
200 password character will be set to $char, or turned off in $char is
201 undef.
202
203 • toggle_showhardreturns
204
205 Toggles the -showhardreturns option.
206
207 • toggle_showoverflow
208
209 Toggles the -showoverflow option.
210
211 • toggle_wrapping
212
213 Toggles the -wrapping option.
214
216 There are different sets of bindings for each mode in which this widget
217 can be used.
218
219 All modes (editor, single line and read only)
220 • <tab>
221
222 Call the 'returreturnn' routine. This will have the widget loose
223 its focus.
224
225 • <cursor-left>, <CTRL+B>
226
227 Call the 'cursor-left' routine: move the cursor one position to the
228 left.
229
230 • <cursor-right>, <CTRL+F>
231
232 Call the 'cursor-right' routine: move the cursor one position to
233 the right.
234
235 • <cursor-down>, <CTRL+N>
236
237 Call the 'cursor-down' routine: move the cursor one line down.
238
239 • <cursor-up>, <CTRL+P>
240
241 Call the 'cursor-up' routine: move the cursor one line up.
242
243 • <page-up>
244
245 Call the 'cursor-pageup' routine: move the cursor to the previous
246 page.
247
248 • <page-down>
249
250 Call the 'cursor-pagedown' routine: move the cursor to the next
251 page.
252
253 • <home>
254
255 Call the 'cursor-home' routine: go to the start of the text.
256
257 • <end>
258
259 Call the 'cursor-end' routine: go to the end of the text.
260
261 • <CTRL+A>
262
263 Call the 'cursor-scrlinestart' routine: move the cursor to the
264 start of the current line.
265
266 • <CTRL+E>
267
268 Call the 'cursor-scrlineend' routine: move the cursor to the end of
269 the current line.
270
271 • <CTRL+W>
272
273 Call the 'toggle-wrapping' routine: toggle the -wrapping option of
274 the texteditor.
275
276 • <CTRL+R>
277
278 Call the 'toggle-showhardreturns' routine: toggle the
279 -showhardreturns option of the texteditor.
280
281 • <CTRL+T>
282
283 Call the 'toggle-showoverflow' routine: toggle the -showoverflow
284 option of the texteditor.
285
286 All edit modes (all but read only mode)
287 • <CTRL+Y>, <CTRL+X>
288
289 Call the 'delete-line' routine: Delete the current line.
290
291 • <CTRL+K>
292
293 Call the 'delete-till-eol' routine: delete the text from the
294 current cursor position up to the end of the current line.
295
296 • <CTRL+U>
297
298 Call the 'clear-line' routine: clear the current line and move the
299 cursor to the start of this line.
300
301 • <CTRL+D>
302
303 Call the 'delete-character' routine: delete the character that
304 currently is under the cursor.
305
306 • <backspace>
307
308 Call the 'backspace' routine: delete the character this is before
309 the current cursor position.
310
311 • <CTRL+Z>
312
313 Call the 'undo' routine: undo the last change to the text, up to
314 -undolevels levels.
315
316 • <CTRL+V>
317
318 Call the 'paste' routine: this will paste the last deleted text at
319 the current cursor position.
320
321 • <any other key>
322
323 Call the 'add-string' routine: the character will be inserted in
324 the text at the current cursor position.
325
326 Only for the read only mode
327 • <h>
328
329 Call the 'cursor-left' routine: move the cursor one position to the
330 left.
331
332 • <l>
333
334 Call the 'cursor-right' routine: move the cursor one position to
335 the right.
336
337 • b<<k>>
338
339 Call the 'cursor-up' routine: move the cursor one line up.
340
341 • b<<j>>
342
343 Call the 'cursor-down' routine: move the cursor one line down.
344
345 • <space>, <]>
346
347 Call the 'cursor-pagedown' routine: move the cursor to the next
348 page.
349
350 • <->, <[>
351
352 Call the 'cursor-pageup' routine: move the cursor to the previous
353 page.
354
355 • </>
356
357 Call the 'search-forward' routine. This will make a 'less'-like
358 search system appear in the textviewer. A searchstring can be
359 entered. After that the user can search for the next occurance
360 using the 'n' key or the previous occurance using the 'N' key.
361
362 • <?>
363
364 Call the 'search-backward' routine. This will do the same as the
365 'search-forward' routine, only it will search in the opposite
366 direction.
367
369 Curses::UI, Curses::UI::TextViewer Curses::UI::TextEntry
370 Curses::UI::Widget, Curses::UI::Common
371
373 Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
374
375 Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
376
377 This package is free software and is provided "as is" without express
378 or implied warranty. It may be used, redistributed and/or modified
379 under the same terms as perl itself.
380
381
382
383perl v5.32.1 2021-01-27 Curses::UI::TextEditor(3)