Curses:...tEditor(3)
π NAME π
Curses::UI::TextEditor β create and manipulate texteditor widgets. okay so this is the Curses::UI::TextEditor page from the Curses:...tEditor(3) manual, bestie, and it's lowkey a whole little toolkit for text widgets. π«Ά
π¦ CLASS HIERARCHY π¦
Curses::UI::Widget
Curses::UI::Searchable
|
+----Curses::UI::TextEditor
β¨ SYNOPSIS β¨
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();
πΈ DESCRIPTION πΈ
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. iconic behavior, honestly.
- 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. yes, that's how it's spelled on the page β I'm not fixing it, I'm just reporting the lore. π
π STANDARD OPTIONS π
-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. standard guest list, no surprises.
π WIDGET-SPECIFIC OPTIONS π
-text < TEXT >β sets the initial text for the widget to TEXT. the starting outfit, basically.-pos < CURSOR_POSITION >β sets the initial cursor position for the widget to CURSOR_POSITION.-posrepresents the character index within-text. By default this option is set to0.-readonly < BOOLEAN >β the texteditor widget will be created as a read only texteditor (which is also called a textviewer) if BOOLEAN is true. By default BOOLEAN is false.-singleline < BOOLEAN >β the texteditor widget will be created as a single line texteditor (which is also called a textentry) if BOOLEAN is true. By default BOOLEAN is false.-wrapping < BOOLEAN >β if BOOLEAN is true, the texteditor will have text wrapping enabled. By default BOOLEAN is false.-showlines < BOOLEAN >β if BOOLEAN is set to a true value, each editable line in the editor will show a line to type on. By default BOOLEAN is set to false.-maxlength < VALUE >β this sets the maximum allowed length of the text to VALUE. By default VALUE is set to0, which means that the text may be infinitely long.-maxlines < VALUE >β this sets the maximum allowed number of lines for the text toSCALAR. yes, the page saysSCALARthere even though the option placeholder isVALUEβ I'm just reading the group chat. By default VALUE is set to0, which means that the text may contain an infinite number of lines.-password < CHARACTER >β instead of showing the real text in the widget, every character of the text will (on the screen) be replaced by CHARACTER. So creating a standard password field can be done by setting:
-password => '*'
-regexp < REGEXP >β if characters are added to the texteditor, the new text will be matched against REGEXP. 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 < VALUE >β this option determines how many undolevels should be kept in memory for the texteditor widget. By default10levels are kept. If this value is set to0, the number of levels is infinite.-showoverflow < BOOLEAN >β if BOOLEAN 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 BOOLEAN is true.-showhardreturns < BOOLEAN >β if BOOLEAN is true, hard returns will be made visible by a diamond character. By default BOOLEAN is false.-homeonblur < BOOLEAN >β if BOOLEAN is set to a true value, the cursor will move to the start of the text if the widget loses focus.-toupper < BOOLEAN >β if BOOLEAN is true, all entered text will be converted to uppercase. By default BOOLEAN is false.-tolower < BOOLEAN >β if BOOLEAN is true, all entered text will be converted to lowercase. By default BOOLEAN is false.-onchange < CODEREF >β this sets the onChange event handler for the texteditor widget. If the text is changed by typing, the code in CODEREF will be executed. It will get the widget reference as its argument.-reverse < BOOLEAN >β makes the text drawn in reverse font. dramatic little font moment.
π§ METHODS π§
new ( OPTIONS )layout ( )draw ( BOOLEAN )focus ( )onFocus ( CODEREF )onBlur ( CODEREF )
These are standard methods. See Curses::UI::Widget for an explanation of these.
text ( [TEXT] )β if TEXT is defined, this will set the text of the widget to TEXT. To see the change, the widget needs to be redrawn by thedrawmethod. If TEXT is not defined, this method will return the current contents of the texteditor.get ( )β this method will calltextwithout any arguments, so it will return the contents of the texteditor. little shortcut, very demure.onChange ( CODEREF )β this method can be used to set the-onchangeevent 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 if$charisundef.toggle_showhardreturnsβ toggles the-showhardreturnsoption.toggle_showoverflowβ toggles the-showoverflowoption.toggle_wrappingβ toggles the-wrappingoption.
π DEFAULT BINDINGS π
There are different sets of bindings for each mode in which this widget can be used. keyboard choreography, basically.
π« All modes (editor, single line and read only) π«
<tab>β calls the'returreturnn'routine. This will have the widget lose its focus.<cursor-left>,<CTRL+B>β calls the'cursor-left'routine: move the cursor one position to the left.<cursor-right>,<CTRL+F>β calls the'cursor-right'routine: move the cursor one position to the right.<cursor-down>,<CTRL+N>β calls the'cursor-down'routine: move the cursor one line down.<cursor-up>,<CTRL+P>β calls the'cursor-up'routine: move the cursor one line up.<page-up>β calls the'cursor-pageup'routine: move the cursor to the previous page.<page-down>β calls the'cursor-pagedown'routine: move the cursor to the next page.<home>β calls the'cursor-home'routine: go to the start of the text.<end>β calls the'cursor-end'routine: go to the end of the text.<CTRL+A>β calls the'cursor-scrlinestart'routine: move the cursor to the start of the current line.<CTRL+E>β calls the'cursor-scrlineend'routine: move the cursor to the end of the current line.<CTRL+W>β calls the'toggle-wrapping'routine: toggle the-wrappingoption of the texteditor.<CTRL+R>β calls the'toggle-showhardreturns'routine: toggle the-showhardreturnsoption of the texteditor.<CTRL+T>β calls the'toggle-showoverflow'routine: toggle the-showoverflowoption of the texteditor.
π₯ All edit modes (all but read only mode) π₯
<CTRL+Y>,<CTRL+X>β calls the'delete-line'routine: delete the current line.<CTRL+K>β calls the'delete-till-eol'routine: delete the text from the current cursor position up to the end of the current line.<CTRL+U>β calls the'clear-line'routine: clear the current line and move the cursor to the start of this line.<CTRL+D>β calls the'delete-character'routine: delete the character that currently is under the cursor.<backspace>β calls the'backspace'routine: delete the character that is before the current cursor position.<CTRL+Z>β calls the'undo'routine: undo the last change to the text, up to-undolevelslevels.<CTRL+V>β calls the'paste'routine: this will paste the last deleted text at the current cursor position.<any other key>β calls the'add-string'routine: the character will be inserted in the text at the current cursor position.
π¦ Only for the read only mode π¦
<h>β calls the'cursor-left'routine: move the cursor one position to the left.<l>β calls the'cursor-right'routine: move the cursor one position to the right.b<<k>>β calls the'cursor-up'routine: move the cursor one line up.b<<j>>β calls the'cursor-down'routine: move the cursor one line down.<space>,<]>β calls the'cursor-pagedown'routine: move the cursor to the next page.<->,<[>β calls the'cursor-pageup'routine: move the cursor to the previous page.</>β calls 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.<?>β calls the'search-backward'routine. This will do the same as the'search-forward'routine, only it will search in the opposite direction.
bestie, the page literally printsb<<k>>andb<<j>>for those two read-only keys, so I'm keeping the chaos exactly as written. π
π SEE ALSO π
Curses::UICurses::UI::TextViewerCurses::UI::TextEntryCurses::UI::WidgetCurses::UI::Common
π AUTHOR π
Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de).
This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself. slay, and also legally binding-ish. β¨
Source/version: perl v5.42.2 Β· date: 2023-07-03 Β· manual: Curses:...tEditor(3) β bye bestie, go edit some text ππ
π¦ where this page comes from
- alpine 3.24: perl-curses-ui-doc 0.9609-r3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms