modeline: refactor+optimize xpm generation
This commit is contained in:
parent
2f12e49a13
commit
b6ed1cf6c5
1 changed files with 29 additions and 10 deletions
|
@ -20,6 +20,9 @@
|
||||||
(defvar doom-modeline-height 29
|
(defvar doom-modeline-height 29
|
||||||
"How tall the mode-line should be. This is only respected in GUI emacs.")
|
"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
|
;; Custom faces
|
||||||
(defface doom-modeline-alternate '((t (:inherit mode-line)))
|
(defface doom-modeline-alternate '((t (:inherit mode-line)))
|
||||||
"Secondary color for the modeline.")
|
"Secondary color for the modeline.")
|
||||||
|
@ -104,6 +107,15 @@ cached the first time."
|
||||||
(add-hook 'find-file-hook 'doom-ml|env-update)
|
(add-hook 'find-file-hook 'doom-ml|env-update)
|
||||||
`(add-hook ',mode (lambda () (setq doom-ml--env-command ,command))))
|
`(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
|
;; 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)
|
(defun doom-modeline (&optional id)
|
||||||
`(:eval
|
`(:eval
|
||||||
(let* ((active (eq (selected-window) doom-ml-selected-window))
|
(let* ((active (eq (selected-window) doom-ml-selected-window))
|
||||||
(lhs (list (propertize " "
|
(lhs (list (propertize
|
||||||
'display
|
" " 'display (doom-make-xpm (if active
|
||||||
(pl/percent-xpm doom-modeline-height 100 0 100 0 3
|
doom-modeline-bar-active
|
||||||
(face-background (if active 'doom-modeline-bar 'mode-line-inactive))
|
doom-modeline-bar-inactive)
|
||||||
nil))
|
doom-modeline-height
|
||||||
|
doom-modeline-bar-width))
|
||||||
(*macro-recording)
|
(*macro-recording)
|
||||||
(*selection-info)
|
(*selection-info)
|
||||||
(*anzu)
|
(*anzu)
|
||||||
|
@ -399,15 +418,15 @@ to be enabled."
|
||||||
;; Eldoc-in-mode-line support (for `eval-expression')
|
;; Eldoc-in-mode-line support (for `eval-expression')
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defvar doom-eldoc-modeline-bar
|
(defvar doom-modeline-eldoc-bar-color (face-background 'doom-modeline-eldoc-bar)
|
||||||
(pl/percent-xpm doom-modeline-height 100 0 100 0 3
|
"The color to use for the bar when eldoc uses the mode-line.")
|
||||||
(face-background 'doom-modeline-eldoc-bar)
|
|
||||||
nil))
|
|
||||||
|
|
||||||
(defun doom-eldoc-modeline ()
|
(defun doom-eldoc-modeline ()
|
||||||
`(:eval
|
`(:eval
|
||||||
(let ((active (eq (selected-window) doom-ml-selected-window)))
|
(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))
|
(and (bound-and-true-p str) str))
|
||||||
(propertize " " 'display `((space :align-to (1- (+ right right-fringe right-margin)))))))))
|
(propertize " " 'display `((space :align-to (1- (+ right right-fringe right-margin)))))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue