# This module contains code that has to do with text marks. These are used to # implement the HTML tag, as well as the links. # When we encounter a "text tag, we create a tk mark by the # same name "foo", with $mark used to count the marks in the current # document. We also create a link that starts at the mark, which will be # given a distinct color to distinguish it from other links. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Create a new mark with a given name. proc NewMark {w name} { global V me Ltag Link link Lnum mark if {$V>2} {set id "$me/NewMark $w $name"} incr mark set i [$w index insert] if {$V>3} {puts "$id: Mark $mark)=\"$name\" i=$i"} if {$V>3} {puts "$id: $w mark set $name $i"} set x [$w mark set $name $i] if {$V>3} {puts "$id: Got {$x}"} if {$V>3} {puts "$id: $w mark gravity $name left"} set x [$w mark gravity $name left] if {$V>3} {puts "$id: Got {$x}"} set Link([incr link]) $name if {$V>3} {puts "$id: Created Link($link)=\"$name\" for mark \"$name\""} $w tag bind Lnk$link "LinkEnter $w $link %X %Y %W" $w tag bind Lnk$link "LinkLeave $w $link %X %Y %W" set Lnum Lnk$link if {$V>3} {puts "$id: Change Ltag from $Ltag to Lname for Lnum=\"$Lnum\""} set Ltag Lname } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Go to a mark. That is, adjust the position in the window w so that the mark # is visible. proc ToMark {w mark} { global V me if {$V>2} {set id "$me/ToMark $w $name"} if {$V>3} {puts "$id: \"$mark\" is the target."} set i [$w index $mark] if {$V>3} {puts "$id: $w see $mark (index=$i)"} set x [$w see $mark] if {$V>3} {puts "$id: got \"$x\""} if {$V>3} {puts "$id: $w mark set insert $mark"} set x [$w mark set insert $mark] if {$V>3} {puts "$id: got \"$x\""} }