Added macro do-list-with-interspersed-element

This commit is contained in:
Nathan Shostek 2022-01-28 14:19:37 +01:00
parent baee1b9fd7
commit 06130c017d
2 changed files with 27 additions and 28 deletions

View file

@ -1,5 +1,18 @@
(in-package #:clim-mode-line)
(defmacro do-list-with-interspersed-element
((var list &body interspersed-forms) &body body)
(alexandria:with-gensyms (initial rest hold cont tmp)
`(flet ((,cont (,var)
,@body))
(let* ((,hold ,list)
(,initial (car ,hold))
(,rest (cdr ,hold)))
(,cont ,initial)
(dolist (,tmp ,rest)
,@interspersed-forms
(,cont ,tmp))))))
(defvar *stumpwm-modeline-frame* nil
"Hold the single mode line")
@ -46,6 +59,9 @@
(stumpwm::screen-groups
(stumpwm:current-screen))))))))
(defun mode-line-format ()
(mode-line-formatters *stumpwm-modeline-frame*))
(defun set-mode-line-format (list)
(setf (mode-line-formatters *stumpwm-modeline-frame*) list))

View file

@ -166,39 +166,22 @@ called within a table, invoke CONTINUATION within a cell."
(declare (dynamic-extent (function ,cont)))
(invoke-with-formatting ,pane #',cont))))
(defun format-groups (frame pane other-formatters)
(declare (ignorable frame))
(let* ((current-group (stumpwm:current-group))
(groups (stumpwm::sort-groups (stumpwm:current-screen)))
(g1 (car groups)))
(with-stumpwm-highlighting (pane (eq current-group g1))
(present g1 'stumpwm::group :stream pane :single-box t))
(dolist (group (cdr groups))
(format pane " ")
(let ((current-group (stumpwm:current-group)))
(do-list-with-interspersed-element
(group (stumpwm::sort-groups (stumpwm:current-screen))
(format pane " "))
(with-stumpwm-highlighting (pane (eq current-group group))
(present group 'stumpwm::group :stream pane :single-box t))))
(call-next-formatter other-formatters frame pane))
(defun format-windows (frame pane other-formatters)
(let* ((current-window (stumpwm:current-window))
(windows (stumpwm::sort-windows-by-number
(stumpwm:group-windows (stumpwm:current-group))))
(w1 (car windows)))
(when windows
(with-normal-stumpwm-highlighting (pane (eq current-window w1))
(present w1 'stumpwm::window :stream pane :single-box t))
(dolist (win (cdr windows))
(format pane " ")
(with-normal-stumpwm-highlighting (pane (eq current-window win))
(present win 'stumpwm::window :stream pane :single-box t)))))
(let ((current-window (stumpwm:current-window)))
(do-list-with-interspersed-element
(win (stumpwm::sort-windows-by-number
(stumpwm:group-windows (stumpwm:current-group)))
(format pane " "))
(with-normal-stumpwm-highlighting (pane (eq current-window win))
(present win 'stumpwm::window :stream pane :single-box t))))
(call-next-formatter other-formatters frame pane))
;; (defun format-windows-tableless (frame pane other-formatters)
;; (with-right-alignment (frame pane)
;; (dolist (win (stumpwm::sort-windows-by-number
;; (stumpwm:group-windows (stumpwm:current-group))))
;; (with-stumpwm-highlighting (pane (eq current-window win))
;; (present win 'stumpwm::window :stream pane :single-box t)))
;; (call-next-formatter other-formatters frame pane)))