Calculate the actual char height of the mode-line.

doom-modeline-height is the minimal height of mode-line. It respects the actual
char height.
This commit is contained in:
Vincent Zhang 2019-05-21 14:32:50 +08:00
parent d306c3f0d3
commit 825c2bed71
3 changed files with 17 additions and 10 deletions

View file

@ -134,10 +134,11 @@ Strongly recommend to use
## Customize ## Customize
``` emacs-lisp ``` emacs-lisp
;; How tall the mode-line should be (only respected in GUI Emacs). ;; How tall the mode-line should be. It's only respected in GUI.
;; If the actual char height is larger, it respects the actual height.
(setq doom-modeline-height 25) (setq doom-modeline-height 25)
;; How wide the mode-line bar should be (only respected in GUI Emacs). ;; How wide the mode-line bar should be. It's only respected in GUI.
(setq doom-modeline-bar-width 3) (setq doom-modeline-bar-width 3)
;; Determines the style used by `doom-modeline-buffer-file-name'. ;; Determines the style used by `doom-modeline-buffer-file-name'.

View file

@ -131,14 +131,12 @@ It returns a file name which can be used directly as argument of
;; Variables ;; Variables
;; ;;
(defvar doom-modeline-height (let ((font (face-font 'mode-line))) (defvar doom-modeline-height 25
(if (and font (fboundp 'font-info)) "How tall the mode-line should be. It's only respected in GUI.
(* 2 (aref (font-info font) 2)) If the actual char height is larger, it respects the actual char height.")
25))
"How tall the mode-line should be (only respected in GUI Emacs).")
(defvar doom-modeline-bar-width (if (eq system-type 'darwin) 3 6) (defvar doom-modeline-bar-width (if (eq system-type 'darwin) 3 6)
"How wide the mode-line bar should be (only respected in GUI Emacs).") "How wide the mode-line bar should be. It's only respected in GUI.")
(defvar doom-modeline-buffer-file-name-style 'truncate-upto-project (defvar doom-modeline-buffer-file-name-style 'truncate-upto-project
"Determines the style used by `doom-modeline-buffer-file-name'. "Determines the style used by `doom-modeline-buffer-file-name'.
@ -488,6 +486,14 @@ It returns a file name which can be used directly as argument of
"Whether is an active window." "Whether is an active window."
(eq (selected-window) doom-modeline-current-window)) (eq (selected-window) doom-modeline-current-window))
(defun doom-modeline--char-height ()
"Calculate the actual char height of the mode-line."
(or
(let ((font (face-font 'mode-line)))
(when (and font (fboundp 'font-info))
(* 2 (aref (font-info font) 2))))
(round (* 1.3 (frame-char-height)))))
(defsubst doom-modeline-vspc () (defsubst doom-modeline-vspc ()
"Text style with icons in mode-line." "Text style with icons in mode-line."
(propertize " " 'face (if (doom-modeline--active) (propertize " " 'face (if (doom-modeline--active)

View file

@ -1226,12 +1226,12 @@ Returns \"\" to not break --no-window-system."
(doom-modeline--make-xpm 'doom-modeline-bar (doom-modeline--make-xpm 'doom-modeline-bar
(or width doom-modeline-bar-width) (or width doom-modeline-bar-width)
(max (or height doom-modeline-height) (max (or height doom-modeline-height)
(ceiling (* 1.3 (frame-char-height))))) (doom-modeline--char-height)))
doom-modeline--bar-inactive doom-modeline--bar-inactive
(doom-modeline--make-xpm 'doom-modeline-inactive-bar (doom-modeline--make-xpm 'doom-modeline-inactive-bar
(or width doom-modeline-bar-width) (or width doom-modeline-bar-width)
(max (or height doom-modeline-height) (max (or height doom-modeline-height)
(ceiling (* 1.3 (frame-char-height))))))) (doom-modeline--char-height)))))
(when (>= emacs-major-version 26) (when (>= emacs-major-version 26)
(add-variable-watcher (add-variable-watcher