home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 0 / 0980 / browse.rc next >
Encoding:
Text File  |  1990-12-28  |  3.3 KB  |  149 lines

  1. set more [get env PAGER]
  2. if { [length $more chars] == 0 } { set more more }
  3.  
  4. proc perror {} {
  5.     browse message [get error]
  6.     browse bell
  7. }
  8.  
  9. proc target {} {
  10.     set file [get file *]
  11.     if {[length $file chars]==0} {set file [get file .]}
  12.     return $file
  13. }
  14.  
  15. proc key_'j' {} {
  16.     if { ![browse move +1] } { browse bell }
  17. }
  18. proc key_'k' {} {
  19.     if { ![browse move -1] } { browse bell }
  20. }
  21. proc key_':' {} {
  22.     set command [get response :]
  23.     if { [length $command chars] > 0 } {
  24.         if { [catch {eval $command} response] != 0 } {
  25.             browse message Error: $response
  26.         } else {
  27.             if { [length $response chars] > 0 } {
  28.                 browse message Response: $response
  29.             }
  30.         }
  31.     }
  32. }
  33. proc key_'!' {} {
  34.     global shellcmd
  35.     set command [get response ! shellcmd]
  36.     if { [length $command chars] > 0 } {
  37.         browse shell $command
  38.         set shellcmd $command
  39.     }
  40. }
  41. proc key_space {} {
  42.     global more
  43.     set file [get file .]
  44.     if { ![browse chdir $file] } {
  45.         set file [target]
  46.         eval [concat browse tag - $file]
  47.         browse message !$more $file
  48.         browse shell [concat $more $file]
  49.     }
  50. }
  51. proc key_'q' {} {
  52.     if { [string compare q [get key -q-]] == 0 } {
  53.         browse exit
  54.     } else {
  55.         browse message
  56.     }
  57. }
  58. proc key_'^J' {} {
  59.     if { [string match *line [get mode]] } { browse redraw }
  60. }
  61. proc key_'d' {} {
  62.     if { [string compare d [get key -d-]] == 0 } {
  63.         set file [target]
  64.         set prompt [concat Delete $file {? }]
  65.         if { [string match {[yY]} [get key $prompt]] } {
  66.             if { ![eval [concat browse delete $file]] } {
  67.                 perror
  68.             }
  69.         }
  70.     }
  71. }
  72. proc cdhelp {name def} {
  73.     set dir $name[get response [concat chdir $name] $def]
  74.     if { ![browse chdir $dir] } { perror }
  75. }
  76. proc key_'=' {} { cdhelp {} [get file .] }
  77. proc key_'.' {} { cdhelp . {} }
  78. proc key_'/' {} { cdhelp / {} }
  79. proc key_'~' {} { cdhelp [get env HOME] {} }
  80. proc key_'t' {} { eval [concat browse tag / [get file .]] }
  81. proc key_'H' {} { browse move [get line home] }
  82. proc key_'L' {} { browse move [get line last] }
  83. proc key_dollar_sign {} { browse move [get line end] }
  84. proc key_'J' {} { browse move [get line end] }
  85. proc key_'^' {} { browse move 0 }
  86. proc key_'K' {} { browse move 0 }
  87. proc key_'M' {} { browse move [expr ([get line home]+[get line last])/2] }
  88. proc key_'<' {} { browse mode narrow }
  89. proc key_'>' {} { browse mode wide }
  90. proc key_'^R' {} { browse rescan }
  91. proc key_'^L' {} { browse redraw }
  92.  
  93. proc key_'r' {} {
  94.     set file [get file .]
  95.     set prompt [concat Rename $file {to }]
  96.     set new_file [get response $prompt $file]
  97.     if { ![browse rename $file $new_file] } {
  98.         perror
  99.     }
  100. }
  101.  
  102. proc key_'R' {} {
  103.     set files [get file *]
  104.     if { [length files] == 0 } {
  105.         key_'r'
  106.     } else {
  107.         set dir [get response {Move tagged files to }]
  108.         foreach file $files {
  109.             if { ![browse rename $file $dir/$file] } {
  110.                 perror
  111.                 return
  112.             }
  113.         }
  114.     }
  115. }
  116.  
  117. proc key_'v' {} { 
  118.     set command [concat vi [get file .]]
  119.     browse message !$command
  120.     browse shell $command
  121. }
  122.  
  123. proc macro_'#' {} { return [get cwd] }
  124. proc macro_'%' {} { return [get file .] }
  125. proc macro_'~' {} { return [get env HOME] }
  126.  
  127. proc key_'^F' {} {
  128.     browse move [expr {[get line .]+10}]
  129. }
  130.  
  131. proc key_'^B' {} {
  132.     browse move [expr {[get line .]-10}]
  133. }
  134.  
  135. proc key_'+' {} {
  136.     set file [get response {Add file: }]
  137.     if { [length $file chars] > 0 } {
  138.         if { ![browse add $file] } {
  139.             perror
  140.         }
  141.     }
  142. }
  143.  
  144. proc key_'p' {} {
  145.     set files [target]
  146.     eval [concat browse tag /P [target]]
  147.     eval [concat browse tag -T [target]]
  148. }
  149.