Create and manipulate texteditor widgets
Curses::UI::Widget Curses::UI::Searchable | +----Curses::UI::TextEditor
use Curses::UI; my $cui = new Curses::UI; my $win = $cui->add('window_id', 'Window');
my $editor = $win->add( 'myeditor', 'TextEditor', -vscrollbar => 1, -wrapping => 1, );
$editor->focus(); my $text = $editor->get();
Curses::UI::TextEditor is a widget that can be used to create a couple of different kinds of texteditors. These are:
multi-line texteditor This is a multi-line text editor with features like word-wrapping, maximum textlength and undo.
single-line texteditor The texteditor can be created as a single-line editor. Most of the features of the default texteditor will remain. Only the multi-line specific options will not be available (like moving up and down in the text).
read only texteditor The texteditor can also be used in read only mode. In this mode, the texteditor will function as a text viewer. The user can walk through the text and search trough it.
See exampes/demo-Curses::UI::TextEditor in the distribution for a short demo of these.
-parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop, -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom, -title, -titlefullwidth, -titlereverse, -onfocus, -onblur
For an explanation of these standard options, see Curses::UI::Widget.
-text < \s-1TEXT\s0 > This sets the initial text for the widget to \s-1TEXT\s0.
-pos < \s-1CURSOR_POSITION\s0 > This sets the initial cursor position for the widget to \s-1CURSOR_POSITION\s0. -pos represents the character index within -text. By default this option is set to 0.
-readonly < \s-1BOOLEAN\s0 > The texteditor widget will be created as a read only texteditor (which is also called a textviewer) if \s-1BOOLEAN\s0 is true. By default \s-1BOOLEAN\s0 is false.
-singleline < \s-1BOOLEAN\s0 > The texteditor widget will be created as a single line texteditor (which is also called a textentry) if \s-1BOOLEAN\s0 is true. By default \s-1BOOLEAN\s0 is false.
-wrapping < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is true, the texteditor will have text wrapping enabled. By default \s-1BOOLEAN\s0 is false.
-showlines < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is set to a true value, each editable line in the editor will show a line to type on. By default \s-1BOOLEAN\s0 is set to false.
-maxlength < \s-1VALUE\s0 > This sets the maximum allowed length of the text to \s-1VALUE\s0. By default \s-1VALUE\s0 is set to 0, which means that the text may be infinitely long.
-maxlines < \s-1VALUE\s0 > This sets the maximum allowed number of lines for the text to \s-1SCALAR\s0. By default \s-1VALUE\s0 is set to 0, which means that the text may contain an infinite number of lines.
-password < \s-1CHARACTER\s0 > Instead of showing the real text in the widget, every character of the text will (on the screen) be replaced by \s-1CHARACTER\s0. So creating a standard password field can be done by setting: -password => '*'
-regexp < \s-1REGEXP\s0 > If characters are added to the texteditor, the new text will be matched against \s-1REGEXP\s0. If the text does not match, the change will be denied. This can for example be used to force digit-only input on the texteditor: -regexp => '/^\d*$/'
-undolevels < \s-1VALUE\s0 > This option determines how many undolevels should be kept in memory for the texteditor widget. By default 10 levels are kept. If this value is set to 0, the number of levels is infinite.
-showoverflow < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is true, the text in the texteditor will be padded by an overflow character ($) if there is text outside the screen (like 'pico' does). By default \s-1BOOLEAN\s0 is true.
-showhardreturns < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is true, hard returns will be made visible by a diamond character. By default \s-1BOOLEAN\s0 is false.
-homeonblur < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is set to a true value, the cursor will move to the start of the text if the widget loses focus.
-toupper < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is true, all entered text will be converted to uppercase. By default \s-1BOOLEAN\s0 is false.
-tolower < \s-1BOOLEAN\s0 > If \s-1BOOLEAN\s0 is true, all entered text will be converted to lowercase. By default \s-1BOOLEAN\s0 is false.
-onchange < \s-1CODEREF\s0 > This sets the onChange event handler for the texteditor widget. If the text is changed by typing, the code in \s-1CODEREF\s0 will be executed. It will get the widget reference as its argument.
-reverse < \s-1BOOLEAN\s0 > Makes the text drawn in reverse font.
new ( \s-1OPTIONS\s0 )
layout ( )
draw ( \s-1BOOLEAN\s0 )
focus ( )
onFocus ( \s-1CODEREF\s0 )
onBlur ( \s-1CODEREF\s0 ) These are standard methods. See Curses::UI::Widget for an explanation of these.
text ( [\s-1TEXT\s0] ) If \s-1TEXT\s0 is defined, this will set the text of the widget to \s-1TEXT\s0. To see the change, the widget needs to be redrawn by the draw method. If \s-1TEXT\s0 is not defined, this method will return the current contents of the texteditor.
get ( ) This method will call text without any arguments, so it will return the contents of the texteditor.
onChange ( \s-1CODEREF\s0 ) This method can be used to set the -onchange event handler (see above) after initialization of the texteditor.
set_password_char ( $char ) This method can be used to change the password property. The password character will be set to $char, or turned off in $char is undef.
toggle_showhardreturns Toggles the -showhardreturns option.
toggle_showoverflow Toggles the -showoverflow option.
toggle_wrapping Toggles the -wrapping option.
There are different sets of bindings for each mode in which this widget can be used.
<tab> Call the 'returreturnn' routine. This will have the widget loose its focus.
<cursor-left>, <\s-1CTRL+B\s0> Call the 'cursor-left' routine: move the cursor one position to the left.
<cursor-right>, <\s-1CTRL+F\s0> Call the 'cursor-right' routine: move the cursor one position to the right.
<cursor-down>, <\s-1CTRL+N\s0> Call the 'cursor-down' routine: move the cursor one line down.
<cursor-up>, <\s-1CTRL+P\s0> Call the 'cursor-up' routine: move the cursor one line up.
<page-up> Call the 'cursor-pageup' routine: move the cursor to the previous page.
<page-down> Call the 'cursor-pagedown' routine: move the cursor to the next page.
<home> Call the 'cursor-home' routine: go to the start of the text.
<end> Call the 'cursor-end' routine: go to the end of the text.
<\s-1CTRL+A\s0> Call the 'cursor-scrlinestart' routine: move the cursor to the start of the current line.
<\s-1CTRL+E\s0> Call the 'cursor-scrlineend' routine: move the cursor to the end of the current line.
<\s-1CTRL+W\s0> Call the 'toggle-wrapping' routine: toggle the -wrapping option of the texteditor.
<\s-1CTRL+R\s0> Call the 'toggle-showhardreturns' routine: toggle the -showhardreturns option of the texteditor.
<\s-1CTRL+T\s0> Call the 'toggle-showoverflow' routine: toggle the -showoverflow option of the texteditor.
<\s-1CTRL+Y\s0>, <\s-1CTRL+X\s0> Call the 'delete-line' routine: Delete the current line.
<\s-1CTRL+K\s0> Call the 'delete-till-eol' routine: delete the text from the current cursor position up to the end of the current line.
<\s-1CTRL+U\s0> Call the 'clear-line' routine: clear the current line and move the cursor to the start of this line.
<\s-1CTRL+D\s0> Call the 'delete-character' routine: delete the character that currently is under the cursor.
<backspace> Call the 'backspace' routine: delete the character this is before the current cursor position.
<\s-1CTRL+Z\s0> Call the 'undo' routine: undo the last change to the text, up to -undolevels levels.
<\s-1CTRL+V\s0> Call the 'paste' routine: this will paste the last deleted text at the current cursor position.
<any other key> Call the 'add-string' routine: the character will be inserted in the text at the current cursor position.
<h> Call the 'cursor-left' routine: move the cursor one position to the left.
<l> Call the 'cursor-right' routine: move the cursor one position to the right.
b<<k>> Call the 'cursor-up' routine: move the cursor one line up.
b<<j>> Call the 'cursor-down' routine: move the cursor one line down.
<space>, <]> Call the 'cursor-pagedown' routine: move the cursor to the next page.
<->, <[> Call the 'cursor-pageup' routine: move the cursor to the previous page.
</> Call the 'search-forward' routine. This will make a 'less'-like search system appear in the textviewer. A searchstring can be entered. After that the user can search for the next occurance using the 'n' key or the previous occurance using the 'N' key.
<?> Call the 'search-backward' routine. This will do the same as the 'search-forward' routine, only it will search in the opposite direction.
Curses::UI, Curses::UI::TextViewer Curses::UI::TextEntry Curses::UI::Widget, Curses::UI::Common
Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
Maintained by Marcus Thiesen ([email protected])
This package is free software and is provided \*(L"as is\*(R" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.