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,28 +2302,37 @@ 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)
(propertize
(if (display-graphic-p) (let ((face (if (doom-modeline--active)
(doom-modeline-icon-material "pageview" (if grip-process
:face (if (doom-modeline--active) (pcase (process-status grip-process)
'all-the-icons-lblue ('run 'all-the-icons-lblue)
'mode-line-inactive) ('exit 'warning)
:height 1.1 (_ 'error))
:v-adjust -0.225) 'error)
"G") 'mode-line-inactive)))
'help-echo (format "Preview on: http://localhost:%d (propertize
(if doom-modeline-icon
(doom-modeline-icon-material
"pageview"
:face face
:height 1.2
:v-adjust -0.2)
(propertize "G" 'face `(:inherit (,face bold))))
'help-echo (format "Preview on: http://localhost:%d
mouse-1: Open browser mouse-1: Open browser
mouse-2: Stop preview" mouse-2: Stop preview"
grip-port) grip-port)
'mouse-face '(:box 0) 'mouse-face '(:box 0)
'local-map (let ((map (make-sparse-keymap))) 'local-map (let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] (define-key map [mode-line mouse-1]
(lambda () (lambda ()
(interactive) (interactive)
(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)