summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/doc/screen.12
-rw-r--r--src/winmsg.c29
-rw-r--r--src/winmsg.h1
3 files changed, 32 insertions, 0 deletions
diff --git a/src/doc/screen.1 b/src/doc/screen.1
index 67505a9..ecd5632 100644
--- a/src/doc/screen.1
+++ b/src/doc/screen.1
@@ -4054,6 +4054,8 @@ is used instead.
Here is the full list of supported escapes:
.IP %
the escape character itself
+.IP C
+The count of screen windows. Prefix with '-' to limit to current window group.
.IP E
sets %? to true if the escape character has been pressed.
.IP f
diff --git a/src/winmsg.c b/src/winmsg.c
index 9fd1151..53f3261 100644
--- a/src/winmsg.c
+++ b/src/winmsg.c
@@ -420,6 +420,32 @@ winmsg_esc_ex(WinNum, Window *win)
wmc_set(cond);
}
+winmsg_esc_ex(WinCount, Window *win)
+{
+ if (esc->num == 0)
+ esc->num = 1;
+
+ if (!win) {
+ wmbc_printf(wmbc, "%*s", esc->num, esc->num > 1 ? "--" : "-");
+ } else {
+ int count = 0;
+
+ for (Window *w = win; w; w = w->w_prev_mru) {
+ if (esc->flags.minus) {
+ if (w->w_group == win->w_group && w->w_type != W_TYPE_GROUP) {
+ count++;
+ }
+ } else {
+ count++;
+ }
+ }
+
+ wmbc_printf(wmbc, "%*d", esc->num, count);
+ }
+
+ wmc_set(cond);
+}
+
winmsg_esc_ex(WinLogName, Window *win)
{
if (win && win->w_log && win->w_log->fp)
@@ -655,6 +681,9 @@ char *MakeWinMsgEv(WinMsgBuf *winmsg, char *str, Window *win,
case WINESC_WIN_NUM:
WinMsgDoEscEx(WinNum, win);
break;
+ case WINESC_WIN_COUNT:
+ WinMsgDoEscEx(WinCount, win);
+ break;
case WINESC_WIN_LOGNAME:
WinMsgDoEscEx(WinLogName, win);
break;
diff --git a/src/winmsg.h b/src/winmsg.h
index 6979ac2..4841bc9 100644
--- a/src/winmsg.h
+++ b/src/winmsg.h
@@ -51,6 +51,7 @@ typedef enum {
WINESC_FOCUS = 'F',
WINESC_HSTATUS = 'h',
WINESC_HOST = 'H',
+ WINESC_WIN_COUNT = 'C',
WINESC_WIN_NUM = 'n',
WINESC_WIN_LOGNAME = 'N',
WINESC_PID = 'p',