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

  1. ; ======================================================================
  2. ;             XTERM WINDOW PACKAGE
  3. ; ======================================================================
  4.  
  5. (require 'vb-bar 'vb-button 'simple-ed-win)
  6.  
  7. ; ================================
  8. ; Function to execute applications
  9. ; ================================
  10.  
  11. (de exec.sh (command)
  12.     (! "/bin/sh" "-c" command))
  13.  
  14. ; Context:
  15. ;       exec.machine
  16. ;
  17. (de exec.xload ()
  18.     (if (boundp 'exec.machine)
  19.     (exec.sh (+ "rx " exec.machine " xload "))
  20.     (? "\nexec.xload: ERROR no described exec.machine\n")))
  21.  
  22.  
  23. ; Context:
  24. ;   exec.machine
  25. ;   exec.font-name
  26. (de exec.xterm ()
  27.     (if (boundp 'exec.machine)
  28.     (with (
  29.            font-arg (if (boundp 'exec.font-name)
  30.                 (+ " -fn " exec.font-name)
  31.                 "")
  32.           )
  33.           (exec.sh (+ "rx " exec.machine " xterm -ls" font-arg)))
  34.     (? "\nexec.xterm: ERROR no described exec.machine\n")))
  35.  
  36. ; Logo plug
  37. ; ---------
  38.  
  39. (: vbterm.logo-plug
  40.   (with (vbterm.logo-pixmap
  41.       (if (boundp 'logo-pixmap) logo-pixmap
  42.     (boundp 'icon-pixmap) icon-pixmap
  43.     ))
  44.     (if vbterm.logo-pixmap
  45.     (with (
  46.            background white
  47.            borderwidth 1
  48.            borderpixel white
  49.            fsm ()
  50.           )
  51.           (plug-make vbterm.logo-pixmap))))
  52. )
  53.  
  54. ; plug with label dynamically changed
  55. ; -----------------------------------
  56.  
  57. (de vbterm.dynamic-plug-make ()
  58.     (with (
  59.        context (list
  60.             'foreground foreground
  61.             'background background
  62.             'font font
  63.             'label-horizontal-margin label-horizontal-margin
  64.             'label-vertical-margin label-vertical-margin
  65.            )
  66.        property (list 'context context)
  67.       )
  68.       (plug-make vbterm.dynamic-default-pixmap)))
  69.  
  70. (de vbterm.dynamic-plug-update (text)
  71.     (with-eval (# 'context wob-property)
  72.     (wob-tile (active-label-make text))))
  73.  
  74. (setq vbterm.dynamic-default-pixmap (label-make ""))
  75.  
  76.  
  77.  
  78. ; Name plug
  79. ; ---------
  80.  
  81. (: vbterm.current-machine-fsm 
  82.     (fsm-make
  83.     (state-make
  84.         (on (user-event 'machine-change)
  85.         (progn
  86.               (vbterm.dynamic-plug-update vbterm.current-machine)
  87.         ))
  88.     )))  
  89.  
  90. ; Context:     (just as label-make)
  91. (de vbterm.current-machine-plug-make ()
  92.     (with (
  93.        fsm vbterm.current-machine-fsm
  94.       )
  95.       (vbterm.dynamic-plug-make)))
  96.  
  97. (setq vbterm.current-machine-small-plug
  98.     (with (
  99.        borderwidth 1
  100.        borderpixel black
  101.        font small-font
  102.       )
  103.       (vbterm.current-machine-plug-make)))
  104.  
  105. (setq vbterm.current-machine-big-plug
  106.     (with (
  107.        borderwidth 1
  108.        borderpixel black
  109.        foreground black
  110.        background white
  111.        font name-font
  112.       )
  113.       (vbterm.current-machine-plug-make)))
  114.  
  115.  
  116. ; Directory plug
  117. ; --------------
  118.  
  119. (: vbterm.current-directory-fsm 
  120.     (fsm-make
  121.     (state-make
  122.         (on (user-event 'directory-change)
  123.         (progn
  124.               (vbterm.dynamic-plug-update vbterm.current-directory)
  125.         ))
  126.     )))  
  127.  
  128. (: vbterm.current-directory-plug 
  129.     (with (
  130.        borderwidth 1
  131.        borderpixel black
  132.        font small-font
  133.        fsm vbterm.current-directory-fsm
  134.       )
  135.       (vbterm.dynamic-plug-make)))
  136.  
  137.  
  138.  
  139. ; Editable plug
  140. ; -------------
  141.  
  142. (: vbterm.edit-fsm  
  143.   (fsm-make 
  144.     (state-make
  145.       (on (keypress 0xff08 any)
  146.     (progn
  147.       (wob-property 
  148.         (: s (match "\\(.*\\)."
  149.         (wob-property) 1)))
  150.       (if (= s "")
  151.         (wob-property (: s " ")))
  152.       (wob-tile (active-label-make s name-font))
  153.       (send-user-event 'get-s (window-icon))
  154.       ))
  155.       (on (keypress 0xffff any)
  156.     (progn
  157.       (wob-property (: s "  "))
  158.       (wob-tile (active-label-make s name-font))
  159.       (send-user-event 'get-s (window-icon))
  160.       ))
  161.       (on (keypress any any)
  162.     (progn
  163.       (wob-property 
  164.         (: s (+ (wob-property) (last-key))))
  165.       (wob-tile (active-label-make s name-font))
  166.       (send-user-event 'get-s (window-icon))
  167.       ))
  168.       (on (user-event 'initialize) 
  169.     (progn
  170.       (wob-property (: s window-name))
  171.       (wob-tile (active-label-make s name-font))
  172.       (send-user-event 'get-s (window-icon))
  173.       ))
  174.       (on (user-event 'name-change) 
  175.     (progn
  176.       (wob-property (: s window-name))
  177.       (wob-tile (active-label-make s name-font))
  178.       (send-user-event 'get-s (window-icon))
  179.       ))
  180.       (on enter-window (set-focus ()))
  181.       (on leave-window (set-focus))
  182.       standard-title-behavior
  183.       standard-behavior
  184. )))
  185.  
  186.  
  187. ;(: vbterm.editable-plug2
  188. ;    ''(with (
  189. ;         borderwidth 1 
  190. ;         background white 
  191. ;         font name-font
  192. ;         property window-name 
  193. ;         fsm vbterm.edit-fsm)
  194. ;        (plug-make (label-make window-name))))
  195.  
  196. (: vbterm.editable-plug2
  197.     (with (
  198.        borderwidth 1 
  199.        background white 
  200.        font name-font
  201.        property "foo" ;window-name 
  202.        fsm vbterm.edit-fsm)
  203.       (plug-make (label-make ""))))
  204.  
  205.  
  206.  
  207. ; Window fsm
  208. ; ----------
  209.  
  210. (de vbterm.get-current-directory ()
  211.     (with (name window-name)
  212.       (if (match ".*:.*" name)
  213.           (with (res (match "\\([^:]*:\\)\\(.*\\)" name 2))
  214.             (if res res " "))
  215.           " ")))
  216.  
  217. (de vbterm.get-current-machine ()
  218.     (match "\\([^:]*\\)" window-name 1))
  219.  
  220.  
  221. (de vbterm.notify-name-change ()
  222.     (setq vbterm.current-directory (vbterm.get-current-directory))
  223.     (send-user-event 'directory-change)
  224.     
  225.     (setq vbterm.current-machine (vbterm.get-current-machine))
  226.     (send-user-event 'machine-change)
  227.     
  228.     ;  (set-x-property "WM_ICON_NAME" (vbterm.get-current-machine))
  229.     (setq xterm.icon-name (vbterm.get-current-machine))
  230.     (send-user-event 'icon-name-change (window-icon))
  231. )  
  232.  
  233. (setq xterm-behavior
  234.     (state-make
  235.     (on (user-event 'name-change) (vbterm.notify-name-change))
  236.     (on (user-event 'initialize)  (vbterm.notify-name-change))
  237.     ))
  238.  
  239.  
  240.  
  241. (if (and (boundp 'emacs-mouse-loaded) emacs-mouse-loaded)
  242.   (progn 
  243.     (: vbterm.sed-window-fsm 
  244.       (fsm-make 
  245.     (state-make
  246.       (on focus-in 
  247.         (progn
  248.           (if autoraise (raise-window))
  249.           (send-user-event 'focus-in)
  250.           (wob-borderpixel black)))
  251.       (on focus-out 
  252.         (progn (send-user-event 'focus-out)
  253.           (wob-borderpixel white)))
  254.       (on (button 1 with-shift) (emacs-click 1))
  255.       (on (button 2 with-shift) (emacs-click 2))
  256.       (on (buttonpress 3 with-shift) (pop-menu emacs-pop))
  257.       xterm-behavior
  258.       window-behavior
  259.       standard-behavior
  260.     )))
  261.     (: vbterm.inner-grabs (list (button any with-shift)))
  262.   )
  263.   (progn
  264.     (: vbterm.sed-window-fsm 
  265.       (fsm-make 
  266.     (state-make 
  267.       (on focus-in 
  268.         (progn
  269.           (if autoraise (raise-window))
  270.           (send-user-event 'focus-in)
  271.           (wob-borderpixel black)))
  272.       (on focus-out 
  273.         (progn (send-user-event 'focus-out)
  274.           (wob-borderpixel white)))
  275.       xterm-behavior
  276.       window-behavior
  277.       standard-behavior
  278.     )))
  279.     (: vbterm.inner-grabs ())))
  280.  
  281.  
  282.  
  283.  
  284. ; Some examples of bar context variable:
  285. ; -------------------------------------
  286. ;       bar-min-width 20
  287. ;       bar-max-width 20
  288. ;       bar.focus-sensitive ()
  289. ;       bar.borderwidth 5
  290. ;       borderpixel black
  291. ;       bar.thickness 24
  292. ;       bar.thickness 30
  293. ;       bar.size-adjust-on 'pixmap
  294. ;       bar.appearance-make bar.color-appearance-make
  295. ;       bar.normal-color foreground
  296. ;       bar.active-color background
  297. ;      font (font-make "screen.r.7")
  298. ;      normal-pixmap0 (label-make "1")
  299. ;      normal-pixmap1 (label-make "gwm")
  300. ;      normal-pixmap2 (label-make "2")
  301. ;      active-pixmap0 ()
  302. ;      active-pixmap1 ()
  303. ;      active-pixmap2 ()
  304. ;      dummy (with (
  305. ;               tmp foreground
  306. ;               foreground background
  307. ;               background tmp
  308. ;              )
  309. ;          (setq active-pixmap0 (label-make "1"))
  310. ;          (setq active-pixmap1 (label-make "gwm"))
  311. ;          (setq active-pixmap2 (label-make "2")))
  312. ;      bar.normal-pixmap-list (list 
  313. ;                   normal-pixmap0 
  314. ;                   normal-pixmap1
  315. ;                   normal-pixmap2)
  316. ;      bar.active-pixmap-list (list 
  317. ;                   active-pixmap0 
  318. ;                   active-pixmap1
  319. ;                   active-pixmap2)
  320. ;      bar.appearance-make bar.pixmap-appearance-make
  321. ;      bar.appearance-make bar.3-pixmaps-appearance-make
  322. ;      bar.appearance-make bar.3-pixmap-files-appearance-make
  323. ;      bar.active-pixmap-file-name "barA"
  324. ;      bar.plugs (+ my-buttons (list vbterm.editable-plug2)); OK
  325. ;       property '(a 3)
  326. ;      bar.normal-pixmap-file-name "barN"
  327. ;      bar.active-pixmap-file-name "barGWM"
  328. ;      bar.normal-pixmap-file-name "closeStore"
  329. ;      bar.active-pixmap-file-name "barN"
  330. ;       borderwidth 1 
  331. ;       fsm vbterm.titlebar-fsm
  332. ;       borderpixel black
  333. ;       bar-min-width 16 bar-max-width 26
  334. ;          bar.normal-pixmap-file-name "barN"
  335. ;          bar.active-pixmap-file-name "barA2"
  336.  
  337.  
  338.  
  339. ; Bars definition
  340. ; ---------------
  341.  
  342. (de resize-0 ()
  343.     (with (
  344.        button.action '(window-size '(80 66))
  345.        button.stencil-label "66"
  346.       )
  347.           (button.make)))
  348.  
  349. (de resize-1 ()
  350.     (with (
  351.        button.action '(window-size '(80 58))
  352.        button.stencil-label "58"
  353.       )
  354.           (button.make)))
  355.  
  356. (de resize-2 ()
  357.     (with (
  358.        button.action '(window-size '(80 30))
  359.        button.stencil-label "30"
  360.       )
  361.           (button.make)))
  362.  
  363. (de vbterm.title-bar-make ()
  364.   (with (
  365.       bar.appearance-make bar.3-paxmap-files-appearance-make
  366.       bar.normal-pixmap-file-name "barA2"
  367.       bar.focus-sensitive ()
  368.       plug-separator 10
  369.       button.minimum-width 24
  370.       button.minimum-height 24
  371.       background grey
  372.       bar.plugs (list 
  373.     vbterm.logo-plug
  374.     (button.iconify)
  375.     (button.kill)
  376.     (button.lower)
  377.     (button.raise)
  378.     (button.xload)
  379.     (with (button.mode 'english) (button.xterm))
  380.     (resize-0)
  381.     (resize-1)
  382.     (resize-2)
  383.     ()
  384.     (with (background white) vbterm.current-machine-big-plug)
  385.       )
  386.     )
  387.     (bar.make)))
  388.  
  389. (de vbterm.bottom-bar-make ()    
  390.     (with (
  391.        bar.appearance-make bar.3-paxmap-files-appearance-make
  392.        bar.normal-pixmap-file-name "barA2"
  393.        bar.focus-sensitive ()
  394.        bar.plugs (list
  395.               vbterm.current-machine-small-plug
  396.               vbterm.current-directory-plug
  397.              )
  398.       )
  399.       (bar.make)))))))
  400.      
  401. (setq vbterm.colored-bar
  402.     (with (
  403.        bar.borderwidth 1
  404.        bar-min-width 4
  405.        bar.normal-color background
  406.        bar.active-color foreground
  407.       )
  408.       (bar.make)))
  409.      
  410.     
  411.  
  412. (de vb-term ()
  413.     (with (
  414.            opening (+ opening '((send-user-event 'initialize)))
  415.        inner-borderwidth (default vbterm.borderwidth 0)
  416.        fsm vbterm.sed-window-fsm 
  417.        borderwidth (default vbterm.borderwidth 0)
  418.        borderpixel white
  419.        grabs (+ grabs vbterm.inner-grabs)
  420.        my-deco (window-make 
  421.            (vbterm.title-bar-make)
  422.            vbterm.colored-bar 
  423.            vbterm.colored-bar
  424.            (vbterm.bottom-bar-make)
  425.            ()))
  426.       my-deco))
  427.  
  428.     
  429.