Fix #68: Size of state icons.

This commit is contained in:
Vincent Zhang 2018-12-19 16:27:20 +08:00
parent 888efb61ec
commit ebf3ddd249

View file

@ -753,40 +753,42 @@ buffer where knowing the current project directory is important."
(add-hook 'after-change-major-mode-hook 'doom-modeline-update-buffer-file-icon) (add-hook 'after-change-major-mode-hook 'doom-modeline-update-buffer-file-icon)
(add-hook 'clone-indirect-buffer-hook 'doom-modeline-update-buffer-file-icon) (add-hook 'clone-indirect-buffer-hook 'doom-modeline-update-buffer-file-icon)
(defun doom-modeline-buffer-file-state-icon (icon &optional face height voffset)
"Displays an ICON with FACE, HEIGHT and VOFFSET.
Uses `all-the-icons-material' to fetch the icon."
(when icon
(doom-modeline-icon-material
icon
:face (if (doom-modeline--active) face)
:height (or height (if (eq system-type 'darwin) 1.0 0.96))
:v-adjust (or voffset (if (eq system-type 'darwin) -0.225 -0.205)))))
(defvar-local doom-modeline--buffer-file-state-icon nil) (defvar-local doom-modeline--buffer-file-state-icon nil)
(defun doom-modeline-update-buffer-file-state-icon (&rest _) (defun doom-modeline-update-buffer-file-state-icon (&rest _)
"Update the buffer or file state in mode-line." "Update the buffer or file state in mode-line."
(setq doom-modeline--buffer-file-state-icon (setq doom-modeline--buffer-file-state-icon
(let ((active (doom-modeline--active))) (cond (buffer-read-only
(cond (buffer-read-only (concat (doom-modeline-buffer-file-state-icon
(concat (doom-modeline-icon-material "lock"
"lock" 'doom-modeline-warning)
:face (if active 'doom-modeline-warning) doom-modeline-vspc))
:height 1.0 ((buffer-modified-p)
:v-adjust -0.225) (concat (doom-modeline-buffer-file-state-icon
doom-modeline-vspc)) "save"
((buffer-modified-p) 'doom-modeline-buffer-modified)
(concat (doom-modeline-icon-material doom-modeline-vspc))
"save" ((and buffer-file-name
:face (if active 'doom-modeline-buffer-modified) (not (file-exists-p buffer-file-name)))
:height 1.0 (concat (doom-modeline-buffer-file-state-icon
:v-adjust -0.225) "do_not_disturb_alt"
doom-modeline-vspc)) 'doom-modeline-urgent)
((and buffer-file-name doom-modeline-vspc))
(not (file-exists-p buffer-file-name))) ((buffer-narrowed-p)
(concat (doom-modeline-icon-material (concat (doom-modeline-buffer-file-state-icon
"do_not_disturb_alt" "unfold_less"
:face (if active 'doom-modeline-urgent) 'doom-modeline-warning
:height 1.0 1.1)
:v-adjust -0.225) doom-modeline-vspc)))))
doom-modeline-vspc))
((buffer-narrowed-p)
(concat (doom-modeline-icon-material
"unfold_less"
:face (if active 'doom-modeline-warning)
:height 1.2
:v-adjust -0.25)
doom-modeline-vspc))))))
(add-hook 'find-file-hook 'doom-modeline-update-buffer-file-state-icon) (add-hook 'find-file-hook 'doom-modeline-update-buffer-file-state-icon)
(add-hook 'after-save-hook 'doom-modeline-update-buffer-file-state-icon) (add-hook 'after-save-hook 'doom-modeline-update-buffer-file-state-icon)
(add-hook 'after-revert-hook 'doom-modeline-update-buffer-file-state-icon) (add-hook 'after-revert-hook 'doom-modeline-update-buffer-file-state-icon)
@ -995,7 +997,11 @@ Uses `all-the-icons-material' to fetch the icon."
(concat " " (concat " "
(when icon (when icon
(concat (concat
(doom-modeline-icon-material icon :face face :height 1.0 :v-adjust (or voffset -0.225)) (doom-modeline-icon-material
icon
:face face
:height (if (eq system-type 'darwin) 1.0 0.96)
:v-adjust (or voffset (if (eq system-type 'darwin) -0.225 -0.205)))
(if text doom-modeline-vspc))) (if text doom-modeline-vspc)))
(if text (propertize text 'face face)) (if text (propertize text 'face face))
" ")) " "))