home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume17 / tcl-editor / part02 / tclLib / macros.tcl < prev    next >
Encoding:
Text File  |  1992-03-18  |  1.2 KB  |  67 lines

  1. #
  2. # Some macros to extend Point commands
  3. #
  4. proc Filter {{cmd fmt}} {
  5.     set s [selection get]
  6.     set ret [catch {exec $cmd << $s} ns]
  7.     # if the command failed then do not delete the selection
  8.     if {$ret==0} DeleteToScrap
  9.     # insert the result or the error message
  10.     InsertString $ns
  11. }
  12.  
  13. proc IndentSelection {{outdent 0}} {
  14.     set sel [Sel get]
  15.     set here [lindex $sel 0]
  16.     set stop [lindex $sel 1]
  17.     for {} 1 {} {
  18.         MoveSel line left0
  19.         set here [lindex [Sel get] 0]
  20.         if {$here>$stop} \
  21.             break;
  22.         if $outdent {
  23.             DeleteToScrap
  24.         } else {
  25.             InsertString \t
  26.         }
  27.         set stop [expr $stop+1]
  28.         MoveSel char down
  29.     }
  30. }
  31.  
  32. proc DefineMacro {{id 0}} {
  33.     set name Macro$id
  34.     global $name
  35.     set $name [selection get]
  36. }
  37.  
  38. proc ExecMacro {{id 0}} {
  39.     set name Macro$id
  40.     global $name
  41.     eval [set $name]
  42. }
  43.  
  44. proc ExecSel {{id 0}} {
  45.     eval [selection get]
  46. }
  47.  
  48. proc MoveWindow {geometry} {
  49.     set aw [WindowName get active]
  50.     wm geometry $aw [FixGeometry $geometry]
  51.     RaiseWindow
  52. }
  53.  
  54. proc ExtendSelToLines {} {
  55.     set endSel [lindex [Sel get] 1]
  56.     MoveSel line left0 noupdate
  57.     set beginSel [lindex [Sel get] 0]
  58.     Sel set $endSel $endSel
  59.     MoveSel line right noupdate
  60.     set endSel [lindex [Sel get] 1]
  61.     Sel set $beginSel $endSel
  62.     set w [WindowName get sel]
  63.     Redraw
  64. }
  65.  
  66.  
  67.