Posted to tcl by schelte at Mon Mar 11 19:09:50 GMT 2013view pretty

proc searchnext w {
    global Find opt

    reorder .f.sr.f
    $w tag remove hilite 1.0 end
    set options {}
    if {$opt(direction) ne "backward"} {
        lappend options -forward
        set start insert+1c
    } else {
        lappend options -backward
        set start insert
    }
    if {!$opt(matchcase)} {
        lappend options -nocase
    }
    set pos [$w search {*}$options -count n -- $Find $start]
    if {$pos ne ""} {
         $w mark set insert $pos
         $w see insert
         $w tag add hilite $pos $pos+${n}c
    }
}