File screen_enhance_windows_list.patch of Package screen

screen: Introduce argument to windows command

A string escape can be passed which makes the windows command
much more flexible. The default string escape if no argument
is passed is "%n%f %t " which is intended to rebuild
the same output the windows command would give as good
as possible (slight changes with the flags can happen).

This command is also not be limited in output size
(the windows command is limited to 1024 bytes).

The windowsx command can be queried (-Q command) and
this is its main purpose (be able to query the exact
window list status of an active screen session from
shell).

Signed-off-by: Thomas Renninger <trenn@suse.de>

--- ./comm.c.orig	2013-09-13 13:37:01.440278153 +0000
+++ ./comm.c	2013-09-13 13:37:21.830278117 +0000
@@ -328,7 +328,7 @@ struct comm comms[RC_LAST + 1] =
   { "wall",		NEED_DISPLAY|ARGS_1},
   { "width",		ARGS_0123 },
   { "windowlist",	ARGS_012 },
-  { "windows",		CAN_QUERY|ARGS_0 },
+  { "windows",		CAN_QUERY|ARGS_01 },
   { "wrap",		NEED_FORE|ARGS_01 },
 #ifdef COPY_PASTE
   { "writebuf",		ARGS_0123 },
--- ./doc/screen.1.orig	2013-09-13 13:39:15.327277916 +0000
+++ ./doc/screen.1	2013-09-13 13:38:46.391277967 +0000
@@ -3435,7 +3435,7 @@ settings).
 and 6 characters high in order to display.
 .sp
 .ne 3
-.B windows
+.B windows [ string ]
 .PP
 Uses the message line to display a list of all the windows.
 Each window is listed by number with the name of process that has been
@@ -3451,6 +3451,9 @@ windows occupied by other users are mark
 windows in the zombie state are marked with `Z'.
 If this list is too long to fit on the terminal's status line only the
 portion around the current window is displayed.
+The optional string parameter follows the \*QSTRING ESCAPES\*U format.
+If string parameter is passed, the output size is unlimited.
+The default command without any parameter is limited to a size of 1024 bytes.
 .sp
 .ne 3
 .BR "wrap " [ on | off ]
--- ./doc/screen.texinfo.orig	2013-09-13 13:38:53.376277955 +0000
+++ ./doc/screen.texinfo	2013-09-13 13:39:47.392277859 +0000
@@ -2617,7 +2617,7 @@ before displaying a message. Default is
 @section Windows
 @kindex w
 @kindex C-w
-@deffn Command windows
+@deffn Command windows [string]
 (@kbd{C-a w}, @kbd{C-a C-w})@*
 Uses the message line to display a list of all the windows.  Each
 window is listed by number with the name of the program running in the
@@ -2636,6 +2636,11 @@ windows in the zombie state are marked w
 
 If this list is too long to fit on the terminal's status line only the
 portion around the current window is displayed.
+
+You can customize the output format to any string you like including
+string escapes (@pxref{String Escapes}).
+In this case, if the string parameter is passed, the maximum output
+size is unlimited (instead of 1024 bytes if no parameter is passed).
 @end deffn
 
 @node Hardstatus, Mousetrack, Windows, Window Settings
--- ./process.c.orig	2013-09-13 13:39:55.192277845 +0000
+++ ./process.c	2013-09-13 13:53:18.672276423 +0000
@@ -170,6 +170,7 @@ static void ResizeFin __P((char *, int,
 static struct action *FindKtab __P((char *, int));
 static void SelectFin __P((char *, int, char *));
 static void SelectLayoutFin __P((char *, int, char *));
+static void ShowWindowsX __P((char *));
 
 
 extern struct layer *flayer;
@@ -1838,6 +1839,11 @@ int key;
       Activate(-1);
       break;
     case RC_WINDOWS:
+      if (args[0])
+	{
+	  ShowWindowsX(args[0]);
+	  break;
+	}
       ShowWindows(-1);
       break;
     case RC_VERSION:
@@ -5637,6 +5643,25 @@ int where;
   Msg(0, "%s", ss);
 }
 
+/*
+ * String Escape based windows listing
+ * mls: currently does a Msg() call for each(!) window, dunno why
+ */
+static void
+ShowWindowsX(str)
+char *str;
+{
+  int i;
+  debug1("ShowWindowsX: string [%s]", string);
+  for (i = 0; i < maxwin ; i++)
+    {
+      if (!wtab[i])
+	continue;
+      Msg(0, "%s", MakeWinMsg(str, wtab[i], '%'));
+    }
+}
+
+
 static void
 ShowInfo()
 {
openSUSE Build Service is sponsored by