Tickit::Widget::Entry::Plugin::Completion - add word-completion logic to a Tickit::Widget::Entry
Tickit::Widget::Entry::Plugin::Completion
use Tickit::Widget::Entry; use Tickit::Widget::Entry::Plugin::Completion; my $entry = Tickit::Widget::Entry->new( ... ); Tickit::Widget::Entry::Plugin::Completion->apply( $entry, words => [ make_words() ], ); ...
This package applies code to a Tickit::Widget::Entry instance to implement word-completion logic while editing. This logic is activated by pressing the <Tab> key.
<Tab>
If the word currently being edited has a unique match in the list of words, then the word is completed entirely, followed by a space.
If there are multiple words that could complete from the word at the cursor, then a popup menu is presented showing the next available characters or matches. The user can continue typing more characters to narrow down the choice until a unique match is found.
Tickit::Widget::Entry::Plugin::Completion->apply( $entry, %params )
Applies the plugin code to the given Tickit::Widget::Entry instance.
The following named parameters are recognised
@words = $gen_words->( %args )
A CODE reference to a subroutine used to generate the list of words at the current position. It is passed the following name/value pairs to assist it:
The partial word currently being completed.
The position of the beginning of the word, within the line. Will be 0 for the initial word of the line.
Tickit::Widget::Entry
The underlying entry widget instance.
A shortcut to providing gen_words; a reference to an array containing all the possible words, in no particular order, that are offered for completion.
gen_words
Optional. If false, do not display a popup menu. Defaults to true.
When this is disabled, the completion logic will apply longest-prefix matching on the set of available words, but will not otherwise display or offer any interactive UI on the list of matches.
Optional. If true, word matching will be performed ignoring case, by using the /i regexp flag. Defaults to false. When the completion logic has selected a word to insert, it may change the case of the text already in the buffer to match the completion word.
/i
Optional. If set, append this string after a successful unique match. Defaults to a single space.
Paul Evans <leonerd@leonerd.org.uk>
To install Tickit::Widget::Entry::Plugin::Completion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::Entry::Plugin::Completion
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::Entry::Plugin::Completion
For more information on module installation, please visit the detailed CPAN module installation guide.