Additional Command 'lineno'

It's quite common that the line number is needed. In original implementation it's uncomfortable to retrieve this information from an index, for example: [lindex [split [$w index $index] .] 0]. The revised implementation offers a command for this purpose:

pathName lineno index

Returns the line number corresponding to index. Index may have any of the forms described under INDICES above.

If the widget is dead (don't contains any lines – possible only if option -start/endline is involved), then 0 (zero) will be returned.

Now the thing is easier: [$w lineno $index]. Note that this command also allows to calculate line numbers, for example: [$w lineno "$index linestart -1c"].