tw wrap

History Key

  • New content
  • Removed content

Recent Versions

Choose two versions to compare, or click the link to view it.

  1. 3. about 3 years by blicharski
  2. 2. about 3 years by blicharski
  3. 1. about 3 years by blicharski
 

(Don't worry about last line in char wrap example, the superfluous text will be clipped).

I've tested my script against text widget's examples from tcl wiki, and it worked fine.

Here is the scirpt, it is the simplest version, it will fail if there is an embedded window in the text widget, but it could be fixed by comaring y values returned from bbox of characters from left side of window and right side of window (if the characters will be in the same line the y coordinates will be the same).

proc getInfo {w} {

    set j 1

    while {[$w bbox $j.0] == ""} {
        incr j
    }

    while {[$w bbox $j.0] != ""} {
        set i 0
        set lineLen [$w count $j.0 $j.end]
        set befPos 0

        while {$i < $lineLen} {
            set ypos [lindex [$w bbox $j.$i] 1]
            if {$ypos > $befPos} {
                puts ""
            }

            puts -nonewline [lindex [$w dump -text $j.$i] 1]
            set befPos [lindex [$w bbox $j.$i] 1]
            incr i
        }
        #puts ""

        incr j
    }
}