| 1 |
NAME |
| 2 |
|
| 3 |
Tickit::Widget::Entry::Plugin::Completion - add word-completion logic |
| 4 |
to a Tickit::Widget::Entry |
| 5 |
|
| 6 |
SYNOPSIS |
| 7 |
|
| 8 |
use Tickit::Widget::Entry; |
| 9 |
use Tickit::Widget::Entry::Plugin::Completion; |
| 10 |
|
| 11 |
my $entry = Tickit::Widget::Entry->new( ... ); |
| 12 |
Tickit::Widget::Entry::Plugin::Completion->apply( $entry, |
| 13 |
words => [ make_words() ], |
| 14 |
); |
| 15 |
|
| 16 |
... |
| 17 |
|
| 18 |
DESCRIPTION |
| 19 |
|
| 20 |
This package applies code to a Tickit::Widget::Entry instance to |
| 21 |
implement word-completion logic while editing. This logic is activated |
| 22 |
by pressing the <Tab> key. |
| 23 |
|
| 24 |
If the word currently being edited has a unique match in the list of |
| 25 |
words, then the word is completed entirely, followed by a space. |
| 26 |
|
| 27 |
If there are multiple words that could complete from the word at the |
| 28 |
cursor, then a popup menu is presented showing the next available |
| 29 |
characters or matches. The user can continue typing more characters to |
| 30 |
narrow down the choice until a unique match is found. |
| 31 |
|
| 32 |
METHODS |
| 33 |
|
| 34 |
apply |
| 35 |
|
| 36 |
Tickit::Widget::Entry::Plugin::Completion->apply( $entry, %params ) |
| 37 |
|
| 38 |
Applies the plugin code to the given Tickit::Widget::Entry instance. |
| 39 |
|
| 40 |
The following named parameters are recognised |
| 41 |
|
| 42 |
gen_words => CODE |
| 43 |
|
| 44 |
@words = $gen_words->( %args ) |
| 45 |
|
| 46 |
A CODE reference to a subroutine used to generate the list of words |
| 47 |
at the current position. It is passed the following name/value pairs |
| 48 |
to assist it: |
| 49 |
|
| 50 |
word => STRING |
| 51 |
|
| 52 |
The partial word currently being completed. |
| 53 |
|
| 54 |
wordpos => INT |
| 55 |
|
| 56 |
The position of the beginning of the word, within the line. Will be |
| 57 |
0 for the initial word of the line. |
| 58 |
|
| 59 |
entry => Tickit::Widget::Entry |
| 60 |
|
| 61 |
The underlying entry widget instance. |
| 62 |
|
| 63 |
words => ARRAY |
| 64 |
|
| 65 |
A shortcut to providing gen_words; a reference to an array containing |
| 66 |
all the possible words, in no particular order, that are offered for |
| 67 |
completion. |
| 68 |
|
| 69 |
use_popup => BOOL |
| 70 |
|
| 71 |
Optional. If false, do not display a popup menu. Defaults to true. |
| 72 |
|
| 73 |
When this is disabled, the completion logic will apply longest-prefix |
| 74 |
matching on the set of available words, but will not otherwise |
| 75 |
display or offer any interactive UI on the list of matches. |
| 76 |
|
| 77 |
ignore_case => BOOL |
| 78 |
|
| 79 |
Optional. If true, word matching will be performed ignoring case, by |
| 80 |
using the /i regexp flag. Defaults to false. When the completion |
| 81 |
logic has selected a word to insert, it may change the case of the |
| 82 |
text already in the buffer to match the completion word. |
| 83 |
|
| 84 |
append_after_word => STRING |
| 85 |
|
| 86 |
Optional. If set, append this string after a successful unique match. |
| 87 |
Defaults to a single space. |
| 88 |
|
| 89 |
AUTHOR |
| 90 |
|
| 91 |
Paul Evans <[email protected]> |
| 92 |
|