Tickit::Widget::Entry(3pm) | User Contributed Perl Documentation | Tickit::Widget::Entry(3pm) |
"Tickit::Widget::Entry" - a widget for entering text
use Tickit; use Tickit::Widget::Entry; my $entry = Tickit::Widget::Entry->new( on_enter => sub { my ( $self, $line ) = @_; # process $line somehow $self->set_text( "" ); }, ); Tickit->new( root => $entry )->run;
This class provides a widget which allows the user to enter a line of text.
The default style pen is used as the widget pen. The following style pen prefixes are also used:
The following style keys are used:
The following keys are bound by default
Delete the entire line
Delete to the start of the line
Delete one word backwards
Delete one character backwards
Delete one character forwards
Delete one word forwards
Move the cursor to the end of the input line
Accept a line of input by running the "on_enter" action
Move the cursor to the beginning of the input line
Toggle between overwrite and insert mode
Move the cursor one character left
Move the cursor one word left
Move the cursor one character right
Move the cursor one word right
Constructs a new "Tickit::Widget::Entry" object.
Takes the following named arguments:
Return or set the CODE reference to be called when the "key_enter_line" action is invoked; usually bound to the "Enter" key.
$on_enter->( $entry, $line )
Returns the current entry position, in terms of characters within the text.
Set the text entry position, moving the cursor
Associate methods or CODE references with keypresses. On receipt of a the key the method or CODE reference will be invoked, being passed the stringified key representation and the underlying "Term::TermKey::Key" structure.
$ret = $entry->method( $keystr, $key ) $ret = $coderef->( $entry, $keystr, $key )
This method takes a hash of keystring/value pairs. Binding a value of "undef" will remove it.
These methods operate on the text input buffer directly, updating the stored text and changing the rendered display to reflect the changes. They can be used by a program to directly manipulate the text.
Returns the currently entered text.
Replace the text in the entry box. This completely redraws the widget's window. It is largely provided for initialisation; for normal edits (such as from keybindings), it is preferable to use "text_insert", "text_delete" or "text_splice".
Insert the given text at the given character position.
Delete the given section of text. Returns the deleted text.
Replace the given section of text with the given replacement. Returns the text deleted from the section.
Search forward in the string, returning the character position of the next beginning of word from the initial position. If none is found, returns $else.
Search forward in the string, returning the character position of the next end of word from the initial position. If none is found, returns the length of the string.
Search backward in the string, returning the character position of the previous beginning of word from the initial position. If none is found, returns 0.
Search backward in the string, returning the character position of the previous end of word from the initial position. If none is found, returns "undef".
Try to find a nice way to allow loaded plugins, possibly per-instance if not just globally or per-class. See how many of these TODO items can be done using plugins.
History. Isearch. History replay. Transpose. Transcase. Yank ring. Numeric prefixes.
Shift-movement, or vim-style. Mouse.
Paul Evans <leonerd@leonerd.org.uk>
2018-07-30 | perl v5.26.2 |