[Enhancement] New modal segment.

An indicator for modal editing state, including evil, god, ryo and xah-fly-keys, etc.
This commit is contained in:
Vincent Zhang 2019-04-22 23:35:52 +08:00
parent 108fd78261
commit 2140ded3de
3 changed files with 19 additions and 31 deletions

View file

@ -24,10 +24,8 @@ The `doom-modeline` was designed for minimalism, and offers:
- A workspace number segment for `eyebrowse` - A workspace number segment for `eyebrowse`
- A perspective name segment for `persp-mode` - A perspective name segment for `persp-mode`
- A window number segment for `ace-window`, `winum` and `window-numbering` - A window number segment for `ace-window`, `winum` and `window-numbering`
- An indicator for `evil` state - An indicator for modal editing state, including `evil`, `god`, `ryo` and
- An indicator for `god` state `xah-fly-keys`, etc.
- An indicator for `ryo-modal` state
- An indicator for `xah-fly-keys` state
- An indicator for remote host - An indicator for remote host
- An indicator for debug state - An indicator for debug state
- An indicator for current input method - An indicator for current input method

View file

@ -1399,10 +1399,10 @@ mouse-1: Display Line and Column Mode Menu"
(concat " " (parrot-create) " "))) (concat " " (parrot-create) " ")))
;; ;;
;; evil-state ;; modals (evil, god, ryo and xah-fly-keys, etc.)
;; ;;
(doom-modeline-def-segment evil-state (defsubst doom-modeline--evil ()
"The current evil state. Requires `evil-mode' to be enabled." "The current evil state. Requires `evil-mode' to be enabled."
(when (bound-and-true-p evil-local-mode) (when (bound-and-true-p evil-local-mode)
(let ((tag (evil-state-property evil-state :tag t))) (let ((tag (evil-state-property evil-state :tag t)))
@ -1417,37 +1417,22 @@ mouse-1: Display Line and Column Mode Menu"
((evil-replace-state-p) 'doom-modeline-evil-replace-state)) ((evil-replace-state-p) 'doom-modeline-evil-replace-state))
'mode-line-inactive))))) 'mode-line-inactive)))))
(defsubst doom-modeline--god ()
;;
;; god-state
;;
(doom-modeline-def-segment god-state
"The current god state. Requires `god-mode' to be enabled." "The current god state. Requires `god-mode' to be enabled."
(when (bound-and-true-p god-local-mode) (when (bound-and-true-p god-local-mode)
(propertize " <G> " 'face (if (doom-modeline--active) (propertize " <G> " 'face (if (doom-modeline--active)
'doom-modeline-evil-normal-state 'doom-modeline-evil-normal-state
'mode-line-inactive)))) 'mode-line-inactive))))
(defsubst doom-modeline--ryo ()
;;
;; ryo-modal state
;;
(doom-modeline-def-segment ryo-modal ()
"The current ryo-modal state. Requires `ryo-modal-mode' to be enabled." "The current ryo-modal state. Requires `ryo-modal-mode' to be enabled."
(when (bound-and-true-p ryo-modal-mode) (when (bound-and-true-p ryo-modal-mode)
(propertize " <R> " 'face (if (doom-modeline--active) (propertize " <R> " 'face (if (doom-modeline--active)
'doom-modeline-evil-normal-state 'doom-modeline-evil-normal-state
'mode-line-inactive)))) 'mode-line-inactive))))
(defsubst doom-modeline--xah-fly-keys ()
;; "The current `xah-fly-keys' state."
;; xah-fly-keys state
;;
(doom-modeline-def-segment xah-fly-keys ()
"The current xah-fly-keys state."
(when (boundp 'xah-fly-insert-state-q) (when (boundp 'xah-fly-insert-state-q)
(propertize (if xah-fly-insert-state-q (propertize (if xah-fly-insert-state-q
" <I> " " <I> "
@ -1456,6 +1441,13 @@ mouse-1: Display Line and Column Mode Menu"
'doom-modeline-evil-normal-state 'doom-modeline-evil-normal-state
'mode-line-inactive)))) 'mode-line-inactive))))
(doom-modeline-def-segment modals
"Displays modal editing states, including `evil', `god', `ryo' and `xha-fly-kyes', etc. "
(concat (doom-modeline--evil)
(doom-modeline--god)
(doom-modeline--ryo)
(doom-modeline--xah-fly-keys)))
;; ;;
;; input method ;; input method
;; ;;

View file

@ -45,10 +45,8 @@
;; - A workspace number segment for eyebrowse ;; - A workspace number segment for eyebrowse
;; - A perspective name segment for persp-mode ;; - A perspective name segment for persp-mode
;; - A window number segment for winum and window-numbering ;; - A window number segment for winum and window-numbering
;; - An indicator for evil state ;; - An indicator for modal editing state, including evil, god, ryo and
;; - An indicator for god state ;; xah-fly-keys, etc.
;; - An indicator for ryo-modal state
;; - An indicator for xah-fly-keys state
;; - An indicator for remote host ;; - An indicator for remote host
;; - An indicator for current input method ;; - An indicator for current input method
;; - An indicator for debug state ;; - An indicator for debug state
@ -85,7 +83,7 @@
;; ;;
(doom-modeline-def-modeline 'main (doom-modeline-def-modeline 'main
'(bar workspace-name window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info) '(bar workspace-name window-number modals matches buffer-info remote-host buffer-position parrot selection-info)
'(misc-info persp-name lsp irc mu4e github debug fancy-battery minor-modes input-method buffer-encoding major-mode process vcs checker)) '(misc-info persp-name lsp irc mu4e github debug fancy-battery minor-modes input-method buffer-encoding major-mode process vcs checker))
(doom-modeline-def-modeline 'minimal (doom-modeline-def-modeline 'minimal
@ -93,7 +91,7 @@
'(media-info major-mode)) '(media-info major-mode))
(doom-modeline-def-modeline 'special (doom-modeline-def-modeline 'special
'(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info) '(bar window-number modals matches buffer-info-simple buffer-position parrot selection-info)
'(misc-info lsp irc-buffers debug fancy-battery minor-modes input-method buffer-encoding major-mode process checker)) '(misc-info lsp irc-buffers debug fancy-battery minor-modes input-method buffer-encoding major-mode process checker))
(doom-modeline-def-modeline 'project (doom-modeline-def-modeline 'project