You are not logged in.

#1 2011-12-02 01:08:20

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

[screen patch] Bold titles for inactive windows

With this patch it's possible to get bold titles for inactive windows by adding a 'T'-flag to the 'w'- or 'W'-escape in the hardstatus string. The 'T'-flag must be used after existing flags (-/+/L).

The path is made to be applied after existing one's in the current screen package. Simply download the source files for the screen Arch package from:
http://projects.archlinux.org/svntogit/ … ges/screen
Add this patch to the same directory, edit PKGBUILD to include the patch and the md5sum. Then makepkg and pacman -U the resulting XZ-package.

Without T-flag:
screen without T-flag

With T-flag:
screen with T-flag

Example hardstatus string:

hardstatus alwayslastline '%{= kg} %-LTw%{w}%n*%f %{+b}%t%{-}%{-}%+LTw%<%-=%{g} @ %{+b}%H%{-}, %{+b}%0c:%s%{-} '

Patch:

diff -Naur original/screen-4.0.3/screen.c screen-4.0.3/screen.c
--- original/screen-4.0.3/screen.c  2011-11-30 04:37:28.000000000 +0100
+++ screen-4.0.3/screen.c   2011-11-30 05:02:51.000000000 +0100
@@ -2025,11 +2025,11 @@
 static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
 #endif

-static char winmsg_buf[MAXSTR];
+char winmsg_buf[MAXSTR];
 #define MAX_WINMSG_REND 256    /* rendition changes */
-static int winmsg_rend[MAX_WINMSG_REND];
-static int winmsg_rendpos[MAX_WINMSG_REND];
-static int winmsg_numrend;
+int winmsg_rend[MAX_WINMSG_REND];
+int winmsg_rendpos[MAX_WINMSG_REND];
+int winmsg_numrend;

 static char *
 pad_expand(buf, p, numpad, padlen)
@@ -2294,6 +2294,7 @@
   int longflg;
   int minusflg;
   int plusflg;
+  int btitlesflg;
   int qmflag = 0, omflag = 0, qmnumrend = 0;
   char *qmpos = 0;
   int numpad = 0;
@@ -2356,6 +2357,8 @@
    num = num * 10 + (*s++ - '0');
       if ((longflg = *s == 'L') != 0)
    s++;
+      if ((btitlesflg = *s == 'T') != 0)
+   s++;
       switch (*s)
    {
         case '?':
@@ -2528,7 +2531,7 @@
        oldfore = D_fore;
        D_fore = win;
          }
-       ss = AddWindows(p, l - 1, (*s == 'w' ? 0 : 1) | (longflg ? 0 : 2) | (plusflg ? 4 : 0), win ? win->w_number : -1);
+       ss = AddWindows(p, l - 1, (*s == 'w' ? 0 : 1) | (longflg ? 0 : 2) | (plusflg ? 4 : 0) | (minusflg ? 8 : 0) | (btitlesflg ? 16 : 0), win ? win->w_number : -1);
        if (minusflg)
           *ss = 0;
        if (display)
diff -Naur original/screen-4.0.3/process.c screen-4.0.3/process.c 
--- original/screen-4.0.3/process.c 2011-11-30 04:37:28.000000000 +0100
+++ screen-4.0.3/process.c  2011-11-30 04:58:32.000000000 +0100
@@ -4742,6 +4742,12 @@
 int flags;
 int where;
 {
+  // MA: alt. pass (strlen(winmsg_buf) - strlen(p)) as buf offset
+  extern char winmsg_buf[];
+  // MA: could / should we use ApplyAttrColor() / SetRendition() instead?
+  extern int winmsg_rend[];
+  extern int winmsg_rendpos[];
+  extern int winmsg_numrend;
   register char *s, *ss;
   register struct win **pp, *p;
   register char *cmd;
@@ -4781,6 +4787,16 @@
           s = AddWindowFlags(s, len, p);
    }
       *s++ = ' ';
+      if (flags & 16 && ((!(flags & 8)) ? : p->w_number < where))
+    {
+          // MA: feels safe atm, but winmsg_rendpos[] must be in asc. order
+          winmsg_rend[winmsg_numrend] = 1024; // %{+b}
+          winmsg_rendpos[winmsg_numrend] = strlen(winmsg_buf) - strlen(s);
+          winmsg_numrend++;
+          winmsg_rend[winmsg_numrend] = -1; // %{-}
+          winmsg_rendpos[winmsg_numrend] = l + strlen(winmsg_buf) - strlen(s);
+          winmsg_numrend++;
+    }
       strncpy(s, cmd, l);
       s += l;
     }

Notes:
If makepkg complains, try edit the path like this:
#define MAX_WINMSG_REND 256[TAB HERE]/* rendition changes */

Last edited by Pingwinski (2011-12-02 01:20:02)

Offline

#2 2011-12-02 15:10:41

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: [screen patch] Bold titles for inactive windows

An alternative is to try tmux.

Offline

#3 2011-12-04 22:52:33

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

Re: [screen patch] Bold titles for inactive windows

Truly seems like the sane thing do to, thanks!

Offline

Board footer

Powered by FluxBB