[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nano-modeline 5cc2c79 02/25: Change modeline rendering
From: |
ELPA Syncer |
Subject: |
[elpa] externals/nano-modeline 5cc2c79 02/25: Change modeline rendering to use :align-to: property |
Date: |
Thu, 23 Dec 2021 12:57:28 -0500 (EST) |
branch: externals/nano-modeline
commit 5cc2c799b41d506c577cb57c9654c676a967ab72
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Change modeline rendering to use :align-to: property
---
nano-modeline.el | 105 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 57 insertions(+), 48 deletions(-)
diff --git a/nano-modeline.el b/nano-modeline.el
index 47c3d87..86d3df3 100644
--- a/nano-modeline.el
+++ b/nano-modeline.el
@@ -26,7 +26,7 @@
;;; Commentary:
;;
;; Nano modeline is a minor mode that modify the modeline as:
-;; [ status | name (primary) secondary ]
+;; [ prefix | name (primary) secondary ]
;;
;; It can be displayed at the bottom (mode-line) or at the top (header-line)
;; depending on nano-modeline-position custom setting.
@@ -198,54 +198,63 @@ Modeline is composed as:
output))
-(defun nano-modeline-compose (status name primary secondary)
+;; ---------------------------------------------------------------------
+(defun nano-modeline-status ()
+ "Return buffer status, one of 'read-only, 'modified or 'read-write."
+
+ (let ((read-only buffer-read-only)
+ (modified (and buffer-file-name (buffer-modified-p))))
+ (cond (modified 'modified)
+ (read-only 'read-only)
+ (t 'read-write))))
+
+
+(defun nano-modeline-render (prefix name primary secondary &optional status)
"Compose a string with provided information"
- (let* ((char-width (window-font-width nil 'header-line))
- (window (get-buffer-window (current-buffer)))
- (active (eq window nano-modeline--selected-window))
- (space-up +0.20)
- (space-down -0.25)
- (prefix (cond ((string= status "RO")
- (propertize (if (window-dedicated-p)"•RO " " RO ")
- 'face (if active
- 'nano-modeline-active-status-RO
-
'nano-modeline-inactive-status-RO)))
- ((string= status "**")
- (propertize (if (window-dedicated-p)"•** " " ** ")
- 'face (if active
- 'nano-modeline-active-status-**
-
'nano-modeline-inactive-status-**)))
- ((string= status "RW")
- (propertize (if (window-dedicated-p) "•RW " " RW ")
- 'face (if active
'nano-modeline-active-status-RW
-
'nano-modeline-inactive-status-RW)))
- (t (propertize status
- 'face (if active
'nano-modeline-active-status-**
-
'nano-modeline-inactive-status-**)))))
- (left (concat
- (propertize " " 'face (if active 'nano-modeline-active
- 'nano-modeline-inactive)
- 'display `(raise ,space-up))
- (propertize name 'face (if active 'nano-modeline-active-name
- 'nano-modeline-inactive-name))
- (propertize " " 'face (if active 'nano-modeline-active
- 'nano-modeline-inactive)
- 'display `(raise ,space-down))
- (propertize primary 'face (if active
'nano-modeline-active-primary
- 'nano-modeline-inactive-primary))))
- (right (concat secondary " "))
-
- (available-width (- (window-total-width)
- (length prefix) (length left) (length right)
- (/ (window-right-divider-width) char-width)))
- (available-width (max 1 available-width)))
- (concat prefix
- left
- (propertize (make-string available-width ?\ )
- 'face (if active 'nano-modeline-active
- 'nano-modeline-inactive))
- (propertize right 'face (if active 'nano-modeline-active-secondary
- 'nano-modeline-inactive-secondary)))))
+ (let* ((window (get-buffer-window (current-buffer)))
+ (name-max-width (- (window-body-width)
+ 1
+ (length prefix)
+ 1
+ (length primary)
+ 5
+ (length secondary)
+ 1))
+ (name (if (and (stringp name) (> (length name) name-max-width))
+ (format "%s…" (substring name 0 (- name-max-width 1)))
+ name))
+ (status (or status (nano-modeline-status)))
+ (active (eq window nano-modeline--selected-window))
+ (prefix-face (cond ((eq status 'read-only) (if active
+
'nano-modeline-active-status-RO
+
'nano-modeline-inactive-status-RO))
+ ((eq status 'modified) (if active
+
'nano-modeline-active-status-**
+
'nano-modeline-inactive-status-**))
+ ((eq status 'read-write) (if active
+
'nano-modeline-active-status-RW
+
'nano-modeline-inactive-status-RW))
+ ((facep status) status)
+ ((listp status) (if active (car status)
+ (cadr status)))
+ (t (if active 'nano-modeline-active
+ 'nano-modeline-inactive))))
+ (left (concat (if (stringp prefix)
+ (propertize (format " %s " prefix)
+ 'face `(:inherit ,prefix-face)))
+ (propertize " " 'display '(raise +0.100))
+ (propertize name 'face (if active
'nano-modeline-active-name
+ 'nano-modeline-inactive-name))
+ (if (length name) " ")
+ (propertize primary 'face (if active
'nano-modeline-active-primary
+
'nano-modeline-inactive-primary))))
+ (right (concat (propertize secondary 'face (if active
'nano-modeline-active-secondary
+
'nano-modeline-inactive-secondary))
+ (propertize " " 'display '(raise -0.125)))))
+ (concat
+ left
+ (propertize " " 'display `(space :align-to (- right ,(+ (length
secondary) 1))))
+ right)))
;; ---------------------------------------------------------------------
- [elpa] externals/nano-modeline 074c3dc 03/25: Update elfeed mode, (continued)
- [elpa] externals/nano-modeline 074c3dc 03/25: Update elfeed mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a2eccb5 16/25: Update org clock mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline febe3d4 11/25: Updated pdf view mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a13702c 15/25: Update message mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a8e45f3 21/25: Reorganizer mode orders and fix modeline appearance, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a216375 23/25: Merge pull request #17 from hans-d/fix/user-mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline 5d36a40 22/25: Merge branch 'master' into fix/user-mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline ab6af26 25/25: Added the possibility to specify when to use user-modeline., ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline 4a00189 10/25: Updated mu4e mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline 45da816 09/25: Updated term mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline 5cc2c79 02/25: Change modeline rendering to use :align-to: property,
ELPA Syncer <=
- [elpa] externals/nano-modeline f27acdc 06/25: Updated info mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a5b3b13 07/25: Updated org agenda mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline d0ece2b 08/25: Update elfeed mode (post view), ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline 2b60ac2 13/25: Updated help mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline f4d7218 17/25: Updated doc view mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline c3a7af4 18/25: Updated bufters view mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline dfc9dda 19/25: Updated completion mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline a1ba95e 20/25: Updated default mode, ELPA Syncer, 2021/12/23
- [elpa] externals/nano-modeline c8e7aa7 24/25: Bumped version number and updated news, ELPA Syncer, 2021/12/23