Improve grip indicator.

This commit is contained in:
Vincent Zhang 2019-08-18 22:08:46 +08:00
parent 2c01d9eb9e
commit c4a77d12c3

View file

@ -66,6 +66,7 @@
(defvar flymake--mode-line-format) (defvar flymake--mode-line-format)
(defvar flymake-menu) (defvar flymake-menu)
(defvar grip-port) (defvar grip-port)
(defvar grip-process)
(defvar helm--mode-line-display-prefarg) (defvar helm--mode-line-display-prefarg)
(defvar iedit-occurrences-overlays) (defvar iedit-occurrences-overlays)
(defvar mc/mode-line) (defvar mc/mode-line)
@ -2301,15 +2302,23 @@ The cdr can also be a function that returns a name to use.")
(when (bound-and-true-p grip-mode) (when (bound-and-true-p grip-mode)
(concat (concat
(doom-modeline-spc) (doom-modeline-spc)
(let ((face (if (doom-modeline--active)
(if grip-process
(pcase (process-status grip-process)
('run 'all-the-icons-lblue)
('exit 'warning)
(_ 'error))
'error)
'mode-line-inactive)))
(propertize (propertize
(if (display-graphic-p) (if doom-modeline-icon
(doom-modeline-icon-material "pageview" (doom-modeline-icon-material
:face (if (doom-modeline--active) "pageview"
'all-the-icons-lblue :face face
'mode-line-inactive) :height 1.2
:height 1.1 :v-adjust -0.2)
:v-adjust -0.225) (propertize "G" 'face `(:inherit (,face bold))))
"G")
'help-echo (format "Preview on: http://localhost:%d 'help-echo (format "Preview on: http://localhost:%d
mouse-1: Open browser mouse-1: Open browser
mouse-2: Stop preview" mouse-2: Stop preview"
@ -2322,7 +2331,8 @@ mouse-2: Stop preview"
(browse-url (format "http://localhost:%d" grip-port)))) (browse-url (format "http://localhost:%d" grip-port))))
(define-key map [mode-line mouse-2] (define-key map [mode-line mouse-2]
#'grip-mode) #'grip-mode)
map)) map)))
(doom-modeline-spc)))) (doom-modeline-spc))))
(provide 'doom-modeline-segments) (provide 'doom-modeline-segments)