stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] [PATCH] Add fmt-head-window-list variant that colors "hidden" wi


From: John Li
Subject: [STUMP] [PATCH] Add fmt-head-window-list variant that colors "hidden" windows.
Date: Wed, 16 Jul 2008 23:24:18 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

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.
---

Here's a screenshot:
http://circularly.org/tmp/ml.png

I personally really like this. I can quickly tell which windows I have
open that aren't visible in any frame (Firefox and ncmpc) - I know
that when I do pull-hidden-* commands, I'll select a colored
window. Oh, and it's pretty.

This patch is just to show what it does. If people like it, it could
replace the current fmt-head-window-list. If you *don't* want the
coloring, you can set *hidden-window-color* to "".

One question: does "hidden window" have another meaning? I can't think
of a better term. "Non-top window" is clunky and "invisible window" is
weird.

 mode-line.lisp |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/mode-line.lisp b/mode-line.lisp
index 9f8e940..a6c6cfe 100644
--- a/mode-line.lisp
+++ b/mode-line.lisp
@@ -27,6 +27,7 @@
          *mode-line-pad-y*
          *mode-line-position*
          *mode-line-timeout*
+          *hidden-window-color*
          *screen-mode-line-format*
          enable-mode-line
          toggle-mode-line))
@@ -67,6 +68,11 @@
 (defvar *mode-line-border-color* "Gray30"
   "The mode line border color.")
 
+(defvar *hidden-window-color* "^5*"
+  "Color command for hidden windows when using the
+fmt-head-window-list2 formatter. To disable coloring hidden windows,
+set this to an empty string.")
+
 (defvar *screen-mode-line-format* "[^B%n^b] %W"
   "This variable describes what will be displayed on the modeline for each 
screen.
 Turn it on with the function TOGGLE-MODE-LINE or the mode-line command.
@@ -101,7 +107,8 @@ List the groups using @var{*group-format*}
                                         (#\h fmt-head)
                                         (#\n fmt-group)
                                         (#\W fmt-head-window-list)
-                                        (#\u fmt-urgent-window-list))
+                                        (#\u fmt-urgent-window-list)
+                                        (#\v fmt-head-window-list2))
   "An alist containing format character format function pairs for
 formatting screen mode-lines. functions are passed the screen's
 current group.")
@@ -174,6 +181,27 @@ timer.")
                   (sort1 (head-windows (mode-line-current-group ml) 
(mode-line-head ml))
                          #'< :key #'window-number))))
 
+(defun fmt-hidden (s)
+  (format nil (concat "^[" *hidden-window-color* "~A^]") s))
+
+(defun fmt-head-window-list2 (ml)
+  "Using *window-format*, return a 1 line list of the windows, space
+separated. The currently focused window is highlighted with
+fmt-highlight. Any non-visible windows are "
+  (let* ((group (mode-line-current-group ml))
+         (head (mode-line-head ml))
+         (all-wins (head-windows group head))
+         (top-wins (mapcar 'frame-window (head-frames group head)))
+         (non-top-wins (set-difference all-wins top-wins)))
+    (format nil "~{~a~^ ~}"
+            (mapcar (lambda (w)
+                      (let ((str (format-expand *window-formatters*
+                                                *window-format* w)))
+                        (cond ((eq w (current-window)) (fmt-highlight str))
+                              ((find w non-top-wins) (fmt-hidden str))
+                              (t str))))
+                    (sort1 all-wins #'< :key #'window-number)))))
+
 (defvar *bar-med-color* "^B")
 (defvar *bar-hi-color* "^B^3*")
 (defvar *bar-crit-color* "^B^1*")
-- 
1.5.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]