CodeTe...mplate(3pm)
π NAME π
Tk::CodeText::Template β a whole template for syntax highlighting plugins, bestie β¨
π SYNOPSIS π
okay soβ¦ this section is literally empty. Not a single line. No cap, there is nothing here to show you π«Ά
πΈ DESCRIPTION πΈ
Tk::CodeText::Template is a framework that's here to help out all the girlies (gn) who write plugin modules π Every single method you'd need to bring syntax highlighting to life inside a Tk::CodeText widget? It's all right there. The only things missing are the syntax definitions and the callbacks, which is lowkey the whole point β you bring those.
π¨ bestie listen: you should never create an instance of Tk::CodeText::Template. Never ever. It is meant to be sub classed only. It's giving "abstract base class, do not touch," and we respect that π
β¨ METHODS β¨
callbacks({'Tagname' => \&callback, ...})β sets and returns the instance variable'callbacks'π¦highlight($text)β highlights$text. It does this by picking the right callback out of the commands hash and invoking it. And it keeps on doing that, over and over, until$texthas been reduced all the way down to an empty string. Iconic loop behavior, fr fr π₯listAdd('listname', $item1, $item2 ...)β adds a list to the'lists'hash πlists(?\%lists?)β sets and returns the instance variable'lists'πout(?\@highlightedlist?)β sets and returns the instance variable'out'πparserError('text')β the error trapping method. It tries to escape the current mode. If that's not possible, it will parse the text with the default tag instead. On top of all that, it complains about being called at all π which is honestly so valid of it. This one is useful for debugging when you're writing a new plugin πrules(?\@rules?)β sets and returns a reference to a list of tagnames and options. By default it is set to[]βsnippetAppend($string)β appends$stringto the current snippet βοΈsnippetParse(?$text?, ?$tagname?)β parses$textinto the'out'list, and assigns$tagnameto it. If$tagnameisn't specified, it will go looking for the tagname by callingstackTop. And if$textisn't specified either, it will go looking for text by callingsnippetπstackβ sets and returns the instance variable'stack', which is a reference to an array π₯stackPullβ retrieves the element that's sitting on top of the stack, and decrements stacksize by 1 πstackPush($tagname)β puts$tagnameon top of the stack, and increments stacksize by 1 πstackTopβ retrieves the element on top of the stack πstateCompare(\@state);β compares two lists,\@stateand the stack. Returns true if they match πstateGetβ returns a list containing the entire stack ποΈstateSet(@list)β accepts@listas the current stack πtokenParse('Tagname');β parses the currently built snippet and tags it with'Tagname'π·οΈtokenTest($value, 'Listname');β returns true if$valueis an element of'Listname'in the'lists'hash β
π AUTHOR π
Hans Jeuken (haje@toneel.demon.nl) β shoutout to the legend π«Ά
π BUGS π
Unknown. (Which is either slay or terrifying, and honestly? Both π)
mwah, that's the whole page bestie π this lovely little doc shipped with perl v5.40.1 and it's dated 2025-05-04, under User Contributed Perl Documentation β go forth and subclass responsibly π§β¨
π¦ where this page comes from
- debian trixie: libtk-codetext-perl 0.3.4-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtk-codetext-perl 0.3.4-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtk-codetext-perl 0.3.4-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms