[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[screen-devel] screen +hide patch
From: |
Ben Kibbey |
Subject: |
[screen-devel] screen +hide patch |
Date: |
Mon, 27 Feb 2006 09:34:13 -0500 |
hello,
Here's a patch to enable window "hiding". It adds a command 'hide' which
will toggle hiding of the current or specified window. When hidden a
window won't be considered with the next, prev or other commands.
--
Benjamin J. Kibbey bjk/freenode/@luxsci.net
3019 F5FC AA33 5BC7 BE9F 09D2 393E DBD2 40D5 FA7E
Index: comm.c
===================================================================
RCS file: /sources/screen/screen/src/comm.c,v
retrieving revision 1.21
diff -u -r1.21 comm.c
--- comm.c 16 Dec 2005 19:06:39 -0000 1.21
+++ comm.c 26 Feb 2006 19:23:15 -0000
@@ -190,6 +190,7 @@
{ "hardstatus", ARGS_012 },
{ "height", ARGS_0123 },
{ "help", NEED_LAYER|ARGS_02 },
+ { "hide", NEED_FORE|ARGS_01 },
#ifdef COPY_PASTE
{ "history", NEED_DISPLAY|NEED_FORE|ARGS_0 },
#endif
Index: comm.h.dist
===================================================================
RCS file: /sources/screen/screen/src/comm.h.dist,v
retrieving revision 1.11
diff -u -r1.11 comm.h.dist
--- comm.h.dist 16 Dec 2005 18:44:47 -0000 1.11
+++ comm.h.dist 26 Feb 2006 19:23:15 -0000
@@ -223,5 +223,6 @@
#define RC_XON 172
#define RC_ZMODEM 173
#define RC_ZOMBIE 174
+#define RC_HIDE 175
-#define RC_LAST 174
+#define RC_LAST 175
Index: process.c
===================================================================
RCS file: /sources/screen/screen/src/process.c,v
retrieving revision 1.22
diff -u -r1.22 process.c
--- process.c 19 Dec 2005 16:13:08 -0000 1.22
+++ process.c 26 Feb 2006 19:23:23 -0000
@@ -1025,6 +1025,49 @@
return i;
}
+void
+HideWindow(p)
+struct win *p;
+{
+ int q;
+ int n = p ? p->w_number : -1;
+ struct win **pp;
+
+ if (!p)
+ {
+ ShowWindows(-1);
+ return;
+ }
+
+ // Valid window?
+ for (q = -1, pp = wtab; pp != wtab + MAXWIN; pp++)
+ {
+ struct win *w = *pp;
+
+ if (w && w->w_number == n)
+ {
+ q = n;
+ break;
+ }
+ }
+ n = q;
+ if (n < 0 || n >= MAXWIN)
+ {
+ ShowWindows(-1);
+ return;
+ }
+ if (p->w_hide)
+ {
+ p->w_hide = 0;
+ Msg(0, "Window %d (%s) unhidden", p->w_number, p->w_title);
+ }
+ else
+ {
+ p->w_hide = 1;
+ Msg(0, "Window %d (%s) is now hidden", p->w_number, p->w_title);
+ }
+}
+
/*ARGSUSED*/
void
DoAction(act, key)
@@ -1080,6 +1123,20 @@
msgok = display && !*rc_name;
switch(nr)
{
+ case RC_HIDE:
+ if (!*args || (args[0][0] == '.' && !args[0][1]))
+ {
+ if (!fore)
+ {
+ Msg(0, "hide . needs a window");
+ break;
+ }
+ n = fore->w_number;
+ }
+ else if (ParseWinNum(act, &n) < 0)
+ break;
+ HideWindow(wtab[n]);
+ break;
case RC_SELECT:
if (!*args)
InputSelect();
@@ -1706,7 +1763,7 @@
/* FALLTHROUGH */
case RC_OTHER:
if (MoreWindows())
- SwitchWindow(display && D_other ? D_other->w_number : NextWindow());
+ SwitchWindow(display && D_other && !D_other->w_hide ? D_other->w_number
: NextWindow());
break;
case RC_META:
if (user->u_Esc == -1)
@@ -4656,8 +4713,13 @@
for (pp = wtab + n + 1; pp != wtab + n; pp++)
{
+ struct win *p;
+
if (pp == wtab + MAXWIN)
pp = wtab;
+ p = *pp;
+ if (p && p->w_hide)
+ continue;
if (*pp)
break;
}
@@ -4672,8 +4734,13 @@
for (pp = wtab + n - 1; pp != wtab + n; pp--)
{
+ struct win *p;
+
if (pp < wtab)
pp = wtab + MAXWIN - 1;
+ p = *pp;
+ if (p && p->w_hide)
+ continue;
if (*pp)
break;
}
@@ -4684,8 +4751,15 @@
MoreWindows()
{
char *m = "No other window.";
- if (windows && (fore == 0 || windows->w_next))
- return 1;
+ struct win **pp, *p;
+ int n = fore ? fore->w_number : -1;
+
+ for (pp = wtab; pp != wtab + MAXWIN; pp++) {
+ p = *pp;
+ if (fore && windows && p && p->w_number != n && p->w_hide == 0)
+ return 1;
+ }
+
if (fore == 0)
{
Msg(0, "No window available");
@@ -4805,6 +4879,10 @@
continue;
if ((flags & 1) && display && p == D_fore)
continue;
+ /*
+ if (p->w_hide)
+ continue;
+ */
cmd = p->w_title;
l = strlen(cmd);
@@ -4861,6 +4939,8 @@
*s++ = '@';
if (p->w_bell == BELL_DONE)
*s++ = '!';
+ if (p->w_hide)
+ *s++ = '^';
#ifdef UTMPOK
if (p->w_slot != (slot_t) 0 && p->w_slot != (slot_t) -1)
*s++ = '$';
Index: window.h
===================================================================
RCS file: /sources/screen/screen/src/window.h,v
retrieving revision 1.22
diff -u -r1.22 window.h
--- window.h 16 Dec 2005 19:06:39 -0000 1.22
+++ window.h 26 Feb 2006 19:23:24 -0000
@@ -185,6 +185,7 @@
int w_SavedCharsetR;
int w_SavedCharsets[4];
#endif
+ int w_hide;
int w_top, w_bot; /* scrollregion */
int w_wrap; /* autowrap */
int w_origin; /* origin mode */
Index: doc/screen.1
===================================================================
RCS file: /sources/screen/screen/src/doc/screen.1,v
retrieving revision 1.22
diff -u -r1.22 screen.1
--- doc/screen.1 20 Dec 2005 18:46:23 -0000 1.22
+++ doc/screen.1 26 Feb 2006 19:23:32 -0000
@@ -1966,6 +1966,12 @@
See also \*QDEFAULT KEY BINDINGS\*U section.
.sp
.ne 3
+.B hide [WindowID]
+.PP
+Toggles hiding of the specified window. If no window is specified the current
+window will be toggled.
+.sp
+.ne 3
.B history
.PP
Usually users work with a shell that allows easy access to previous commands.
@@ -3027,6 +3033,7 @@
is marked with an `@';
a window which has output logging turned on is marked with `(L)';
windows occupied by other users are marked with `&';
+hidden windows 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.
Index: doc/screen.texinfo
===================================================================
RCS file: /sources/screen/screen/src/doc/screen.texinfo,v
retrieving revision 1.18
diff -u -r1.18 screen.texinfo
--- doc/screen.texinfo 20 Dec 2005 18:46:23 -0000 1.18
+++ doc/screen.texinfo 26 Feb 2006 19:23:43 -0000
@@ -975,6 +975,8 @@
Set display height. @xref{Window Size}.
@item help [-c @var{class}]
Display current key bindings. @xref{Help}.
address@hidden hide address@hidden
+Toggle hiding of a window.
@item history
Find previous command beginning @dots{}. @xref{History}.
@item hstatus @var{status}
@@ -1413,7 +1415,7 @@
@kindex C-n
@deffn Command next
(@kbd{C-a @key{SPC}}, @kbd{C-a n}, @kbd{C-a C-n})@*
-Switch to the next window. This command can be used repeatedly to
+Switch to the next unhidden window. This command can be used repeatedly to
cycle through the list of windows. (On some terminals, address@hidden
generates a NUL character, so you must release the control key before
pressing space.)
@@ -1423,7 +1425,7 @@
@kindex C-p
@deffn Command prev
(@kbd{C-a p}, @kbd{C-a C-p})@*
-Switch to the previous window (the opposite of @kbd{C-a n}).
+Switch to the previous unhidden window (the opposite of @kbd{C-a n}).
@end deffn
@node Other Window, Select, Next and Previous, Selecting
@@ -1431,7 +1433,7 @@
@kindex C-a
@deffn Command other
(@kbd{C-a C-a})@*
-Switch to the last window displayed. Note that this command
+Switch to the last unhidden window displayed. Note that this command
defaults to the command character typed twice, unless overridden.
For instance, if you use the option @samp{-e]x},
this command becomes @kbd{]]} (@pxref{Command Character}).
@@ -2187,6 +2189,7 @@
a window which has output logging turned on is marked with @samp{(L)};
windows occupied by other users are marked with @samp{&}
or @samp{&&} if the window is shared by other users;
+hidden windows are marked with @samp{^};
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
@@ -4325,6 +4328,7 @@
* Nethack:: Use @code{nethack}-like error messages.
* Nonblock:: Disable flow-control to a display.
* Number:: Change the current window's number.
+* Hide:: Toggle a windows hidden status.
* Silence:: Notify on inactivity.
* Time:: Display the time and load average.
* Verbose:: Display window creation commands.
@@ -4468,7 +4472,7 @@
displays is changed. Initial setting is @code{off}.
@end deffn
address@hidden Number, Silence, Nonblock, Miscellaneous
address@hidden Number, Hide, Nonblock, Miscellaneous
@section Number
@kindex N
@deffn Command number address@hidden
@@ -4478,7 +4482,17 @@
specified, the current window number (and title) is shown.
@end deffn
address@hidden Silence, Time, Number, Miscellaneous
address@hidden Hide, Silence, Number, Miscellaneous
address@hidden Hide
address@hidden Command hide address@hidden
+(none)@*
+Toggles hiding of the specified window @xref{Selecting}. If no window is
+specified then the current window will be toggled. When a window is hidden the
+commands @code{next}, @code{prev} and @code{other} will skip the window and
+the window will have a status flag of @samp{^}.
address@hidden deffn
+
address@hidden Silence, Time, Hide, Miscellaneous
@section Silence
@deffn Command silence address@hidden|@var{sec}]
(none)@*
screen-cvs+hide.diff
Description: Text document
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [screen-devel] screen +hide patch,
Ben Kibbey <=