Refactor zoom-frame micro-state and fix post action
This commit is contained in:
parent
3edf542762
commit
6493fb1247
|
@ -131,45 +131,44 @@
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
(spacemacs|define-micro-state zoom-frm
|
(spacemacs|define-micro-state zoom-frm
|
||||||
:doc "Zoom Frame [+] zoom frame in [-] zoom frame out [=] reset zoom"
|
:doc "[+] zoom frame in [-] zoom frame out [=] reset zoom"
|
||||||
:evil-leader "zf"
|
:evil-leader "zf"
|
||||||
:use-minibuffer t
|
:use-minibuffer t
|
||||||
:bindings
|
:bindings
|
||||||
("+" spacemacs/zoom-frm-in :post 'spacemacs//powerline-calc)
|
("+" spacemacs/zoom-frm-in :post (spacemacs//zoom-frm-powerline-reset))
|
||||||
("-" spacemacs/zoom-frm-out :post 'spacemacs//powerline-calc)
|
("-" spacemacs/zoom-frm-out :post (spacemacs//zoom-frm-powerline-reset))
|
||||||
("=" spacemacs/zoom-frm-unzoom :post 'spacemacs//powerline-calc))
|
("=" spacemacs/zoom-frm-unzoom :post (spacemacs//zoom-frm-powerline-reset)))
|
||||||
|
|
||||||
(defun spacemacs//powerline-calc ()
|
(defun spacemacs//zoom-frm-powerline-reset ()
|
||||||
(when (fboundp 'powerline-reset)
|
(when (fboundp 'powerline-reset)
|
||||||
(setq-default powerline-height (spacemacs/compute-powerline-height))
|
(setq-default powerline-height (spacemacs/compute-powerline-height))
|
||||||
(powerline-reset)))
|
(powerline-reset)))
|
||||||
|
|
||||||
|
(defun spacemacs//zoom-frm-do (arg)
|
||||||
|
"Perform a zoom action depending on ARG value."
|
||||||
|
(let ((zoom-action (cond ((eq arg 0) 'zoom-frm-unzoom)
|
||||||
|
((< arg 0) 'zoom-frm-out)
|
||||||
|
((> arg 0) 'zoom-frm-in)))
|
||||||
|
(fwp (* (frame-char-width) (frame-width)))
|
||||||
|
(fhp (* (frame-char-height) (frame-height))))
|
||||||
|
(funcall zoom-action)
|
||||||
|
(set-frame-size nil fwp fhp t)))
|
||||||
|
|
||||||
(defun spacemacs/zoom-frm-in ()
|
(defun spacemacs/zoom-frm-in ()
|
||||||
"zoom in frame, but keep the same pixel size"
|
"zoom in frame, but keep the same pixel size"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((fwp (* (frame-char-width) (frame-width)))
|
(spacemacs//zoom-frm-do 1))
|
||||||
(fhp (* (frame-char-height) (frame-height))))
|
|
||||||
(zoom-frm-in)
|
|
||||||
(set-frame-size nil fwp fhp t)
|
|
||||||
))
|
|
||||||
|
|
||||||
(defun spacemacs/zoom-frm-out ()
|
(defun spacemacs/zoom-frm-out ()
|
||||||
"zoom out frame, but keep the same pixel size"
|
"zoom out frame, but keep the same pixel size"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((fwp (* (frame-char-width) (frame-width)))
|
(spacemacs//zoom-frm-do -1))
|
||||||
(fhp (* (frame-char-height) (frame-height))))
|
|
||||||
(zoom-frm-out)
|
|
||||||
(set-frame-size nil fwp fhp t)
|
|
||||||
))
|
|
||||||
|
|
||||||
(defun spacemacs/zoom-frm-unzoom ()
|
(defun spacemacs/zoom-frm-unzoom ()
|
||||||
"Unzoom current frame, keeping the same pixel size"
|
"Unzoom current frame, keeping the same pixel size"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((fwp (* (frame-char-width) (frame-width)))
|
(spacemacs//zoom-frm-do 0))
|
||||||
(fhp (* (frame-char-height) (frame-height))))
|
|
||||||
(zoom-frm-unzoom)
|
|
||||||
(set-frame-size nil fwp fhp t)
|
|
||||||
))
|
|
||||||
;; Font size, either with ctrl + mouse wheel
|
;; Font size, either with ctrl + mouse wheel
|
||||||
(global-set-key (kbd "C-<wheel-up>") 'spacemacs/zoom-frm-in)
|
(global-set-key (kbd "C-<wheel-up>") 'spacemacs/zoom-frm-in)
|
||||||
(global-set-key (kbd "C-<wheel-down>") 'spacemacs/zoom-frm-out))))
|
(global-set-key (kbd "C-<wheel-down>") 'spacemacs/zoom-frm-out))))
|
||||||
|
|
Loading…
Reference in a new issue