Text Indexes and Modifiers

In a Text widget, several indexes are defined to identify positions in the text. These are used by the methods that retrieve and manipulate text.

n.m

Numbers representing character m on line n

@ x,y

The character closest to the x,y coordinate

end

The end of the text

insert

The character after the insert cursor

current

The position closest to the mouse cursor

mark

Other marks defined for the widget (see discussion of text marks later in this section)

sel.first

The first selected character

sel.last

The character just after the last selected character

tag.first

The first character in the widget of the specified tag type

tag.last

The character just after the last character of the specified tag type

widget

The location of an embedded widget

There are also several modifiers to use with text indexes. They are:

- n lines+ n lines

n lines before or after the index

- n chars+ n chars

n characters before or after the index

linestart

The first character on the line

lineend

The last character on the line (often a newline)

wordstart

The first character in the word

wordend

The character after the last character in the word

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.