Add doom/{increase,decrease,reset}-font commands

Borrows the idea from zoom-frm (see #1389).
This commit is contained in:
Henrik Lissner 2019-05-12 21:54:16 -04:00
parent ef4106dae8
commit 0f0fdbc00c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
8 changed files with 124 additions and 51 deletions

View file

@ -11,18 +11,22 @@
(defvar +modeline--old-bar-height nil)
;;;###autoload
(defun +modeline|resize-for-big-font ()
"Adjust the modeline's height when `doom-big-font-mode' is enabled. This was
made to be added to `doom-big-font-mode-hook'."
(defun +modeline|resize-for-font ()
"Adjust the modeline's height when the font size is changed by
`doom/increase-font-size' or `doom/decrease-font-size'.
Meant for `doom-change-font-size-hook'."
(unless +modeline--old-bar-height
(setq +modeline--old-bar-height doom-modeline-height))
(let ((default-height +modeline--old-bar-height))
(if doom-big-font-mode
(let* ((font-size (font-get doom-font :size))
(big-size (font-get doom-big-font :size))
(ratio (/ (float big-size) font-size)))
(setq doom-modeline-height (ceiling (* default-height ratio 0.75))))
(let ((default-height +modeline--old-bar-height)
(scale (or (frame-parameter nil 'font-scale) 0)))
(if (> scale 0)
(let* ((font-size (string-to-number
(aref (doom--font-name (frame-parameter nil 'font)
(selected-frame))
xlfd-regexp-pixelsize-subnum)))
(scale (frame-parameter nil 'font-scale)))
(setq doom-modeline-height (+ default-height (* scale doom-font-increment))))
(setq doom-modeline-height default-height))
;; already has a variable watcher in Emacs 26+
(unless EMACS26+ (doom-modeline-refresh-bars))))