Version 0 of How many lines in a text widget?

Updated 2006-01-15 10:37:23

If we need to incrementally work through the lines of a text widget we can obtain the content sixe in terms of lines and characters using:

<pathName> index end

This will, however return a a value such as 5.5, ie. five lines '.' and five characters. If we just need the lines, and not the characters, (eg. in an incremented loop) then the following proc is always handy.

 #---------------
 # return actual number of lines in a text widget
 #---------------
 proc _lines {t} {
  puts [$t index end]
  return [expr [lindex [split [$t index end] .] 0] -1]
 }

 proc demo {} {
    text .txt

 }