Indicates char'th character on line line. Lines are numbered from 1 for consistency with other UNIX programs that use this numbering scheme. Within a line, characters are numbered from 0. If char is end then it refers to the newline character that ends the line, and if char is begin then it refers the first character at start of the line.
…
Indicates the start of the text (the character just at the start of the first line).
…
It is logical to introduce the additional special index specifier begin, as the counterpart of end. This should imply that begin has the same precedence as end (see section INDICES in Tk documentation), but for compatibility reasons it has the lowest precedence, to avoid that any existing application may break. But in a future version the precedence has to be corrected.
Therefore another chapter has to be added to section KNOWN BUGS, because in documentation (see above) it has been introduced with the intended precedence.
Currently the special index specifier begin has the lowest precedence, although it should have the same precedence as the special index special end (see section INDICES). In a future release this will be corrected. The current behavior is a workaround, avoiding that existing applications will break with the introduction of begin.
The difference between 'pathName compare mark == 1.0' and 'pathName compare mark == begin' is:
begin is more expressive than 1.0.
The user must not remember if the first line starts with 1.0, or something else (it's not really logical that the first line is 1, and the first character is 0 – even the original implementation of library/text.tcl is confusing 1.0 with 0.0). Now there is a clean way how to detect whether a position is on the first line: '[$w compare [$w index "$pos linestart"] == begin]' (in the revised implementation the linestart/lineend computation is super-fast (constant time)).
begin is the (yet missing) counterpart of end.
Additionally begin can be used to denote a start range non-numerical in the same way how end will be used to denote an end range non-numerical.
The text widget now will print a warning on stderr if a mark with name "begin" will be set (Linux and Mac – Windoze is silently ignoring the default destination of error messages).
Indicates the character that covers the pixel whose x and y coordinates within the text's window are x and y. If no element covers that point, then the closest element to that point is used. It's allowed to use first to denote the first pixel coordinate, and last to denote the last pixel coordinate within the text's window, for both x and y.
Also this is an important extension, and adds new functionality. In general an expression like "@0,[winfo height .t]" will not give the same result as "@first,last". It is recommended to add this extension also to other widgets, like the listbox.
With the introduction of these extensions it is possible to write a sophisticated editor control without any concrete numbers, a computed editor layout don't need concrete numbers. This means that the definition of indices is now complete.
Note: In fact the new form "@first,first", etc., is incompatible to prior releases, but it is not expected that any existing application will break, I'm sure that nobody is using such a form for the name of a mark or image. But with the new special specifier begin the things are different, it needs a transition time.
We are introducing another extension, with the goal to save some thousands of tags and bindings under some common conditions.
...
...
Indicates the first character in the region (a connected span of text sharing the same tag) nearby the current mark (it is left from, right from, or inside the tagged region) that has been tagged with tag. This form generates an error if no character is currently tagged with tag nearby the current mark.
Indicates the character just after the last one in the region (a connected span of text sharing the same tag) nearby the current mark (it is left from, right from, or inside the tagged region) that has been tagged with tag. This form generates an error if no character is currently tagged with tag nearby the current mark.
And here is one use case: We assume that our text contains many thousands of chess moves, hovering a move will highlight this move, and when clicking on the highlighted move any move dependent function will be performed. The first approach is like the one below (a simplified example). In a game with some thousands moves (because of many sub-variations) it will use some thousands different tags, and some thousands bindings.
With the help of the new index types we can reduce the number of tags, now we need only two ones. Moreover it will save bindings.
Note that this method to share tags needs the new transition mode displayline, see widget option -transitionmode.