home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / data / mwm-functions.gwm < prev    next >
Lisp/Scheme  |  1995-07-03  |  6KB  |  256 lines

  1. ;;File: mwm-functions.gwm --
  2. ;;Author: colas@mirsa.inria.fr (Colas NAHABOO) -- Bull Research FRANCE
  3. ;;Author: Frederic CHARTON
  4. ;;Author: Glen Whitney
  5. ;;Revision: 1.0 -- Sep 12 1989
  6. ;;Revision: 1.1 -- Feb  5 1991
  7. ;;
  8. ;;State: Exp
  9. ;;GWM Version: 1.7d
  10.  
  11.  
  12. ; Description of mwm functions :
  13. ; -     f.function_name : the function
  14. ; -    e.function_name : the validity field of the function
  15. ;
  16. ; e.function_name determines if an item is enable or not,
  17. ; the function evaluation looks like : (if e.fctn (f.fctn))
  18.  
  19. (df f.beep () (bell))
  20. (: e.beep t)
  21.  
  22. (df f.circle_down () (circulate-windows-down))
  23. (: e.circle_down t)
  24.  
  25. (df f.circle_up () (circulate-windows-up))
  26. (: e.circle_up t)
  27.  
  28. (df f.eval args (eval (# 0 args)))
  29. (: e.eval t)
  30.  
  31. (df f.focus_key ())
  32. (: e.focus_key t)
  33.  
  34. (df f.identify ()
  35.     (pop-up-win "Version"
  36.                 (+ "Name: " window-name)
  37.         (+ "Icon name: " window-icon-name)
  38.               (+ "Resource name: " window-client-name)
  39.               (+ "Resource class: " window-client-class)
  40.           (+ "Client machine: " window-machine-name)
  41.               (+ "Geometry: " (itoa (# 0 window-size))
  42.                  "x" (itoa (# 1 window-size))
  43.                  "+" (itoa window-x)
  44.                  "+" (itoa window-y))
  45.               (if window-is-shaped "Shaped" "Rectangular")))
  46. (: e.identify t)
  47.  
  48. (df f.kill () 
  49.  (progn
  50.   (send-user-event 'depop)
  51.   (kill-window)
  52.  )
  53. )
  54. (: e.kill t)
  55.  
  56. (df f.delete ()
  57.     (progn
  58.       (send-user-event 'depop)
  59.       (delete-window)))
  60. (: e.delete t)
  61.  
  62. (df f.load (file)
  63.     (load file))
  64. (: e.load t)
  65.  
  66. (df f.lower () (lower-window))
  67. (: e.lower t)
  68.  
  69. (df f.maximize () (zoom))
  70. (: e.maximize '(and (not (# 'zoom window-property))
  71.             (not (= window-status 'icon))))
  72.  
  73. (df f.menu args 
  74.  (eval (+ '(menu.pop) args))
  75. )
  76. (: e.menu t)
  77.  
  78. (df f.minimize () 
  79.  (progn 
  80.   (mwm-iconify-window)
  81.   (if (and (= keyboardFocusPolicy 'explicit) autoKeyFocus)
  82.    (set-focus-kFL)
  83.   )
  84.  )
  85. )
  86. (: e.minimize '(not (= window-status 'icon)))
  87.  
  88. (df f.move ()
  89.  (if action-by-menu (warp-pointer (/ window-width 2) (/ window-height 2) window))
  90.  (with (cursor cross-cursor) 
  91.   (if (= window-status 'icon)
  92.    (move-icon)
  93.    (move-window)
  94.   )
  95.  )
  96. )
  97. (: e.move t)
  98.  
  99. (df f.nop () )
  100. (: e.nop t)
  101.  
  102. (df f.normalize ()
  103.     (if (= window-status 'icon)
  104.           (progn 
  105.        (mwm-de-iconify-window)
  106.            (if (and (= keyboardFocusPolicy 'explicit) deiconifyKeyFocus)
  107.         (set-focus window-window)
  108.        )
  109.       )
  110.           (zoom) ) )
  111. (: e.normalize '(or (= window-status 'icon) (# 'zoom window-property)))
  112.  
  113. (df f.show_sel ()
  114.      (pop-up-win "Cut Buffer"
  115.       "Contents of selection buffer:"
  116.                            cut-buffer))
  117. (: e.show_sel t)
  118.  
  119. (defun string-of (thing)
  120.   (with (type-is ())
  121.     (: type-is (type thing))
  122.     (if
  123.      (= thing nil) "nil"
  124.      (= type-is 'string) (+ "\"" thing "\"")
  125.      (= type-is 'atom) (+ "" thing)
  126.      (= type-is 'active) (+ "" thing)
  127.      (= type-is 'bar) "{BAR}"
  128.      (= type-is 'client) "{CLIENT}"
  129.      (= type-is 'number) (itoa thing)
  130.      (member type-is '(subr fsubr expr fexpr)) "{FUNCTION}"
  131.      (= type-is 'list)
  132.          (+ "(" (eval (+ (list '+)
  133.              (mapfor elt thing (+ (string-of elt) " ")))) ")")
  134.      "{Other Obj}")))
  135.  
  136. (df f.eval_sel ()
  137.    (with (dummy ())
  138.      (execute-string (+ "(: dummy " cut-buffer ")"))
  139.      (pop-up-win "Evaluate"
  140.       "GWM value of selection:"
  141.          (string-of dummy))))
  142. (: e.eval_sel t)
  143.  
  144. (df f.post_wmenu (button) 
  145.  (menu.pop (window-menu) button)
  146. )
  147. (: e.post_wmenu t)
  148.  
  149. (df f.quit_mwm () (end))
  150. (: e.quit_mwm '(= window-status 'root))
  151.  
  152. (df f.raise () 
  153.     (with (l (list-of-windows 'stacking-order))
  154.       (if (not (= window (# (- (length l) 1) l)))
  155.           (if (= window-status 'icon)
  156.           (raise-window (# (- (length l) 1) l))
  157.         (raise-window)))))
  158. (: e.raise t)
  159.  
  160. (df f.raise_lower ()
  161.     (with (win-unobscured t
  162.          might-obscure ())
  163.        (for w (list-of-windows 'stacking-order 'mapped)
  164.           (if (and might-obscure
  165.                    (obscured-by window w))
  166.               (: win-unobscured ()))
  167.           (if (= w window) (: might-obscure t)))
  168.        (if win-unobscured
  169.          (lower-window)
  170.          (raise-window))))
  171. (: e.raise_lower t)
  172.  
  173. (df f.raise_move ()
  174.     (f.raise)
  175.     (f.move))
  176. (: e.raise_move t)
  177.  
  178. (df f.refresh () (refresh))
  179. (: e.refresh t)
  180.  
  181. (df f.refresh_win () (refresh window))
  182. (: e.refresh_win t)
  183.  
  184. (df f.resize () (send-user-event 'resize-by-menu))
  185. (: e.resize '(= window-status 'window))
  186.  
  187. (df f.restart () (restart))
  188. (: e.restart '(= window-status 'root))
  189.  
  190. (df f.set_behavior ())
  191. (: e.set_behavior t)
  192.  
  193. (df f.title ())
  194. (: e.title t)
  195.  
  196. (df f.warpto (name)
  197.     (with (found-window () winlist (list-of-windows 'window 'mapped))
  198.         (for w winlist
  199.              (with (wob w)
  200.                    (if (and (not found-window)
  201.                             (match name window-name))
  202.                        (progn
  203.                          (: found-window t)
  204.                          (raise-window)
  205.                          (warp-pointer (/ window-width 2)
  206.                                        (/ window-height 2) w)))))))
  207. (: e.warpto t)
  208.  
  209. (df f.exec args (if (= (length args) 1) (! "/bin/sh" "-c" (# 0 args))
  210.     (eval (+ '(!) args)))
  211. )
  212. (: e.exec t)
  213.  
  214. (df f.exec-cut () (execute-string (+ "(? " cut-buffer ")")) )
  215. (: e.exec-cut t)
  216.  
  217.  
  218. (de f.pack_icons ()
  219.  (with (theIconList (list-of-windows 'icon 'mapped)
  220.         i 0 l (length theIconList)
  221.        )
  222.   (: icon-array (list-make (* nb-icons.w nb-icons.h)))
  223.   (while (< i l)
  224.    (with (thePlace (auto-get-place)
  225.           X (# 0 thePlace)
  226.           Y (# 1 thePlace)
  227.           thePixelPlace (XY-to-xy X Y)
  228.           x (# 0 thePixelPlace)
  229.           y (# 1 thePixelPlace)
  230.           theIcon (# i theIconList)
  231.          )
  232.     (set-icon-of-array X Y theIcon)
  233.     (move-window theIcon x y)
  234.     (## 'X theIcon X)
  235.     (## 'Y theIcon Y)
  236.    )
  237.    (: i (+ i 1))
  238.   )
  239.  )
  240. )
  241. (: e.pack_icons iconAutoPlace)
  242.  
  243. (df f.info () (? "Window: " (window-client-name) "."
  244.                   (window-client-class) "."
  245.                   (window-name) "@"
  246.                   (window-machine-name) "\n")
  247. )
  248. (: e.info t)
  249.  
  250. (df f.termcap () (progn (send-key-to-window "eval `resize`" alone)
  251.                         (send-key-to-window 0xff0d alone)
  252.                  )
  253. )
  254.  
  255. (: e.termcap '(=  window-client-class "XTerm"))
  256.