screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[screen-devel] [PATCH 2/3] screen: Introduce windows command


From: Thomas Renninger
Subject: [screen-devel] [PATCH 2/3] screen: Introduce windows command
Date: Tue, 12 Feb 2013 00:07:54 +0100

This new command is doing nearly the same as the windows
command.
But a string escape can be passed which makes it 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 <address@hidden>
Signed-off-by: Thomas Renninger <Thomas Renninger" address@hidden>
---
 src/comm.c             |    2 +-
 src/doc/screen.1       |    5 ++++-
 src/doc/screen.texinfo |    7 ++++++-
 src/process.c          |   35 ++++++++++++++++++++++++++++++++++-
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/comm.c b/src/comm.c
index 8722ca8..b8b535f 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -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 },
diff --git a/src/doc/screen.1 b/src/doc/screen.1
index 4e72f8b..7a0c1de 100644
--- a/src/doc/screen.1
+++ b/src/doc/screen.1
@@ -3430,7 +3430,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
@@ -3446,6 +3446,9 @@ windows occupied by other users are marked with `&';
 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 ]
diff --git a/src/doc/screen.texinfo b/src/doc/screen.texinfo
index e564abe..e7a693d 100644
--- a/src/doc/screen.texinfo
+++ b/src/doc/screen.texinfo
@@ -2613,7 +2613,7 @@ before displaying a message. Default is 30 seconds.
 @section Windows
 @kindex w
 @kindex C-w
address@hidden Command windows
address@hidden 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
@@ -2632,6 +2632,11 @@ windows in the zombie state are marked with @samp{Z}.
 
 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
diff --git a/src/process.c b/src/process.c
index 7370924..79e82b5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1838,7 +1838,12 @@ int key;
       Activate(-1);
       break;
     case RC_WINDOWS:
-      ShowWindows(-1);
+      if (args[0]) {
+       s = SaveStr(args[0]);
+       ShowWindowsX(s);
+      }
+      else
+       ShowWindows(-1);
       break;
     case RC_VERSION:
       OutputMsg(0, "screen %s", version);
@@ -5605,6 +5610,34 @@ struct win *p;
   return s;
 }
 
+/*
+ * String Escape based windows listing
+ * Unfortunately it is not possible to rebuild the exact
+ * output (flags) from ShowWindows() with a default
+ * string escape. But when there should be a new screen
+ * version where slight output changes get accepted,
+ * ShowWindowsX() should replace the rather static
+ * (in output and size) old ShowWindows() and AddWindows()
+ * functions
+ */
+void
+ShowWindowsX(char *string)
+{
+  int i;
+  char *s = "";
+
+  debug1("ShowWindowsX: string [%s]", string);
+
+  for (i = 0; i < maxwin ; i++)
+    {
+      if (wtab[i] == NULL)
+       continue;
+
+      s = MakeWinMsg(string, wtab[i], '%');
+      Msg(0, "%s", s);
+    }
+}
+
 void
 ShowWindows(where)
 int where;
-- 
1.7.6.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]