Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe33d99

Browse files
jliShawn
authored andcommitted
Add fmt-head-window-list variant that colors "hidden" windows.
Windows not displayed in any frame get their titles colored with the *hidden-window-color* command, "^5*" (magenta) by default. This can be set to "" for the behavior of fmt-head-window-list.
1 parent a8ea0cf commit fe33d99

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

mode-line.lisp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*mode-line-pad-y*
2828
*mode-line-position*
2929
*mode-line-timeout*
30+
*hidden-window-color*
3031
*screen-mode-line-format*
3132
*screen-mode-line-formatters*
3233
add-screen-mode-line-formatter
@@ -70,6 +71,11 @@
7071
(defvar *mode-line-border-color* "Gray30"
7172
"The mode line border color.")
7273

74+
(defvar *hidden-window-color* "^5*"
75+
"Color command for hidden windows when using the
76+
fmt-head-window-list2 formatter. To disable coloring hidden windows,
77+
set this to an empty string.")
78+
7379
(defvar *screen-mode-line-format* "[^B%n^b] %W"
7480
"This variable describes what will be displayed on the modeline for each screen.
7581
Turn it on with the function TOGGLE-MODE-LINE or the mode-line command.
@@ -105,6 +111,7 @@ List the groups using @var{*group-format*}
105111
(#\n fmt-group)
106112
(#\W fmt-head-window-list)
107113
(#\u fmt-urgent-window-list)
114+
(#\v fmt-head-window-list-hidden-windows)
108115
(#\d fmt-modeline-time))
109116
"An alist containing format character format function pairs for
110117
formatting screen mode-lines. functions are passed the screen's
@@ -184,6 +191,28 @@ timer.")
184191
(sort1 (head-windows (mode-line-current-group ml) (mode-line-head ml))
185192
#'< :key #'window-number))))
186193

194+
(defun fmt-hidden (s)
195+
(format nil (concat "^[" *hidden-window-color* "~A^]") s))
196+
197+
(defun fmt-head-window-list-hidden-windows (ml)
198+
"Using *window-format*, return a 1 line list of the windows, space
199+
separated. The currently focused window is highlighted with
200+
fmt-highlight. Any non-visible windows are colored the
201+
*hidden-window-color*."
202+
(let* ((group (mode-line-current-group ml))
203+
(head (mode-line-head ml))
204+
(all-wins (head-windows group head))
205+
(top-wins (mapcar 'frame-window (head-frames group head)))
206+
(non-top-wins (set-difference all-wins top-wins)))
207+
(format nil "~{~a~^ ~}"
208+
(mapcar (lambda (w)
209+
(let ((str (format-expand *window-formatters*
210+
*window-format* w)))
211+
(cond ((eq w (current-window)) (fmt-highlight str))
212+
((find w non-top-wins) (fmt-hidden str))
213+
(t str))))
214+
(sort1 all-wins #'< :key #'window-number)))))
215+
187216
(defun fmt-modeline-time (ml)
188217
(declare (ignore ml))
189218
(format-expand *time-format-string-alist* *time-modeline-string*))

0 commit comments

Comments
 (0)