Refactor zoom-frame microstate to use spacemacs microstate macro.

Modify zoom in and out to keep frame the same size.
This commit is contained in:
Rich Alesi 2015-03-25 22:53:57 -07:00 committed by syl20bnr
parent 31deb94d7f
commit 3edf542762

View file

@ -130,55 +130,49 @@
zoom-frm-in)
:init
(progn
(defun spacemacs/zoom-frame-overlay-map ()
"Set a temporary overlay map to easily change the font size."
(set-temporary-overlay-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "+") 'spacemacs/zoom-in-frame)
(define-key map (kbd "-") 'spacemacs/zoom-out-frame)
(define-key map (kbd "=") 'spacemacs/reset-zoom)
map) t))
(spacemacs|define-micro-state zoom-frm
:doc "Zoom Frame [+] zoom frame in [-] zoom frame out [=] reset zoom"
:evil-leader "zf"
:use-minibuffer t
:bindings
("+" spacemacs/zoom-frm-in :post 'spacemacs//powerline-calc)
("-" spacemacs/zoom-frm-out :post 'spacemacs//powerline-calc)
("=" spacemacs/zoom-frm-unzoom :post 'spacemacs//powerline-calc))
(defun spacemacs/zoom-frame-micro-state-doc ()
"Display a short documentation in the mini buffer."
(echo "Zoom Frame micro-state
+ to zoom frame in
- to zoom frame out
= to reset zoom
Press any other key to exit."))
(defun spacemacs/zoom-in-frame ()
"Zoom in frame."
(interactive)
(spacemacs/zoom-in-or-out 1))
(defun spacemacs/zoom-out-frame ()
"Zoom out frame."
(interactive)
(spacemacs/zoom-in-or-out -1))
(defun spacemacs/reset-zoom ()
"Reset the zoom."
(interactive)
(spacemacs/zoom-in-or-out 0))
(defun spacemacs/zoom-in-or-out (direction)
"Zoom the buffer in/out. If DIRECTION is positive or zero the frame text is enlarged,
otherwise it is reduced."
(interactive)
(cond
((eq direction 0) (zoom-frm-unzoom))
((< direction 0) (zoom-frm-out))
((> direction 0) (zoom-frm-in)))
(defun spacemacs//powerline-calc ()
(when (fboundp 'powerline-reset)
(setq-default powerline-height (spacemacs/compute-powerline-height))
(powerline-reset))
(spacemacs/zoom-frame-overlay-map)
(spacemacs/zoom-frame-micro-state-doc))
(evil-leader/set-key
"zf+" 'spacemacs/zoom-in-frame
"zf-" 'spacemacs/zoom-out-frame
"zf=" 'spacemacs/reset-zoom))))
(powerline-reset)))
(defun spacemacs/zoom-frm-in ()
"zoom in frame, but keep the same pixel size"
(interactive)
(let ((fwp (* (frame-char-width) (frame-width)))
(fhp (* (frame-char-height) (frame-height))))
(zoom-frm-in)
(set-frame-size nil fwp fhp t)
))
(defun spacemacs/zoom-frm-out ()
"zoom out frame, but keep the same pixel size"
(interactive)
(let ((fwp (* (frame-char-width) (frame-width)))
(fhp (* (frame-char-height) (frame-height))))
(zoom-frm-out)
(set-frame-size nil fwp fhp t)
))
(defun spacemacs/zoom-frm-unzoom ()
"Unzoom current frame, keeping the same pixel size"
(interactive)
(let ((fwp (* (frame-char-width) (frame-width)))
(fhp (* (frame-char-height) (frame-height))))
(zoom-frm-unzoom)
(set-frame-size nil fwp fhp t)
))
;; Font size, either with ctrl + mouse wheel
(global-set-key (kbd "C-<wheel-up>") 'spacemacs/zoom-frm-in)
(global-set-key (kbd "C-<wheel-down>") 'spacemacs/zoom-frm-out))))
(defun spacemacs/init-emacs-builtin-process-menu ()
(evilify process-menu-mode process-menu-mode-map))