# Description: Moves old msgs from status window to query window proc find {w} { global info set text [$info(text,.0) dump -tag -text 1.0 end] set copy {} set pos 1.0 set lines {} while {[set f [$info(text,.0) search -forward -exact -nocase -- *$info(nick,$w) $pos end]] != ""} { set pos [$info(text,.0) index "$f lineend"] lappend lines [lindex [split $f .] 0] } if {$lines == ""} {return} foreach x $lines { eval lappend dump [$info(text,.0) dump -tag -text $x.0 "$x.0+1l"] } set t $info(text,$w) $t configure -state normal foreach {d text pos} $dump { if {$d == "text"} {$t insert end $text} } addtags $t $dump reformattext $t $t configure -state disabled $info(text,.0) configure -state normal foreach x [lsort -integer -decreasing $lines] {$info(text,.0) delete $x.0 $x.0+1l} $info(text,.0) configure -state disabled } proc addtags {w tags} { set cur 0 set prev -1 foreach {d tag pos} $tags { if {$d == "tagon" && $tag != "privmsg"} { set line [lindex [split $pos .] 0] set char [lindex [split $pos .] 1] if {$line != $prev} {set prev $line; incr cur} set t($tag) $cur.$char } elseif {$d == "tagoff" && [info exists t($tag)] && $t($tag) != ""} { set char [lindex [split $pos .] 1] $w tag add $tag $t($tag) $cur.$char unset t($tag) } } } proc reformattext {w} { set line 1 foreach x [split [$w get 1.0 end] \n] { if {[set s [string first "-> *" $x]] > -1} { set e [string first * $x [expr {$s + 5}]] $w delete $line.$s $line.$e+1c $w insert $line.$s "<$::me>" } elseif {[set s [string first " *" $x]] > -1} { set e [string first * $x [expr {$s + 2}]] set nick [$w get $line.$s+2c $line.[string first ! $x]] $w delete $line.$s+1c $line.$e+1c $w insert $line.$s+1c "<$nick>" } incr line } } proc unload {} { unbind all <> "[namespace current]::find %W" } startup bind all <> "+[namespace current]::find %W"