source: trunk/lstview @ 674

Last change on this file since 674 was 667, checked in by toby, 16 years ago

# on 2003/04/10 21:58:31, toby did:
change startup section

  • Property rcs:author set to toby
  • Property rcs:date set to 2003/04/10 21:58:31
  • Property rcs:lines set to +10 -3
  • Property rcs:rev set to 1.12
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 21.4 KB
Line 
1#!/bin/sh
2# the next line restarts this script using wish found in the path\
3exec wish "$0" "$@"
4# If this does not work, change the #!/usr/bin/wish line below
5# to reflect the actual wish location and delete all preceeding lines
6#
7# (delete here and above)
8#!/usr/bin/wish
9# $Id: lstview 667 2009-12-04 23:10:00Z toby $
10set Revision {$Revision: 667 $ $Date: 2009-12-04 23:10:00 +0000 (Fri, 04 Dec 2009) $}
11# display a .LST file in a text box
12# updates 8/26 add bindings for page-up, -down, uparrow, downarrow
13# read from gzip .LST.gz files using gunzip and then append the .LST file
14# start work on plotting variables change next line to use
15set txtvw(plotvars) 1
16set txtvw(font) "Courier"
17set txtvw(menulength) 25
18set txtvw(stringcount) 0
19set txtvw(string) {}
20set txtvw(sum) 0
21set txtvw(hideplot) 0
22# maximum characters to read initially from a .LST file
23set txtvw(maxchars) 1000000
24if {$tcl_platform(platform) == "windows"} {
25   # windows is slow!
26   set txtvw(maxchars) 200000
27}
28if {[set expnam [lindex $argv 0]] == ""} {
29    tk_dialog .warn Notify "No filename specified" error 0 OK
30    destroy .
31}
32set filename $expnam.LST
33set zfil {}
34set lstfp {}
35# is there a compressed version of the file?
36if {[file exists $filename.gz] && $tcl_platform(platform) != "windows"} {
37    set zfil [open "|gunzip < $filename.gz" r]
38}
39set box {}
40set txtvw(followcycle) 1
41
42proc waitmsg {message} {
43    set w .wait
44    # kill any window/frame with this name
45    catch {destroy $w}
46    pack [frame $w]
47    frame $w.bot -relief raised -bd 1
48    pack $w.bot -side bottom -fill both
49    frame $w.top -relief raised -bd 1
50    pack $w.top -side top -fill both -expand 1
51    label $w.msg -justify left -text $message -wrap 3i
52    catch {$w.msg configure -font \
53                -Adobe-Times-Medium-R-Normal--*-180-*-*-*-*-*-*
54    }
55    pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m
56    label $w.bitmap -bitmap info
57    pack $w.bitmap -in $w.top -side left -padx 3m -pady 3m
58    update
59}
60
61proc donewaitmsg {} {
62    catch {destroy .wait}
63}
64waitmsg "Reading $expnam.LST, Please wait"
65
66set txtvw(runnumber) 0
67
68proc findcyc {win menu {pos 0.0}} {
69    global txtvw
70    global trackinglist
71    set i 0
72    set lastpos {}
73    # loop over cycles
74    set startpos $pos
75    # get current cycle number
76    set pos [$win search -regexp -count chars \
77            {Cycle *[0-9]+ +There} $pos+1line end]
78    while {$pos != ""} {
79        # add the current cycle number to the menu
80        set line [lindex [split $pos .] 0]
81        $win tag add cycle $line.1 $line.10
82        incr i
83        set cycle {}
84        regexp {Cycle *([0-9]+) +There} [$win get $pos $line.end] x cycle
85        if {$cycle != ""} {
86            set lastpos $pos
87            set txtvw(lastcycle) "Cycle $cycle"
88            .a.goto.menu entryconfigure 1 -state normal
89            $menu insert 1 command \
90                    -font 6x12 \
91                    -label "Cycle $cycle" \
92                    -command "$win see $pos"
93            if {[$menu index end] > $txtvw(menulength)} {$menu delete end}
94        }
95        # get next cycle number
96        set nextpos [$win search -regexp -count chars \
97                {Cycle *[0-9]+ +There} $pos+1line end]
98        if {$nextpos == ""} {
99            set epos end
100        } else {
101            set epos $nextpos
102        }
103
104        # loop to highlight all Rwp & Rp values
105        set npos $startpos
106        set npos [$win search -regexp -count chars \
107                {Hstgm *[0-9]+} $npos+1line $pos]
108        while {$npos != ""} {
109            set line [lindex [split $npos .] 0]
110            set x [$win get $line.0 $line.end]
111            scan $x %s%d%s%d%d%f%f%f a hst c d e f rwp rp
112            foreach d {Rwp Rp} value "$rwp $rp" {
113                set v ${d}_$hst
114                set var tracklist_$v
115                set trackinglist($v) "$d hist $hst"
116                global $var
117                set ${var}($cycle) $value
118            }
119            $win tag add rval $npos $line.end
120            set npos [$win search -regexp -count chars \
121                {Hstgm *[0-9]+} $npos+1line $pos]
122        }
123        # get the CHI**2 value
124        set chipos [$win search {Reduced CHI**2 =} $pos $epos]
125        if {$chipos != ""} {
126            $win tag add chi $chipos+8chars $chipos+23chars
127            set chi [string trim [$win get $chipos+16chars $chipos+23chars]]
128            set txtvw(lastchi) "Chi**2 $chi"
129            set var tracklist_chi2
130            set trackinglist(chi2) "red. Chi squared"
131            global $var
132            set ${var}($cycle) $chi
133        }
134        set sumpos [$win search {Final variable sum} $pos $epos]
135        if {$sumpos != ""} {
136            set line [$win get $sumpos "$sumpos lineend"]
137            regexp {: *([0-9\.]+) } $line a finalshift
138            set txtvw(finalshift) "Shift/SU $finalshift"
139            set var tracklist_fshft2
140            set trackinglist(fshft2) "Sum((shft/su)**2)"
141            global $var
142            set ${var}($cycle) $finalshift
143        }
144        # loop to highlight all R(F**2) values
145        set npos $pos
146        set npos [$win search -regexp -count chars \
147                {Histogram *[0-9]+} $npos+1line $epos]
148        while {$npos != ""} {
149            set line [lindex [split $npos .] 0]
150            set x [$win get $line.0 $line.end]
151            catch {
152                regexp {gram *([0-9]+).*\) =(.*)} $x a hst rf2
153                set var tracklist_Rbragg_$hst
154                set trackinglist(Rbragg_$hst) "R(Bragg) hist $hst"
155                global $var
156                set ${var}($cycle) $rf2
157            }
158            $win tag add rval $npos $line.end
159            set npos [$win search -regexp -count chars \
160                    {Histogram *[0-9]+} $npos+1line $epos]
161        }
162        # get ready to loop again
163        set startpos $pos
164        set pos $nextpos
165    }
166    if {$txtvw(followcycle) && $lastpos != ""} {$win see $lastpos}
167}
168
169proc findrun {win {menu ""} {pos 0.0}} {
170    global txtvw
171    while {$pos != ""} {
172        set pos [$win search "Program GENLES" $pos+1line end]
173        if {$menu != "" && $pos != ""} {
174            incr txtvw(runnumber)
175            .a.goto.menu entryconfigure 2 -state normal
176            $menu insert 1 command \
177                    -font 6x12 \
178                    -label "Run $txtvw(runnumber)" \
179                    -command "$win see $pos"
180            if {[$menu index end] > $txtvw(menulength)} {$menu delete end}
181        }
182    }
183}
184
185
186proc findsum {win menu {pos 0.0}} {
187    global txtvw
188    global trackinglist
189    set pos [$win search {Summary table} $pos+1line end]
190    # found a summary, now search back for the cycle number
191    while {$pos != ""} {
192        # add it to the menu
193        incr txtvw(sum)
194        .a.goto.menu entryconfigure 3 -state normal
195        $menu insert 1 command \
196                -font 6x12 \
197                -label "Summary $txtvw(sum)" \
198                -command "$win see $pos"
199        if {[$menu index end] > $txtvw(menulength)} {$menu delete end}
200       
201        set npos [$win index "$pos+1line linestart"]
202        set fpos [$win index $pos-1line]
203       
204        if {!$txtvw(plotvars)} continue
205
206        # parse outs the last listed cycle number
207        set lstcyc {}
208        set fpos [$win search -backwards -nocase -regexp {cycle *[0-9]+ } $pos]
209        if {$fpos != ""} {
210            set end [$win index "$fpos lineend"]
211            set lstcyc [lindex [$win get $fpos $end] 1]
212        }
213        # get the cycle offset
214        set ncyc [lindex [$win get $npos "$npos lineend"] end]
215        set npos [$win index "$npos+1line linestart"]
216       
217        set end [$win index end]
218        # now read through the summary table
219        while {![string match *Fraction* \
220                [set line [$win get $npos "$npos lineend"]] \
221                ]} {
222            set v1 [string range $line 1 9]
223            # make a name without spaces
224            set v "zz$v1"
225            regsub -all " " $v "_" v
226            set var tracklist_$v
227            catch {
228                # are there any invalid numbers in the list?
229                foreach value [string range $line 10 end] {
230                    expr [string trim $value]
231                }
232
233                # passed syntax check, add to list
234                set trackinglist($v) "shift/SU $v1"
235                global $var
236               
237                set i 0
238                foreach value [string range $line 10 end] {
239                    incr i
240                    set cycle [expr {$lstcyc - $ncyc + $i}]
241                    set ${var}($cycle) $value
242                }
243            }
244            set npos [$win index "$npos+1line linestart"]
245            if {$npos == $end} break
246        }
247        set pos [$win search {Summary table} $npos+1line end]
248    }
249}
250
251proc findsetstring {win string {menu ""} {pos 0.0}} {
252    global txtvw
253    while {$pos != ""} {
254        set pos [$win search -regexp -count chars \
255                $string $pos+1line end]
256        if {$menu != "" && $pos != ""} {
257            $win tag add found $pos "$pos + $chars chars"
258            incr txtvw(stringcount)
259            $menu insert 1 command \
260                    -font 6x12 \
261                    -label "loc #$txtvw(stringcount)" \
262                    -command "$win see $pos"
263            if {[$menu index end] > $txtvw(menulength)} {$menu delete end}
264        }
265    }
266}
267
268proc setsearchstring { } {
269    global txtvw
270    set txtvw(stringcount) 0
271    .a.goto.menu entryconfigure 5 -state disabled -label ""
272    .a.goto.menu.str delete 1 end
273    catch {.txt tag delete found}
274    .txt tag config found -foreground red
275    if {[string trim $txtvw(entry)] == ""} {
276        set txtvw(string) {}
277        return
278    } else {
279        set txtvw(string) [string trim $txtvw(entry)]
280    }
281    findsetstring .txt $txtvw(string) .a.goto.menu.str
282    if {$txtvw(stringcount) > 0} {
283        .a.goto.menu entryconfigure 5 -state normal -label "$txtvw(string)..."
284    }
285}
286
287proc updatetext {"fil {}"} {
288    global txtvw filename tcl_platform lstfp
289    set repeat 0
290    if {$fil == ""} {
291        set repeat 1
292        after 5000 updatetext
293        set fil $lstfp
294    }
295    set txt {}
296    catch {set txt [read $fil]}
297    if {$txt == ""} return
298    .txt config -state normal
299    set oldend [.txt index end]
300    # truncate the text if too long
301    if {[string length $txt] > $txtvw(maxchars) && $repeat == 0} {
302        set beg [expr [string length $txt] - $txtvw(maxchars)]
303        .txt insert end "(first $beg characters in file skipped)\n"
304        .txt insert end [string range $txt $beg end]
305    } else {
306        .txt insert end $txt
307    }
308    # don't disable in Win as this prevents the highlighting of selected text
309    if {$tcl_platform(platform) != "windows"} {
310        .txt config -state disabled
311    }
312    update idletasks
313    findrun .txt .a.goto.menu.run $oldend
314    update
315    findcyc .txt .a.goto.menu.cyc $oldend
316    update
317    findsum .txt .a.goto.menu.sum $oldend
318    update
319   
320    if {$txtvw(string) != ""} {
321        findsetstring .txt $txtvw(string) .a.goto.menu.str $oldend
322        if {$txtvw(stringcount) > 0} {
323            .a.goto.menu entryconfigure 5 -state normal -label "$txtvw(string)..."
324        }
325    }
326}
327
328proc GetSearchString {} {
329    catch {destroy .str}
330    toplevel .str
331    grab .str
332    pack [frame .str.1] -side top
333    pack [frame .str.2] -side top
334    pack [label .str.1.l -text "Search String"] -side left
335    pack [entry .str.1.e -textvariable txtvw(entry) -width 12] -side left
336    pack [label .str.1.2 -text "(regexp)"] -side left
337    pack [button .str.2.ok -text "Search" -command \
338            "setsearchstring; destroy .str" ] -side left
339    pack [button .str.2.q -text "Quit" -command \
340            "destroy .str" ] -side left
341# bind to RETURN here   
342#    bind .str
343}
344
345proc findstring {win str1 {str2 ""}} {
346    set pos [$win search -backwards $str1 end]
347    if {$pos == "" && $str2 != ""} {
348        set pos [$win search -backwards $str2 end]
349    }
350    if {$pos == ""} return
351    $win see $pos
352}
353
354proc SaveOptions {} {
355    global txtvw
356    set fp [open [file join ~ .gsas_config] a]
357    puts $fp "set txtvw(followcycle) [list $txtvw(followcycle)]"
358    puts $fp "set txtvw(font) [list $txtvw(font)]"
359    close $fp
360}
361
362proc aboutgsas {} {
363    global Revision
364    tk_dialog .warn About "
365GSAS\n\
366A. C. Larson and\n R. B. Von Dreele,\n LANSCE, Los Alamos\n\n\
367LSTVIEW\nB. Toby, NIST\nNot subject to copyright\n\n\
368$Revision\n\
369" {} 0 OK
370}
371
372#----------------------------------------------------------------
373# where are we?
374set expgui(script) [info script]
375# translate links -- go six levels deep
376foreach i {1 2 3 4 5 6} {
377    if {[file type $expgui(script)] == "link"} {
378        set link [file readlink $expgui(script)]
379        if { [file  pathtype  $link] == "absolute" } {
380h           set expgui(script) $link
381        } {
382            set expgui(script) [file dirname $expgui(script)]/$link
383        }
384    } else {
385        break
386    }
387}
388
389# fixup relative paths
390if {[file pathtype $expgui(script)] == "relative"} {
391    set expgui(script) [file join [pwd] $expgui(script)]
392}
393set expgui(scriptdir) [file dirname $expgui(script) ]
394set expgui(docdir) [file join $expgui(scriptdir) doc]
395# location for web pages, if not found locally
396set expgui(website) www.ncnr.nist.gov/xtal/software/expgui
397
398source [file join $expgui(scriptdir) gsascmds.tcl]
399source [file join $expgui(scriptdir) opts.tcl]
400
401# override options with locally defined values
402if {[catch {
403    foreach file [list \
404                      [file join $expgui(scriptdir) localconfig] \
405                      [file join ~ .gsas_config]] {
406        if [file exists $file] {source $file}
407    }
408} errmsg]} {
409    set msg "Error reading file $file (aka [file nativename $file]): $errmsg"
410    MyMessageBox -parent . -title "Customize warning" \
411        -message $msg -icon warning -type Ignore -default ignore \
412        -helplink "expguierr.html Customizewarning"
413}
414
415set txtvw(lastchi) {}
416set txtvw(lastcycle) {}
417set txtvw(finalshift) {}
418text .txt -width 100 -wrap none \
419        -yscrollcommand ".yscroll set" \
420        -xscrollcommand ".xscroll set" 
421if {$tcl_version >= 8.0} {.txt config -font $txtvw(font)}
422scrollbar .yscroll -command ".txt yview"
423scrollbar .xscroll -command ".txt xview" -orient horizontal
424grid .xscroll -column 0 -row 2 -sticky ew
425grid .txt -column 0 -row 1 -sticky nsew
426grid .yscroll -column 1 -row 1 -sticky ns
427grid columnconfigure . 0 -weight 1
428grid rowconfigure . 1 -weight 1
429wm title . "View $filename"
430wm iconname . $filename
431grid [frame .a -bd 2 -relief raised] -column 0 -row 0 -columnspan 2 -sticky ew
432pack [menubutton .a.file -text File -underline 0 -menu .a.file.menu] \
433            -side left
434menu .a.file.menu
435.a.file.menu add command -label "Delete $filename" -command KillLSTfile
436.a.file.menu add command -label "Trim $filename" -command TrimLSTfile
437.a.file.menu add command -label Exit -command "destroy ."
438
439# windows copy command. Should not be needed in X windows
440if {$tcl_platform(platform) == "windows"} {
441    pack [menubutton .a.edit -text Edit -underline 0 -menu .a.edit.menu] \
442            -side left
443    menu .a.edit.menu
444    .a.edit.menu add command -label copy \
445            -command {catch {clipboard append [selection get]}}
446}
447
448pack [menubutton .a.goto -text "Go To" -underline 0 -menu .a.goto.menu] \
449        -side left
450menu .a.goto.menu
451.a.goto.menu add cascade -label "Cycle #"  -menu .a.goto.menu.cyc \
452        -state disabled
453menu .a.goto.menu.cyc
454.a.goto.menu add cascade -label "Refinement Run #"  -menu .a.goto.menu.run \
455        -state disabled
456menu .a.goto.menu.run
457.a.goto.menu add cascade -label "Summary #"  -menu .a.goto.menu.sum \
458        -state disabled
459menu .a.goto.menu.sum
460.a.goto.menu add command -label "Set Search String" -command GetSearchString
461.a.goto.menu add cascade -label ""  -menu .a.goto.menu.str -state disabled
462menu .a.goto.menu.str
463
464pack [menubutton .a.options -text "Options" -underline 0 \
465        -menu .a.options.menu] \
466            -side left
467menu .a.options.menu
468.a.options.menu  add checkbutton -label "Auto Advance" -variable txtvw(followcycle) 
469
470if {$tcl_version >= 8.0} {
471    pack [label .a.fontl -text "  Font:"] -side left
472    set fontbut [tk_optionMenu .a.fontb txtvw(font) ""]
473    pack .a.fontb -side left
474    $fontbut delete 0 end
475    foreach f {5 6 7 8 9 10 11 12 13 14 15 16} {
476        $fontbut add command -label "Courier $f" -font "Courier $f"\
477                -command "set txtvw(font) \"Courier $f\"; \
478                .txt config -font \$txtvw(font)"
479    }
480}
481
482.a.options.menu add command -label "Save Options" -underline 1 \
483        -command "SaveOptions"
484
485proc postingvars {} {
486    global trackinglist
487    eval destroy [winfo children .plot.c.f]
488    set i 0
489    foreach var [lsort [array names trackinglist]] {
490        grid [checkbutton .plot.c.f.$i -text $trackinglist($var) \
491                -pady 0 -command plotvars -variable plotlist($var)] \
492                -column 0 -row [incr i] -sticky w
493    }
494}
495
496proc makeplot {} {
497    # handle Tcl/Tk v8+ where BLT is in a namespace
498    #  use the command so that it is loaded
499    catch {blt::graph}
500    catch {
501        namespace import blt::graph
502    }
503    toplevel .plot
504    grid [graph .plot.g] -col 0 -row 0 -sticky news
505    canvas .plot.c \
506            -scrollregion {0 0 5000 1000} -width 40 -height 250 \
507            -yscrollcommand ".plot.s set"
508    scrollbar .plot.s -command ".plot.c yview"
509    grid .plot.c -col 1 -row 0 -sticky news
510        frame .plot.c.f -class SmallFont
511    .plot.c create window 0 0 -anchor nw -window .plot.c.f
512    grid columnconfigure .plot 0 -weight 1
513    grid rowconfigure .plot 0 -weight 1
514    Blt_ZoomStack .plot.g
515    Blt_ActiveLegend .plot.g
516    .plot.g config -title ""
517    .plot.g xaxis config -title "cycle"
518    .plot.g yaxis config -title ""
519    wm iconify .plot
520}
521
522proc plotvars {} {
523    raise .plot
524    eval .plot.g element delete [.plot.g element names]
525    global trackinglist
526    global plotlist
527    set num 0
528    foreach v [lsort [array names trackinglist]] {
529        set datalist {}
530        if $plotlist($v) {
531            incr num
532            set var tracklist_$v
533            global $var
534            set color [lindex {red green blue magenta cyan yellow} \
535                    [expr $num % 6]]
536            foreach n [lsort -integer [array names $var]] {
537                lappend datalist $n [set ${var}($n)]
538            }
539            .plot.g element create "$var" -data $datalist -color $color \
540                    -label $trackinglist($v)
541        }
542    }
543}
544
545proc hideplot {} {
546    global txtvw
547    if {![winfo exists .plot]} {
548        makeplot
549        postingvars
550    }
551    # hide or show the plot
552    if {$txtvw(hideplot) != 1} {
553        wm iconify .plot
554    } else {
555        wm deiconify .plot
556        update idletasks
557        # size the box width & scrollregion height
558        set sizes [grid bbox .plot.c.f]
559        .plot.c config -scrollregion $sizes -width [lindex $sizes 2]
560        # is the scroll bar needed?
561        if {[winfo height .plot.c] >= [lindex $sizes 3]} {
562            grid forget .plot.s
563        } else {
564            grid .plot.s -col 2 -row 0 -sticky news
565        }
566    }
567}
568
569
570proc KillLSTfile {} {
571    global filename lstfp tcl_platform
572    # confirm the delete
573    set ans [tk_dialog .warn Notify \
574            "OK to delete the contents of $filename?" "" 0 Yes No]
575    if {$ans != 0} return
576    # stop the updates
577    after cancel updatetext
578    # zero out the file
579    close $lstfp
580    set lstfp [open $filename w+]
581    .txt config -state normal
582    .txt delete 0.0 end
583    ClearMenus
584    updatetext
585}
586
587proc TrimLSTfile {} {
588    global filename lstfp tcl_platform txtvw
589   
590    # get the last refinement run position
591    set loc {}
592    # get the starting location
593    catch {
594        set loc [lindex [.a.goto.menu.run entrycget 1 -command] end]
595        set loc [.txt index "$loc - 2lines"]
596        set txtvw(delete) [expr {100.*$loc/[.txt index end]}]
597        .txt see $loc
598
599    }
600    if {$loc == ""} {
601        set txtvw(delete) [expr {50.* \
602                ([lindex [.txt yview] 0] + [lindex [.txt yview] 1])}]
603        set loc [expr {int(0.5+ $txtvw(delete) * [.txt index end]/100.)}].0
604    }
605
606    catch {toplevel .trim}
607    eval destroy [winfo children .trim]
608    wm title .trim "Trim $filename"
609    pack [label .trim.0 -text "File $filename has [expr {int([.txt index end])}] lines total."] -side top
610    pack [label .trim.1 -text "Select percentage of file to delete."] \
611            -anchor w -side top
612   
613    # set the slider resolution so that 1 division is on the
614    # order of 1-2 lines
615    set res .5
616    while {$res > 200./[.txt index end] && $res > 0.01} {
617        if {[string match *5* $res]} {
618            set res [expr $res/2.5]
619        } else {
620            set res [expr $res/2.]
621        }
622    }
623    pack [scale .trim.2 -command HighlightText -orient horizontal \
624            -variable txtvw(delete) \
625            -resolution $res] -expand yes -fill x
626    pack [frame .trim.3]
627    pack [button .trim.3.a -text Trim \
628            -command {DeleteSelectedText; destroy .trim} \
629            ] -side left
630    pack [button .trim.3.b -text Cancel -command {destroy .trim} ] -side left
631    # create a binding so that we can click on the text box
632    .txt tag delete b
633    .txt tag add b 0.0 end
634    .txt tag bind b <1> "ClickHighlightText %x %y"
635    # show the region pending delete
636    .txt tag delete pend
637    .txt tag add pend 0.0 $loc
638    .txt tag config pend -foreground grey
639}
640
641proc ClickHighlightText {x y} {
642    global txtvw
643    if {![winfo exists .trim]} return
644    set loc [.txt index "@$x,$y linestart"]
645    set txtvw(delete) [expr {100.*$loc/[.txt index end]}]
646    .txt tag delete pend
647    .txt tag add pend 0.0 $loc
648    .txt tag config pend -foreground grey
649}
650
651proc DeleteSelectedText {} {
652    global filename lstfp
653    .txt config -state normal
654    eval .txt delete [.txt tag nextrange pend 0.0]
655    # stop the updates
656    after cancel updatetext
657    # zero out the file
658    close $lstfp
659    set lstfp [open $filename w+]
660    puts $lstfp [.txt get 0.0 end]
661    .txt delete 0.0 end
662    ClearMenus
663    seek $lstfp 0
664    updatetext
665}
666
667proc ClearMenus {} {
668    foreach m {str run cyc sum} {
669        .a.goto.menu.$m delete 1 end
670    }
671    foreach num {1 2 3 5} {
672        .a.goto.menu entryconfigure $num -state disabled
673    }
674    global txtvw
675    set txtvw(runnumber) 0
676    set txtvw(sum) 0
677}
678
679proc HighlightText {args} {
680    global txtvw
681    set loc [expr {int(0.5+ $txtvw(delete) * [.txt index end]/100.)}].0
682    .txt tag delete pend
683    .txt tag add pend 0.0 $loc
684    .txt tag config pend -foreground grey
685    .txt see $loc
686}
687
688pack [menubutton .a.help -text Help -underline 0 -menu .a.help.menu] -side right
689menu .a.help.menu
690.a.help.menu add command -command aboutgsas -label "About"
691
692grid [frame .but ] -column 0 -row 3 -columnspan 2 -sticky ew
693pack [label .but.lbl2 -textvariable txtvw(lastcycle) \
694        -relief sunken -bd 2] -side left
695pack [label .but.lbl3 -textvariable txtvw(lastchi) \
696        -relief sunken -bd 2] -side left
697pack [label .but.lbl4 -textvariable txtvw(finalshift) \
698        -relief sunken -bd 2] -side left
699bind all <Control-KeyPress-c> {destroy .}
700bind . <KeyPress-Prior> ".txt yview scroll -1 page"
701bind . <KeyPress-Next> ".txt yview scroll 1 page"
702bind . <KeyPress-Up> ".txt yview scroll -1 unit"
703bind . <KeyPress-Down> ".txt yview scroll 1 unit"
704bind . <KeyPress-Home> ".txt yview 0"
705bind . <KeyPress-End> ".txt yview end"
706#pack [button .but.q -text close -command "destroy ." ] -side right
707.txt tag config cycle -background yellow
708.txt tag config rval -background  green
709.txt tag config chi -background  green
710if [file exists $filename] {
711    set lstfp [open $filename r]
712} else {
713    # create a file if it does not exist
714    set lstfp [open $filename w+]
715}
716donewaitmsg
717# read a file compressed file, if present
718if {$zfil != ""} {
719    updatetext $zfil
720    close $zfil
721}
722# read the initial file
723updatetext $lstfp
724# now start reading with updates
725updatetext
726
727if {$txtvw(plotvars) && ![catch {package require BLT}]} {
728    .a.options.menu add checkbutton -label "Show Plot" -command hideplot \
729            -variable txtvw(hideplot)
730}
Note: See TracBrowser for help on using the repository browser.