# # Put up a nice display for the zeb directory -- point and click to get # at zeb descriptions. # # Load in the support files # source edit_zeb.tcl # # Some utility routines to make our life simpler below # proc update_zeb_directory {} { global zebFiles set theZebList [get_sorted_zeb_list] foreach zeb $theZebList { set name [lindex $zeb 0] set fname [lindex $zeb 1] set zebFiles($name) $fname } .zebList.zebDirectory delete 1 end set list [get_zeb_names $theZebList] foreach i $list { .zebList.zebDirectory insert end $i } } # # display_selected_zeb_info # # Load the zeb file for the selected info. # proc display_selected_zeb_info {} { set zebName [.zebList.zebDirectory get \ [lindex [.zebList.zebDirectory curselection] 0]] display_zeb_info $zebName } # # display_zeb_info # Load up the text canvas with the zeb text # proc display_zeb_info {zebName} { global zebFiles global fBankName set infile [open $zebFiles($zebName) r] set desc [read $infile] close $infile .zebContent.zebDescription delete 1.0 end .zebContent.zebDescription insert 1.0 $desc .zebContent.info.fileName config -text $zebFiles($zebName) set fBankName $zebName .zebContent.info.openFile config -state normal } # # open_new_window # # Display current zeb file in a new window. # proc open_new_window {} { global zebFiles global fBankName global wIndex set fName $zebFiles($fBankName) set wSym ".displayZeb$wIndex" set wIndex [expr $wIndex+1] toplevel $wSym wm title $wSym $fName wm iconname $wSym $fBankName frame $wSym.control -relief raised -bd 1 pack $wSym.control -side top -fill x button $wSym.control.quit -text "Close" -command "destroy $wSym" pack $wSym.control.quit -side left -padx 10 -pady 10 frame $wSym.text -relief raised -bd 1 pack $wSym.text -side bottom -fill both -expand 1 text $wSym.text.it -height 20 -setgrid 1 \ -yscrollcommand "$wSym.text.scroll set" -width 80 -wrap none scrollbar $wSym.text.scroll \ -command "$wSym.text.it yview" pack $wSym.text.it -side left -fill both -expand 1 pack $wSym.text.scroll -side right -fill y set infile [open $fName r] set contentsOfFile [read $infile] close $infile $wSym.text.it insert 1.0 $contentsOfFile } # # Prevent us from scrolling tooo far! # proc scrollAndStop {command scrollbar line} { set scrollInfo [eval $scrollbar get] set lastLine [expr [lindex $scrollInfo 0]-[lindex $scrollInfo 1]] if {$line > $lastLine} {set line $lastLine} eval $command $line } # # Build the user interface # frame .header -relief raised -bd 2 pack .header -side top -fill x button .header.quitMe -text "Quit" -command "destroy ." -padx 2 -pady 2 pack .header.quitMe -side left -padx 10 -pady 10 message .header.id -text "ZEB Viewer 1.0" -justify right -width 200 pack .header.id -side right # frame .zebList -relief raised pack .zebList -fill y -side left listbox .zebList.zebDirectory -geom 10x10 -setgrid 1 \ -yscrollcommand ".zebList.zebScroll set" tk_listboxSingleSelect .zebList.zebDirectory bind .zebList.zebDirectory <ButtonRelease-1> {display_selected_zeb_info} scrollbar .zebList.zebScroll -command ".zebList.zebDirectory yview" \ -repeatinterval 10 -repeatdelay 100 pack .zebList.zebDirectory -side left -fill y pack .zebList.zebScroll -side right -fill y # frame .zebContent -height 1 -relief sunken -bd 2 pack .zebContent -side left -fill both -expand 1 frame .zebContent.info -height 1 -bd 1 -relief raised pack .zebContent.info -fill x -side top button .zebContent.info.openFile -text "Open" -command {open_new_window} \ -state disabled pack .zebContent.info.openFile -side left message .zebContent.info.fileName -width 1000 pack .zebContent.info.fileName -fill x text .zebContent.zebDescription -height 1 -setgrid 1 -yscrollcommand \ ".zebContent.zebDesScroll set" -width 40 -wrap none scrollbar .zebContent.zebDesScroll \ -command {scrollAndStop ".zebContent.zebDescription yview" \ ".zebContent.zebDesScroll"} \ -repeatinterval 10 -repeatdelay 100 pack .zebContent.zebDescription -side left -fill both -expand 1 pack .zebContent.zebDesScroll -side right -fill y bind .zebContent.zebDescription <KeyPress> {set i %W} # # Ok -- get the zeb directory and put it in the log pane. # set fName "" set wIndex 0 update_zeb_directory # wm title . "Zeb Viewer" wm iconname . "Zeb"