home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / tcl / 1858 / man.tk
Encoding:
Tcl/Tk script  |  1992-11-17  |  1.4 KB  |  51 lines

  1. #!/usr/local/bin/wish -f
  2. ####################################
  3. # man.tk
  4. # man page viewer hack
  5. # Bob Bagwill - no rights reserved
  6. ####################################
  7. set sections {1 2 3 4 5 6 7 8 l n}
  8. set ALPHABET {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
  9. set alphabet {a b c d e f g h i j k l m n o p q r s t u v w x y z}
  10. set Alphabet [concat $ALPHABET $alphabet]
  11.  
  12. set mandir /usr/man/man
  13.  
  14. proc display page {
  15.     catch {destroy .$page}
  16.     toplevel .$page
  17.     wm minsize .$page 80 25
  18.     button .$page.ok -text OK -command "destroy .$page"
  19.     text .$page.text -setgrid true -yscroll ".$page.scroll set"
  20.     scrollbar .$page.scroll -command ".$page.text yview"
  21.     pack append .$page .$page.ok {bottom fillx} \
  22.         .$page.scroll {right filly} .$page.text {fill expand}
  23.     .$page.text insert 1.0 [exec man -D $page]
  24. }
  25.  
  26. wm title . man
  27.  
  28. foreach h $sections {
  29.     frame .$h
  30.     label .$h.l$h -width 8 -relief raised -text $h
  31.     pack append .$h .$h.l$h left
  32.     foreach i $Alphabet {
  33.         if {[glob -nocomplain $mandir$h/$i*] != ""} {
  34.             menubutton .$h.$i -text $i -menu .$h.$i.m
  35.             pack append .$h .$h.$i left
  36.             menu .$h.$i.m
  37.             foreach j [lsort [glob -nocomplain $mandir$h/$i*]] {
  38.                 if {$j != ""} {
  39.                     set manpage [file root [file tail $j]]
  40.                     .$h.$i.m add command -label $manpage -command "display $manpage"
  41.                 }
  42.             }
  43.         }
  44.     }
  45.     pack append . .$h {top fillx}
  46. }
  47. bind all <Control-q> {destroy .}
  48. ################
  49. # end of man.tk
  50. ################
  51.