Refactor :ui modeline +light
This commit is contained in:
parent
e00bfc7612
commit
0252f4f36f
1 changed files with 230 additions and 226 deletions
|
@ -50,17 +50,17 @@ side of the modeline, and whose CDR is the right-hand side.")
|
|||
;;
|
||||
;;; Faces
|
||||
|
||||
(defface +modeline-bar-active '((t (:inherit highlight)))
|
||||
(defface doom-modeline-bar '((t (:inherit highlight)))
|
||||
"Face used for left-most bar on the mode-line of an active window.")
|
||||
|
||||
(defface +modeline-bar-inactive '((t (:inherit mode-line-inactive)))
|
||||
(defface doom-modeline-bar-inactive '((t (:inherit mode-line-inactive)))
|
||||
"Face used for left-most bar on the mode-line of an inactive window.")
|
||||
|
||||
(defface +modeline-highlight
|
||||
(defface doom-modeline-highlight
|
||||
'((t (:inherit mode-line-highlight)))
|
||||
"Face used for highlighted modeline panels (like search counts).")
|
||||
|
||||
(defface +modeline-alternate-highlight
|
||||
(defface doom-modeline-alternate-highlight
|
||||
'((t (:inherit mode-line-highlight)))
|
||||
"Alternative face used for highlighted modeline panels (like search counts).")
|
||||
|
||||
|
@ -175,24 +175,31 @@ LHS and RHS will accept."
|
|||
|
||||
|
||||
;;; `+modeline-bar'
|
||||
(progn
|
||||
(def-modeline-var! +modeline-bar "")
|
||||
(def-modeline-var! +modeline-inactive-bar "")
|
||||
|
||||
(defvar +modeline-active-bar "")
|
||||
(defvar +modeline-inactive-bar "")
|
||||
|
||||
(add-hook! '(doom-init-ui-hook doom-load-theme-hook) :append
|
||||
(defun +modeline-refresh-bars-h ()
|
||||
(let ((width (or +modeline-bar-width 1))
|
||||
(height (max +modeline-height 0)))
|
||||
(setq +modeline-bar
|
||||
(+modeline--make-xpm
|
||||
(and +modeline-bar-width
|
||||
(face-background '+modeline-bar-active nil t))
|
||||
(height (max +modeline-height 0))
|
||||
(active-bg (face-background 'doom-modeline-bar nil t))
|
||||
(inactive-bg (face-background 'doom-modeline-bar-inactive nil t)))
|
||||
(when (or (null +modeline-bar-width)
|
||||
(= +modeline-bar-width 0))
|
||||
(setq active-bg nil
|
||||
inactive-bg nil))
|
||||
(setq +modeline-active-bar
|
||||
(+modeline--make-xpm (and +modeline-bar-width active-bg)
|
||||
width height)
|
||||
+modeline-inactive-bar
|
||||
(+modeline--make-xpm
|
||||
(and +modeline-bar-width
|
||||
(face-background '+modeline-bar-inactive nil t))
|
||||
width height)))))
|
||||
(+modeline--make-xpm (and +modeline-bar-width inactive-bg)
|
||||
width height)
|
||||
+modeline-bar
|
||||
'(:eval (if (+modeline-active)
|
||||
+modeline-active-bar
|
||||
+modeline-inactive-bar))))))
|
||||
|
||||
(add-hook! 'doom-change-font-size-hook
|
||||
(defun +modeline-adjust-height-h ()
|
||||
|
@ -205,11 +212,10 @@ LHS and RHS will accept."
|
|||
doom-font-increment))
|
||||
default-height))
|
||||
(when doom-init-time
|
||||
(+modeline-refresh-bars-h))))))
|
||||
(+modeline-refresh-bars-h)))))
|
||||
|
||||
|
||||
;;; `+modeline-matches'
|
||||
(progn
|
||||
(use-package! anzu
|
||||
:after-call isearch-mode
|
||||
:config
|
||||
|
@ -226,8 +232,7 @@ LHS and RHS will accept."
|
|||
anzu--cached-count
|
||||
anzu--cached-positions anzu--last-command
|
||||
anzu--last-isearch-string anzu--overflow-p))
|
||||
|
||||
(anzu-mode +1))
|
||||
(global-anzu-mode +1))
|
||||
|
||||
(use-package! evil-anzu
|
||||
:when (featurep! :editor evil)
|
||||
|
@ -250,7 +255,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
(format " %s+ " total))
|
||||
(t
|
||||
(format " %s/%d " here total))))
|
||||
'face (if (+modeline-active) '+modeline-highlight))))
|
||||
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||
|
||||
(defun +modeline--evil-substitute ()
|
||||
"Show number of matches for evil-ex substitutions and highlights in real time."
|
||||
|
@ -266,7 +271,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
(if pattern
|
||||
(format " %s matches " (how-many pattern (car range) (cdr range)))
|
||||
" - "))
|
||||
'face (if (+modeline-active) '+modeline-highlight))))
|
||||
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||
|
||||
(defun +modeline--multiple-cursors ()
|
||||
"Show the number of multiple cursors."
|
||||
|
@ -274,8 +279,8 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
(let ((count (length evil-mc-cursor-list)))
|
||||
(when (> count 0)
|
||||
(let ((face (cond ((not (+modeline-active)) 'mode-line-inactive)
|
||||
(evil-mc-frozen '+modeline-highlight)
|
||||
('+modeline-alternate-highlight))))
|
||||
(evil-mc-frozen 'doom-modeline-highlight)
|
||||
('doom-modeline-alternate-highlight))))
|
||||
(concat (propertize " " 'face face)
|
||||
(all-the-icons-faicon "i-cursor" :face face :v-adjust -0.0575)
|
||||
(propertize " " 'face `(:inherit (variable-pitch ,face)))
|
||||
|
@ -305,22 +310,22 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
-1)
|
||||
"-")
|
||||
length))
|
||||
'face (if (+modeline-active) '+modeline-highlight))))
|
||||
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||
|
||||
(defun +modeline--macro-recording ()
|
||||
"Display current Emacs or evil macro being recorded."
|
||||
(when (and (+modeline-active)
|
||||
(or defining-kbd-macro
|
||||
executing-kbd-macro))
|
||||
(let ((sep (propertize " " 'face '+modeline-highlight)))
|
||||
(let ((sep (propertize " " 'face 'doom-modeline-highlight)))
|
||||
(concat sep
|
||||
(propertize (if (bound-and-true-p evil-this-macro)
|
||||
(char-to-string evil-this-macro)
|
||||
"Macro")
|
||||
'face '+modeline-highlight)
|
||||
'face 'doom-modeline-highlight)
|
||||
sep
|
||||
(all-the-icons-octicon "triangle-right"
|
||||
:face '+modeline-highlight
|
||||
:face 'doom-modeline-highlight
|
||||
:v-adjust -0.05)
|
||||
sep))))
|
||||
|
||||
|
@ -332,7 +337,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
(+modeline--iedit)
|
||||
(+modeline--multiple-cursors))))
|
||||
(or (and (not (equal meta "")) meta)
|
||||
" %I ")))))
|
||||
" %I "))))
|
||||
|
||||
|
||||
;;; `+modeline-modes'
|
||||
|
@ -340,7 +345,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
'(""
|
||||
(:propertize mode-name
|
||||
face bold
|
||||
mouse-face +modeline-highlight)
|
||||
mouse-face doom-modeline-highlight)
|
||||
mode-line-process
|
||||
"%n"
|
||||
" "))
|
||||
|
@ -369,7 +374,6 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
|
||||
|
||||
;;; `+modeline-checker'
|
||||
(progn
|
||||
(def-modeline-var! +modeline-checker nil
|
||||
"Displays color-coded error status & icon for the current buffer."
|
||||
:local t)
|
||||
|
@ -399,11 +403,10 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
(`running (+modeline-format-icon "access_time" "*" 'font-lock-comment-face "Running..."))
|
||||
(`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!"))
|
||||
(`interrupted (+modeline-format-icon "pause" "!" 'font-lock-comment-face "Interrupted"))
|
||||
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious")))))))
|
||||
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious"))))))
|
||||
|
||||
|
||||
;;; `+modeline-selection-info'
|
||||
(progn
|
||||
(defsubst +modeline--column (pos)
|
||||
"Get the column of the position `POS'."
|
||||
(save-excursion (goto-char pos)
|
||||
|
@ -411,11 +414,11 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
|||
|
||||
(def-modeline-var! +modeline-selection-info
|
||||
'(:eval
|
||||
(when (or mark-active
|
||||
(and (bound-and-true-p evil-local-mode)
|
||||
(eq evil-state 'visual)))
|
||||
(when (or (and (bound-and-true-p evil-local-mode)
|
||||
(eq evil-state 'visual))
|
||||
mark-active)
|
||||
(cl-destructuring-bind (beg . end)
|
||||
(if (boundp 'evil-local-mode)
|
||||
(if (bound-and-true-p evil-visual-selection)
|
||||
(cons evil-visual-beginning evil-visual-end)
|
||||
(cons (region-beginning) (region-end)))
|
||||
(propertize
|
||||
|
@ -450,7 +453,7 @@ lines are selected, or the NxM dimensions of a block selection.")
|
|||
(add-hook 'evil-visual-state-entry-hook #'+modeline-add-selection-segment-h)
|
||||
(add-hook 'evil-visual-state-exit-hook #'+modeline-remove-selection-segment-h))
|
||||
(add-hook 'activate-mark-hook #'+modeline-add-selection-segment-h)
|
||||
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h)))
|
||||
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h))
|
||||
|
||||
|
||||
;;; `+modeline-encoding'
|
||||
|
@ -496,8 +499,8 @@ lines are selected, or the NxM dimensions of a block selection.")
|
|||
,(all-the-icons-octicon
|
||||
"file-directory"
|
||||
:face 'bold
|
||||
:v-adjust -0.05
|
||||
:height 1.25)
|
||||
:v-adjust -0.06
|
||||
:height 1.1)
|
||||
(:propertize (" " (:eval (abbreviate-file-name default-directory)))
|
||||
face bold))
|
||||
'("" mode-line-misc-info +modeline-modes))
|
||||
|
@ -507,7 +510,8 @@ lines are selected, or the NxM dimensions of a block selection.")
|
|||
" " +modeline-buffer-identification)
|
||||
'("" +modeline-modes))
|
||||
|
||||
;; TODO (def-modeline! pdf ...)
|
||||
;; (def-modeline! pdf
|
||||
;; '("" +modeline-matches))
|
||||
;; TODO (def-modeline! helm ...)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue