home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / epoch / auto-unmap-screens.el next >
Encoding:
Text File  |  1991-03-30  |  3.5 KB  |  98 lines

  1. ; Date: Tue, 9 Oct 90 14:57:37 EDT
  2. ; From: Ken Laprade <laprade@trantor.harris-atd.com>
  3. ; Subject: Map handler to get rid of minibuffer
  4. ; Here is a map handler that will unmap the minibuffer (and any other special
  5. ; screens such as a mouse-helper) when the last normal screen is unmapped and
  6. ; will remap the minibuffer (and others) when any window is mapped.  Maybe
  7. ; nobody else cares, but when I close my last epoch screen, I want everything
  8. ; else to go away; I have no need for a lone minibuffer.
  9. ; -- 
  10. ; Ken Laprade            INTERNET: laprade@trantor.harris-atd.com
  11. ; Harris Corporation         Usenet:  ...!uunet!x102a!trantor!laprade
  12. ; PO Box 37, MS 3A/1912        Voice: (407)727-4433
  13. ; Melbourne, FL 32902        FAX: (407)729-2537
  14. ; --------------------
  15. ;;; Add a map event handler that gets rid of auto-unmap-screens when the
  16. ;;; last normal screen is closed and brings them back when any screen is
  17. ;;; opened.  auto-unmap-screens is a list of symbols that eval to screens.
  18. ;;; The last size and position is remembered for each window because
  19. ;;; mapping seems to resize screens to their creation size.
  20.  
  21. (defvar auto-unmap-screens nil
  22.   "*List of symbols referring to screens that will be automatically unmapped
  23. when the last normal screen is closed and remapped when any screen is opened.")
  24. (defvar auto-unmap-screens-geometry nil
  25.   "Alist of saved geometries for screens referenced by auto-unmap-screens.")
  26.  
  27. (defun normal-screens (screens)
  28.   "Return a list of all screens in SCREENS that are not referenced by
  29. auto-unmap-screens."
  30.   (let (l)
  31.     (while screens
  32.       (let ((scrn (car screens))
  33.         isone)
  34.     (mapcar
  35.      (function (lambda (scr)
  36.              (setq isone (or isone (eq scrn (eval scr))))))
  37.      auto-unmap-screens)
  38.     (or isone
  39.         (setq l (append l (list scrn)))))
  40.       (setq screens (cdr screens)))
  41.     l))
  42.  
  43. (defun my-map-event-handler (type value screen)
  44.   "Map event handler.  Will unmap auto-unmap-screens if this is the last
  45. normal screen being unmapped.  Will remap auto-unmap-screens if mapping a
  46. screen.  Calls on-event::handler first."
  47.   (on-event::handler type value screen)
  48.   (if value
  49.       ;; Mapping.
  50.       (mapcar
  51.        (function
  52.     (lambda (scr)
  53.       (setq scr (eval scr))
  54.       (or (not (screen-p scr))
  55.           (eq scr screen)
  56.           (screen-mapped-p scr)
  57.           (progn
  58.         (map-screen scr)
  59.         ;; Unmapped screens can forget their geometry, so we have to restore it.
  60.         (let* ((geom (cdr (assq scr auto-unmap-screens-geometry))))
  61.           (if geom
  62.               (progn
  63.             (change-screen-size (car geom) (nth 1 geom) scr)
  64.             (move-screen (nth 2 geom) (nth 3 geom) scr))))))))
  65.        auto-unmap-screens)
  66.     ;; Unmapping.
  67.     (or (normal-screens (screen-list))
  68.     ;; No more normal screens are mapped: unmap all others.
  69.     (mapcar
  70.      (function
  71.       (lambda (scr)
  72.         (setq scr (eval scr))
  73.         (or (not (screen-p scr))
  74.         (not (screen-mapped-p scr))
  75.         ;; Unmapped screens can forget their geometry, so we have to remember it.
  76.         (let* ((entry (assq scr auto-unmap-screens-geometry))
  77.                (info (epoch::screen-information scr))
  78.                (border (nth 5 info))
  79.                (x (- (car info) border))
  80.                (y (- (nth 1 info) border))
  81.                (geom (list (epoch::screen-width scr)
  82.                    (epoch::screen-height scr)
  83.                    x y)))
  84.           (if entry
  85.               (setcdr entry geom)
  86.             (setq auto-unmap-screens-geometry
  87.               (append auto-unmap-screens-geometry
  88.                   (list (cons scr geom)))))
  89.           (unmap-screen scr)))))
  90.      auto-unmap-screens))))
  91.     
  92. (setq auto-unmap-screens (append auto-unmap-screens (list '(minibuf-screen))))
  93. (push-event 'map 'my-map-event-handler)
  94.