home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / languages / tcl / !tcldoc / tcldoc < prev   
Encoding:
Text File  |  1994-09-23  |  2.7 KB  |  125 lines

  1. # Tcl Documentation Reader
  2.  
  3. source {<tcl$Dir>.!Choices}
  4.  
  5. proc beep {} {puts -nonewline \a}
  6.  
  7. w_init tcldoc
  8.  
  9. w_box progInfo create "About this program"\
  10.  { vlist {info Name TclDoc}
  11.         {info Purpose "Read Tcl Documentation"}
  12.         {info Author C.T.Stretch}
  13.         {info Version {Fri,12 Aug 1994}}
  14.  }
  15.  
  16. set menudata { TclDoc {Info -dbox progInfo}
  17.                {Quit -click exit}
  18.              }
  19.  
  20. source {<tclDoc$Dir>.index}
  21.  
  22. w_bar -menu $menudata  -drag {dragproc $w_file}
  23.  
  24. proc process {text}\
  25.  { 
  26.    regsub -all \t $text "        " text 
  27.    regsub -all `` $text \x94 text 
  28.    regsub -all '' $text \x95 text 
  29.    regsub -all {\\([-\`'.])} $text {\1} text 
  30.    regsub -all {\\[ 0t]} $text " " text 
  31.    regsub -all {\\[|^&!%{}acdpru]} $text "" text 
  32.    regsub -all {\|} $text || text 
  33.    regsub -all {\\fI} $text |fi| text 
  34.    regsub -all {\\fB} $text |fb| text 
  35.    regsub -all {\\fR} $text |fr| text 
  36.    regsub -all {\\e} $text \\ text 
  37.    set text
  38.  }
  39.  
  40. proc outpar {}\
  41.  { global win par ind stdind
  42.    if {$par!=""}\
  43.    { w_text win$win options -l${ind}i -i${ind}i
  44.      w_text win$win write [process $par]
  45.      set par ""
  46.      set ind $stdind
  47.    }
  48.  }
  49.  
  50. proc outlab {}\
  51.  { global win line
  52.    outpar
  53.    w_text win$win options -l0
  54.    w_text win$win print |cred|[string range $line 4 end]
  55.  }
  56.  
  57. proc skipdef {}\
  58.  { global tfile line
  59.    outpar
  60.    while {![eof $tfile]}\
  61.    { set line [gets $tfile]
  62.      if {[string match ..* $line]} break
  63.    }
  64.  }
  65.  
  66. proc inspar {}\
  67.  { global line win ind stdind
  68.    outpar
  69.    regexp {.IP[ ]*([^ ]*)[ ]*[0-9]*} $line x line
  70.    w_text win$win options -l${stdind}i
  71.    w_text win$win print |cblue|[process $line]
  72.    set ind [expr $stdind+.5]
  73.  }
  74.  
  75. proc insparn {}\
  76.  { global line win ind stdind tfile
  77.    outpar
  78.    set len [string range $line 4 end]
  79.    if {[string trim $len]==""} {set len 8}
  80.    w_text win$win options -l${stdind}i
  81.    w_text win$win print |cblue|[process [gets $tfile]]
  82.    set ind [expr $stdind+$len*.1]
  83.  }
  84.  
  85. proc dragproc {fname}\
  86.  { global win par ind line tfile rsind rind stdind
  87.    set tfile [open $fname]
  88.    w_text win$win create -width 8i  -title $fname
  89.    w_text win$win options -pon -jon -r.5i -l.5i -i.5i
  90.    while {![eof $tfile]}\
  91.    { set line [gets $tfile]
  92.      switch -glob $line \
  93.      { '* {}
  94.        .SH* outlab
  95.        .IP* inspar
  96.        .TP* insparn
  97.        .RS* {set rsind $stdind;set rind $ind;set stdind $ind;outpar}
  98.        .RE* {outpar;set stdind $rsind;set ind $rind}
  99.        .de* skipdef
  100.        .VS*  {}
  101.        .VE*  {}
  102.        .*   outpar
  103.        default {append par "[string trim $line {}] "}
  104.      }
  105.    }
  106.    outpar
  107.    close $tfile
  108.    w_text win$win open
  109.    incr win
  110.  }
  111.  
  112. proc man {fname}\
  113.  { dragproc $fname
  114.  }
  115.  
  116. set win 0
  117. set par ""
  118. set stdind .5
  119. set ind $stdind
  120. set rsind $stdind
  121. set rind $ind
  122.  
  123.  
  124.  
  125.