1Reindex(3) perl/Tk Documentation Reindex(3)
2
3
4
6 Tk::Reindex - change the base index of Text-like widgets
7
9 use Tk::ReindexedText;
10 $t1=$w->ReindexedText(-linestart => 2);
11
12 use Tk::ReindexedROText;
13 $t2=$w->ReindexedROText(-linestart => 0);
14
16 Creates a new widget class based on Text-like widgets that can redefine
17 the line number base (normally Text widgets start line numbers at 1),
18 or possibly other manipulations on indexes.
19
21 The newly-defined widget takes all the same options as the base widget,
22 which defaults to Text.
23
25 Name: lineStart
26 Class: LineStart
27 Switch: -linestart
28 Sets the line number of the first line in the Text widget. The
29 default -toindexcmd and -fromindexcmd use this configuration
30 option.
31
32 -item Name: toIndexCmd fromIndexCmd
33
34 -item Class: ToIndexCmd FromIndexCmd
35
36 -item Switch: -toindexcmd -fromindexcmd
37
38 These two options specify callbacks that are called with a list of
39 indexes and are responsible for translating them to/from indexes
40 that the base Text widget can understand. The callback is passed
41 the widget followed by a list of indexes, and should return a list
42 of translated indexes. -toindexcmd should translate from 'user'
43 indexes to 'native' Text-compatible indexes, and -fromindexcmd
44 should translate from 'native' indexes to 'user' indexes.
45
46 The default callbacks simply add/subtract the offset given by the
47 -linestart option for all indexes in 'line.character' format.
48
49 It would probably be prudent to make these functions inverses of
50 each other.
51
53 import
54 To make new Reindex widgets, this function should be called via use
55 with the name of the Text-like base class that you are extending
56 with "Reindex" capability. 'use base(Tk::Reindex
57 Tk::nameofbasewidget)' should also be specified for that widget.
58
60 I've used the word "indexes" instead of "indices" throughout the
61 documentation.
62
63 All the built-in perl code for widget bindings & methods will use the
64 new 'user' indexes. Which means all this index manipulation might
65 might break code that is trying to parse/manipulate indexes. Or even
66 assume that '1.0' is the beginning index. Tk::Text::Contents comes to
67 mind.
68
70 Andrew Allen <ada@fc.hp.com>
71
72 This code may be distributed under the same conditions as Perl.
73
74
75
76Tk1.1 2022-07-22 Reindex(3)