summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authored@s5h.net <ed@s5h.net>2020-01-20 18:24:05 +0000
committerAmadeusz Sławiński <amade@asmblr.net>2020-02-03 23:42:14 +0100
commiteb38c84a676a5e6a8d628fa7584ed5c78405de06 (patch)
tree6547bfb2d8d53fc272d59aaabaf3dd938076b123
parentc2d797a3792a6e9ee4276600cc00f22e121bc8e2 (diff)
downloadscreen-eb38c84a676a5e6a8d628fa7584ed5c78405de06.tar.gz
Add escape to show number of currently open windows in hardstatus
String escape format of %C for number of windows with - prefix for group window count. Bug: 14484 Signed-off-by: Ed Neville <ed@s5h.net>
-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',