forked from pool/screen
e59f511065
- Add sort command - convert maxwin99bug.patch into a patch format quilt understands OBS-URL: https://build.opensuse.org/request/show/83586 OBS-URL: https://build.opensuse.org/package/show/Base:System/screen?expand=0&rev=22
108 lines
3.0 KiB
Diff
108 lines
3.0 KiB
Diff
screen: Introduce sort command
|
|
|
|
:sort
|
|
will sort all active screen windows ordered by title.
|
|
Limitations:
|
|
- Will only work in overview window (CTRL-a-")
|
|
- For unknown reasons does not always work.
|
|
Encountered on a screen session with about 100 active
|
|
windows and several users active, that the sorting
|
|
does not always take place.
|
|
|
|
Still, this command is very helpful for users who use
|
|
screen sessions with a huge amount of active windows.
|
|
|
|
Might apply with line offset to latest screen sources.
|
|
Got tested intensively with our screen over the last
|
|
years.
|
|
|
|
Please apply.
|
|
|
|
Signed-off-by: Thomas Renninger <trenn@suse.de>
|
|
|
|
comm.c | 1 +
|
|
doc/screen.1 | 5 +++++
|
|
process.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 47 insertions(+)
|
|
|
|
Index: screen-4.0.3/comm.c
|
|
===================================================================
|
|
--- screen-4.0.3.orig/comm.c
|
|
+++ screen-4.0.3/comm.c
|
|
@@ -283,6 +283,7 @@ struct comm comms[RC_LAST + 1] =
|
|
{ "sleep", ARGS_1 },
|
|
{ "slowpaste", NEED_FORE|ARGS_01 },
|
|
{ "sorendition", ARGS_012 },
|
|
+ { "sort", ARGS_0 },
|
|
{ "source", ARGS_1 },
|
|
{ "split", NEED_DISPLAY|ARGS_0 },
|
|
{ "startup_message", ARGS_1 },
|
|
Index: screen-4.0.3/process.c
|
|
===================================================================
|
|
--- screen-4.0.3.orig/process.c
|
|
+++ screen-4.0.3/process.c
|
|
@@ -2794,6 +2794,47 @@ int key;
|
|
WindowChanged((struct win *)0, 0);
|
|
}
|
|
break;
|
|
+ case RC_SORT:
|
|
+ if (fore)
|
|
+ {
|
|
+ /* Better do not allow this. Not sure what the utmp stuff in number
|
|
+ command above is for (you get four entries in e.g. /var/log/wtmp
|
|
+ per number switch). But I don't know enough about this.*/
|
|
+ Msg(0, "Sorting inside a window is not allowed. Push CTRL-a \" "
|
|
+ "and try again\n");
|
|
+ break;
|
|
+ }
|
|
+ i = 0;
|
|
+ if (!wtab[i] || !wtab[i+1])
|
|
+ {
|
|
+ Msg(0, "Less than two windows, sorting makes no sense.\n");
|
|
+ break;
|
|
+ }
|
|
+ for (i = 0; wtab[i+1] != NULL; i++)
|
|
+ {
|
|
+ for (n = i, nr = i; wtab[n+1] != NULL; n++)
|
|
+ {
|
|
+ if (strcmp(wtab[nr]->w_title,wtab[n+1]->w_title) > 0)
|
|
+ {
|
|
+ nr = n+1;
|
|
+ }
|
|
+ }
|
|
+ if (nr != i)
|
|
+ {
|
|
+ debug2("Exchange window %d and %d.\n", i, nr);
|
|
+ p = wtab[nr];
|
|
+ wtab[nr] = wtab[i];
|
|
+ wtab[i] = p;
|
|
+ wtab[nr]->w_number = nr;
|
|
+ wtab[i]->w_number = i;
|
|
+#ifdef MULTIUSER
|
|
+ /* exchange the acls for these windows. */
|
|
+ AclWinSwap(i, nr);
|
|
+#endif
|
|
+ }
|
|
+ }
|
|
+ WindowChanged((struct win *)0, 0);
|
|
+ break;
|
|
case RC_SILENCE:
|
|
n = fore->w_silence != 0;
|
|
i = fore->w_silencewait;
|
|
Index: screen-4.0.3/doc/screen.1
|
|
===================================================================
|
|
--- screen-4.0.3.orig/doc/screen.1
|
|
+++ screen-4.0.3/doc/screen.1
|
|
@@ -2678,6 +2678,11 @@ underlying system exposes flow control p
|
|
text.
|
|
.sp
|
|
.ne 3
|
|
+.B sort
|
|
+.PP
|
|
+Sort the windows in alphabetical order of the window tiles.
|
|
+.sp
|
|
+.ne 3
|
|
.BI "source " file
|
|
.PP
|
|
Read and execute commands from file \fIfile\fP. Source commands may
|