Reindex(3)
π
Reindex(3) π
Okay so this page is from the perl/Tk Documentation, and it's all about Tk::Reindex β the icon that changes the base index of Text-like widgets. π¦
πΈ NAME πΈ
Tk::Reindex β change the base index of Text-like widgets. Periodt. π
β¨ SYNOPSIS β¨
Bestie, here's the exact vibe:
use Tk::ReindexedText;
$t1=$w->ReindexedText(-linestart => 2);
use Tk::ReindexedROText;
$t2=$w->ReindexedROText(-linestart => 0);
π DESCRIPTION π
This creates a brand-new widget class based on Text-like widgets, and it can redefine the line number base (normally Text widgets start line numbers at 1) β or possibly do other manipulations on indexes. It's giving customizable index main-character energy. β¨
π STANDARD OPTIONS π
The newly-defined widget takes all the same options as the base widget, and that base widget defaults to Text. No cap. π
π§ WIDGET-SPECIFIC OPTIONS π§
-linestartβ Name:lineStart; Class:LineStart; Switch:-linestart. Sets the line number of the first line in the Text widget. The default-toindexcmdand-fromindexcmduse this configuration option. πΈ-toindexcmdβ Name:toIndexCmd; Class:ToIndexCmd; Switch:-toindexcmd. One of the two callbacks.-toindexcmdshould translate from 'user' indexes to 'native' Text-compatible indexes. π-fromindexcmdβ Name:fromIndexCmd; Class:FromIndexCmd; Switch:-fromindexcmd. The other callback.-fromindexcmdshould translate from 'native' indexes to 'user' indexes. π«Ά
Also, the original spec literally has these -item lines, so here they are exactly, untouched:
-item Name: toIndexCmd fromIndexCmd
-item Class: ToIndexCmd FromIndexCmd
-item Switch: -toindexcmd -fromindexcmd
These two options specify callbacks that are called with a list of indexes and are responsible for translating them to/from indexes that the base Text widget can understand. The callback is passed the widget followed by a list of indexes, and should return a list of translated indexes. It would probably be prudent to make these functions inverses of each other. πβ¨
The default callbacks simply add/subtract the offset given by the -linestart option for all indexes in 'line.character' format. π
π CLASS METHODS π
π§ import
To make new Reindex widgets, call this function via use with the name of the Text-like base class you're extending with "Reindex" capability. Also, 'use base(Tk::Reindex Tk::nameofbasewidget)' should be specified for that widget. Slay. β¨
π¦ BUGS π¦
Okay so the author literally says: "I've used the word "indexes" instead of "indices" throughout the documentation." Not a bug, just a note, but it's in BUGS. π
Also: all the built-in perl code for widget bindings & methods will use the new 'user' indexes. Which means all this index manipulation might might break code that is trying to parse/manipulate indexes. Or even assume that '1.0' is the beginning index. Tk::Text::Contents comes to mind. π
π AUTHOR π
Andrew Allen <ada@fc.hp.com> β iconic. π
This code may be distributed under the same conditions as Perl.
Sign-off: this page is from Tk1.1, dated 2025-07-31, and yes bestie it's the Reindex(3) manual page. Stay reindexed π
β¨π«Ά
π¦ where this page comes from
- alpine 3.23: perl-tk-doc 804.036-r8 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- alpine 3.24: perl-tk-doc 804.036-r8 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms