modeline: refactor+optimize xpm generation
This commit is contained in:
parent
2f12e49a13
commit
b6ed1cf6c5
|
@ -20,6 +20,9 @@
|
|||
(defvar doom-modeline-height 29
|
||||
"How tall the mode-line should be. This is only respected in GUI emacs.")
|
||||
|
||||
(defvar doom-modeline-bar-width 3
|
||||
"How wide the mode-line bar should be. This is only respected in GUI emacs.")
|
||||
|
||||
;; Custom faces
|
||||
(defface doom-modeline-alternate '((t (:inherit mode-line)))
|
||||
"Secondary color for the modeline.")
|
||||
|
@ -104,6 +107,15 @@ cached the first time."
|
|||
(add-hook 'find-file-hook 'doom-ml|env-update)
|
||||
`(add-hook ',mode (lambda () (setq doom-ml--env-command ,command))))
|
||||
|
||||
(defun doom-make-xpm (color height width)
|
||||
"Create an XPM bitmap."
|
||||
(let ((data nil)
|
||||
(i 0))
|
||||
(setq data (make-list height (make-list width 1)))
|
||||
(pl/make-xpm "percent" color color (reverse data))))
|
||||
|
||||
(pl/memoize 'doom-make-xpm)
|
||||
|
||||
|
||||
;;
|
||||
;; Initialization
|
||||
|
@ -365,14 +377,21 @@ to be enabled."
|
|||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar doom-modeline-bar-active (face-background 'doom-modeline-bar)
|
||||
"The color to use for the bar in active window mode-lines.")
|
||||
|
||||
(defvar doom-modeline-bar-inactive (face-background 'mode-line-inactive)
|
||||
"The color to use for the bar in inactive window mode-lines.")
|
||||
|
||||
(defun doom-modeline (&optional id)
|
||||
`(:eval
|
||||
(let* ((active (eq (selected-window) doom-ml-selected-window))
|
||||
(lhs (list (propertize " "
|
||||
'display
|
||||
(pl/percent-xpm doom-modeline-height 100 0 100 0 3
|
||||
(face-background (if active 'doom-modeline-bar 'mode-line-inactive))
|
||||
nil))
|
||||
(lhs (list (propertize
|
||||
" " 'display (doom-make-xpm (if active
|
||||
doom-modeline-bar-active
|
||||
doom-modeline-bar-inactive)
|
||||
doom-modeline-height
|
||||
doom-modeline-bar-width))
|
||||
(*macro-recording)
|
||||
(*selection-info)
|
||||
(*anzu)
|
||||
|
@ -399,15 +418,15 @@ to be enabled."
|
|||
;; Eldoc-in-mode-line support (for `eval-expression')
|
||||
;;
|
||||
|
||||
(defvar doom-eldoc-modeline-bar
|
||||
(pl/percent-xpm doom-modeline-height 100 0 100 0 3
|
||||
(face-background 'doom-modeline-eldoc-bar)
|
||||
nil))
|
||||
(defvar doom-modeline-eldoc-bar-color (face-background 'doom-modeline-eldoc-bar)
|
||||
"The color to use for the bar when eldoc uses the mode-line.")
|
||||
|
||||
(defun doom-eldoc-modeline ()
|
||||
`(:eval
|
||||
(let ((active (eq (selected-window) doom-ml-selected-window)))
|
||||
(list (list (propertize " " 'display doom-eldoc-modeline-bar)
|
||||
(list (list (propertize " " 'display (doom-make-xpm doom-modeline-eldoc-bar-color
|
||||
doom-modeline-height
|
||||
doom-modeline-bar-width))
|
||||
(and (bound-and-true-p str) str))
|
||||
(propertize " " 'display `((space :align-to (1- (+ right right-fringe right-margin)))))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user