new mode line theme - finish the face part
authorPeng Li <seudut@gmail.com>
Sat, 9 Sep 2017 00:10:09 +0000 (08:10 +0800)
committerPeng Li <seudut@gmail.com>
Sat, 9 Sep 2017 00:10:09 +0000 (08:10 +0800)
emacs.d/my-mode-line.el

index 095b415..639fe0e 100644 (file)
 
 ;;; Code:
 
+;; A windows may have six kinds different mode-line
+;; type = 1.
+;;   -----------------------------
+;;   |>>>         O           <<<| 
+;;   -----------------------------
+
 (defun my-get-window-type ()
   "According to the window layout, separate the windows as six types.
 Each type will have different mode line. This function return the defined
@@ -51,7 +57,7 @@ window type."
        (t
         4)))
 
-
+(my-get-window-type)
 (defun sd/powerline-center-theme_revised-2 ()
   "Setup a mode-line with major and minor modes centered."
   (interactive)
@@ -59,18 +65,16 @@ window type."
                 '("%e"
                   (:eval
                    (let* ((window-type (my-get-window-type))
-                         ;; (active (powerline-selected-window-active))
-                         (active t)
-                          ;; (mode-line-buffer-id (if active 'sd/mode-line-buffer-id 'mode-line-buffer-id-inactive))
-                          (mode-line-buffer-id (if active 'sd/mode-line-buffer-id 'powerline-inactive1))
-                          (mode-line (if active 'mode-line 'mode-line-inactive))
-                          (my-face1 (if active 'sd/powerline-active1 'powerline-inactive1))
-                          (my-face-buffer-modified (if (and (sd/buffer-is-eshel-or-scratch) (buffer-modified-p) (not buffer-read-only)) 
-                                                       'sd/buffer-modified-active1
-                                                     (if buffer-read-only 'sd/buffer-view-active1
-                                                       my-face1)))
-                          (face1 (if active 'powerline-active1 'powerline-inactive1))
-                          (face2 (if active 'powerline-active2 'powerline-inactive2))
+                         (active (powerline-selected-window-active))
+                         ;; (active t)
+                          ;; (my-face1 (if active 'sd/powerline-active1 'powerline-inactive1))
+                         (my-face1 'sd/powerline-active1 )
+                          ;; (my-face-buffer-modified (if (and (sd/buffer-is-eshel-or-scratch) (buffer-modified-p) (not buffer-read-only)) 
+                          ;;                              'sd/buffer-modified-active1
+                          ;;                            (if buffer-read-only 'sd/buffer-view-active1
+                          ;;                              my-face1)))
+                          (face1 'powerline-active1)
+                          (face2 'powerline-active2)
                           (separator-left (intern (format "powerline-%s-%s"
                                                           (powerline-current-separator)
                                                           (car powerline-default-separator-dir))))
@@ -78,21 +82,39 @@ window type."
                                                            (powerline-current-separator)
                                                            (cdr powerline-default-separator-dir))))
                           (lhs (if (or (= window-type 1) (= window-type 2) (= window-type 3) (= window-type 6))
-                                  (list (powerline-raw "%* " my-face-buffer-modified 'l)
-                                        (powerline-raw " " my-face1)
-                                        (funcall separator-left my-face1 face1)
-                                        (powerline-narrow face1 'l)
-                                        (sd/powerline-simpler-vc (powerline-vc face1)))
+                                  (let ((lface))
+                                    (if (or (= window-type 1) (= window-type 2))
+                                        (setq lface my-face1)
+                                      (if active
+                                          (setq lface my-face1)
+                                        (setq lface face2)))
+                                    (list (powerline-raw "%* " lface 'l)
+                                          ;; (powerline-raw "%* " my-face-buffer-modified 'l)
+                                          (powerline-raw " " lface)
+                                          (funcall separator-left lface face1)
+                                          (powerline-narrow face1 'l)
+                                          ;; (sd/powerline-simpler-vc (powerline-vc face1))
+                                          ))
                                 nil))
                           (center (if (or (= window-type 1) (= window-type 4))
-                                     (list (powerline-raw " " face1)
-                                           (funcall separator-right face1 face2)
-                                           (powerline-raw (concat " ==" (number-to-string (my-get-window-type)) "== ") face2)
-                                           (funcall separator-left face2 face1))
+                                     (let ((cface))
+                                       (if active
+                                           (setq cface my-face1)
+                                         (setq cface face2))
+                                       (list (powerline-raw " " face1)
+                                             (funcall separator-right face1 cface)
+                                             (powerline-raw (concat " ==" (number-to-string (my-get-window-type)) "== ") cface)
+                                             (funcall separator-left cface face1)))
                                    nil))
                           (rhs (if (or (= window-type 1) (= window-type 3) (= window-type 2) (= window-type 5))
-                                  (list (funcall separator-right face1 my-face1)
-                                   (powerline-raw (format-time-string " %I:%M %p  ") my-face1 'r))
+                                  (let ((rface))
+                                    (if (or (= window-type 1) (= window-type 3))
+                                        (setq rface my-face1)
+                                      (if active
+                                          (setq rface my-face1)
+                                        (setq rface face2)))
+                                    (list (funcall separator-right face1 rface)
+                                          (powerline-raw (format-time-string " %I:%M %p  ") rface 'r)))
                                 nil)))
                      (concat (powerline-render lhs)
                              (powerline-fill-center face1 (/ (powerline-width center) 2.0))