summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Naumov <posix.ru@gmail.com>2015-06-03 14:29:42 +0200
committerAlexander Naumov <posix.ru@gmail.com>2015-06-03 14:29:42 +0200
commita57d750e2a38da6617d13c4949d5bf7c95292ff6 (patch)
treebe417faced494de55ae01032be2e194b2787b53a
parent93fc5a42ad401cc2ef461f7e536b9b72210d6060 (diff)
downloadscreen-a57d750e2a38da6617d13c4949d5bf7c95292ff6.tar.gz
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: Alexander Naumov <alexander_naumov@opensuse.org> Signed-off-by: Thomas Renninger <trenn@suse.de>
-rw-r--r--src/comm.c2
-rw-r--r--src/doc/screen.15
-rw-r--r--src/doc/screen.texinfo7
-rw-r--r--src/process.c23
4 files changed, 34 insertions, 3 deletions
diff --git a/src/comm.c b/src/comm.c
index c63bb1e..abf542c 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -327,7 +327,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 33fe978..77d14f1 100644
--- a/src/doc/screen.1
+++ b/src/doc/screen.1
@@ -3440,7 +3440,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
@@ -3456,6 +3456,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 3dfa721..40ead07 100644
--- a/src/doc/screen.texinfo
+++ b/src/doc/screen.texinfo
@@ -2616,7 +2616,7 @@ before displaying a message. Default is 30 seconds.
@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
@@ -2635,6 +2635,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 662cae8..11f9928 100644
--- a/src/process.c
+++ b/src/process.c
@@ -170,6 +170,7 @@ static void ResizeFin __P((char *, int, char *));
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;
@@ -1840,6 +1841,10 @@ int key;
Activate(-1);
break;
case RC_WINDOWS:
+ if (args[0]) {
+ ShowWindowsX(args[0]);
+ break;
+ }
ShowWindows(-1);
break;
case RC_VERSION:
@@ -5647,6 +5652,24 @@ 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()
{