Tickit...pletion(3pm)

πŸ“¦
version 0.02 Β· 2 versions
  • 0.02 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.02 Β· alpine 3.24
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Tickit::Widget::Entry::Plugin::Completion πŸ’–

okay bestie, gather round, because this one is literally the glow-up plugin for your entry widget πŸ¦‹

Quick vibe check first: this page lives in the User Contributed Perl Documentation section, so it's filed under <cyan>Tickit...pletion(3pm)</cyan> β€” yes, the name gets truncated, no, that's not a typo, that's just how man does her hair πŸ’…


✨ NAME ✨

Tickit::Widget::Entry::Plugin::Completion β€” add word-completion logic to a Tickit::Widget::Entry

like, it bolts autocomplete onto your entry widget. that's the whole personality. πŸ‘‘


🌸 SYNOPSIS 🌸

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() ],
);

...

look at that. three lines of setup and your entry is out here completing words like a main character. periodt. ✨


πŸŽ€ DESCRIPTION πŸŽ€

So what's actually happening here? This package applies code to a Tickit::Widget::Entry instance to implement word-completion logic while editing. And the way you wake it up? You press the <Tab> key. That's the activation. <Tab> is the vibe check. 🌈

Here's the tea on how it behaves:

  • 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. boom. done. slay. πŸ’…
  • 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. And the user? They can keep typing more characters to narrow down the choice until a unique match is found. it's giving "choose your fighter" but for words. πŸ”₯

🫢 METHODS 🫢

πŸ’œ apply

Tickit::Widget::Entry::Plugin::Completion->apply( $entry, %params )

Applies the plugin code to the given Tickit::Widget::Entry instance. that's it, that's the job, and she does it flawlessly. 😌

The following named parameters are recognised:

  • gen_words => CODE
@words = $gen_words->( %args )

A CODE reference to a subroutine used to generate the list of words at the current position. It gets passed the following name/value pairs to assist it, because it deserves a little help sometimes πŸ₯Ί:

  • word => STRING β€” the partial word currently being completed.
  • wordpos => INT β€” the position of the beginning of the word, within the line. Will be 0 for the initial word of the line. (first word of the line? 0. iconic behaviour honestly.)
  • entry => "Tickit::Widget::Entry" β€” the underlying entry widget instance.
  • words => ARRAY β€” 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. chaotic energy, but valid. πŸ“
  • use_popup => BOOL β€” 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. so like, it still works, it's just shy. πŸ™ˆ

  • ignore_case => BOOL β€” Optional. If true, word matching will be performed ignoring case, by using the /i regexp flag. Defaults to false. And heads up bestie: 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. lowercase girlies, be aware. 😭
  • append_after_word => STRING β€” Optional. If set, append this string after a successful unique match. Defaults to a single space. so like, you can change the space. wild. love that for you. 🌸

πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk>

(the actual legend who wrote this. we stan. πŸ’–)


real talk though: everything above is exactly what the page says. I added sparkle, not ✨facts✨. if the docs say it, it's here, and if it's not here, it wasn't in the docs. no cap. 🫢

okay and for the cute sign-off, this whole thing ships as part of <purple>perl v5.36.0</purple>, dated <cyan>2022-12-17</cyan>, filed under <lavender>Tickit...pletion(3pm)</lavender> in the User Contributed Perl Documentation. go forth and complete some words, bestie. <rainbow>slay πŸ’…βœ¨πŸŒˆ</rainbow>

πŸ“¦ where this page comes from