proc more filename { set f [open $filename] catch {wce siphide} ;# hide keyboard set w [toplevel .[clock clicks]] wm title $w [file tail $filename] bind $w <FocusOut> "catch {close $f}; destroy $w" bind $w <Up> "$w.t yview scroll -1 page" bind $w <Down> "more'page $w.t $f; $w.t yview scroll 1 page" text $w.t -wrap word -height 20 -width 38 $w.t tag config blue -foreground blue grid $w.t -sticky news more'page $w.t $f focus -force $w }#-- Page presentation
proc more'page {t f} { if [eof $f] return set nmax 20 set n 0 $t config -state normal while {[gets $f line]>=0} { $t insert end $line\n set ln [expr {[string length $line]/38+1}] if {[incr n $ln]>$nmax} break } $t insert end [expr {[eof $f]? "EOF": "more..\n"}] blue $t config -state disabled }
See IDE: from cathedral to patchwork bazaar for what I do this for.
Category File