[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cheesy Hacks #2: Zoomkey

Time for the next Cheesy Hack. I find this one very handy because it's
much quicker to just hit ctrl-Z than to grab the mouse and find the 
stupid zoombox, which of course wanders all over the place.

;;; zoomkey3.lisp
;;; Cheesy Hacks #2 (3/21/94)
;;; Keystroke Control-Z will zoom current MCL window in/out, just like
;;; clicking on its zoom box.
;;; 10/23/93 Shannon Spires
;;; 12/8/93 SVS updated so that function is not anonymous anymore and will
;;;    show up properly in the Fred Commands window.
;;; 2/12/94 Version 3. SVS added functionality so it also work in inspector
;;;    windows.
;;; No guarantees--use at your own risk.

(defmethod %ed-zoom-window ((w window))
  (setq w (view-window w))
    (if (= (view-size w) (window-zoom-size w))
      (window-zoom-event-handler w #$inZoomIn)
      (window-zoom-event-handler w #$inZoomOut)

(defun ed-zoom-window (w) (eval-enqueue `(%ed-zoom-window ,w)))

(comtab-set-key *comtab* '(:control #\z) 'ed-zoom-window)

Note that the following form won't work:
(comtab-set-key *comtab* '(:control #\z) '%ed-zoom-window)

If you do this, it zooms okay, but doesn't redraw scroll bars and window contents
properly. But if you type (%ed-zoom-window (front-window)) into the listener, it
works right. Solution is to make the keystroke command be evaluated like things
typed into the listener are evaluated, thus eval-enqueue is used.

Ironically (and possibly _because_ of the eval-enqueue), the keystroke does nothing
if a long lisp operation is going on, like a big Load. (Well, actually, the keystroke
goes to the end of the queue and is delayed until the long Lisp operation completes.)
Curiously, clicking the mouse on the zoom box _does_ work in this circumstance.
Fixing this and explaining the behavior is left as an exercise to the reader.

; This makes it also work in inspector windows:
(defmethod view-key-event-handler :around ((view inspector::inspector-window) key)
  (if (eql key #\^Z) ; for some reason, this is not the same as '(:control #\z) and
                     ;  it won't work if you write it that way.
    (ed-zoom-window view)

;;; End of Cheesy Hacks #2.