#!/bin/sh # the next line restarts using wish \ exec wish "$0" "$@" # please change wish version if current version does not exist on your machine ############################################################################### # Copyright (c) 2002, Alexander Gnusin, alexg12@tclforeda.net # # All rights reserved. # # # # Redistribution and use in source and binary forms, with or without # # modification, are permitted provided that the following conditions are met: # # Redistributions of source code must retain the above copyright notice, this # # list of conditions and the following disclaimer. # # # # Redistributions in binary form must reproduce the above copyright notice, # # this list of conditions and the following disclaimer in the documentation # # and/or other materials provided with the distribution. # # # # Neither the name of the TCLforEDA nor the names of its contributors may # # be used to endorse or promote products derived from this software without # # specific prior written permission. # # # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR # # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY# # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ############################################################################### if [catch {set synopsys_path $env(SYNOPSYS)} result] { puts stderr "==================ERROR==================" puts stderr "Please, set environment variable SYNOPSYS" puts stderr "before running vman!" puts stderr "==================ERROR==================" return 0 } #========================================================================== proc run_search {pattern} { global clist set ret_list "" foreach command $clist { if {[string match $pattern $command]} { lappend ret_list $command } } return $ret_list } #========================================================================== proc view {command i} { global env toplevel .$i wm title .$i $command frame .$i.buttons pack .$i.buttons -side bottom -fill x -pady 1m button .$i.buttons.dismiss -text Dismiss -command "destroy .$i" -bd 1 pack .$i.buttons.dismiss -fill x -expand yes text .$i.text -relief sunken -bd 1 -bg grey80 -yscrollcommand ".$i.scroll set" \ -setgrid 1 -height 30 scrollbar .$i.scroll -command ".$i.text yview" -bd 1 pack .$i.scroll -side right -fill y pack .$i.text -expand yes -fill both exec man $command > .tmpfile set HF [open .tmpfile r] set flag 0 while {[gets $HF line] >= 0} { if {$line != ""} {set flag 1} regsub -all "_" $line "" clean_line if {$flag} { .$i.text insert end $clean_line\n } } close $HF } #========================================================================== proc search_window {} { global lb set i 0 wm title . "Synopsys Manual Pages" set frame1 [frame .1 -bd 1 -relief flat] set label1 [label $frame1.label -text "Search: " -anchor w] set entry1 [entry $frame1.entry -width 30 -relief sunken -textvariable spattern -bd 1] pack $label1 -side left pack $entry1 -side right -fill x -expand yes pack $frame1 -side top -fill x -padx 1m -pady 1m set sframe [frame .2 -bd 1 -relief flat] set frame3 [frame $sframe.2 -bd 1 -relief flat] set lb $frame3.list set sb [scrollbar $frame3.scroll -command "$lb yview" -width 10 -bd 1] set lb [listbox $frame3.list -selectmode extended \ -yscroll "$sb set" -setgrid 1 -height 5 -bd 1] pack $sb -side right -fill y pack $lb -side left -expand yes -fill both pack $frame3 -side right -padx 1m -pady 1m -expand yes -fill both pack $sframe -side top -fill both -expand yes set frame4 [frame .cmd -bd 1 -relief flat] button $frame4.cancel -text " Cancel " -bd 1 -command { destroy . } button $frame4.ok -text " OK " -bd 1 -command { view [$lb get [$lb curselection]] $i incr i } bind $entry1 { $lb delete 0 end foreach item [run_search $spattern] { $lb insert end $item } } bind $lb { view [$lb get [$lb curselection]] $i incr i } pack $frame4.ok -side left -fill x -expand yes pack $frame4.cancel -side right -fill x -expand yes pack $frame4 -side bottom -fill x } #========================================================================== # Main body #========================================================================== if {[lindex $argv 0] == "" || [lindex $argv 0] == "-syn"} { set tool syn } elseif {[lindex $argv 0] == "-pt"} { set tool pt } else { puts "Error: Valid options are -syn (DC man pages) or -pt (Primetime man pages) only" puts "By default, DC man pages are used" return 0 } set manpath $synopsys_path/doc/$tool/man set env(MANPATH) $manpath global clist set clist "" for {set i 1} {$i <= 3} {incr i} { if {[file exists $manpath/cat$i]} { foreach file [exec ls $manpath/cat$i] { lappend clist [file rootname $file] } } } search_window