Hi,

I have sent this patch to screen-devel already some time ago, but it was not
noticed.

The patch implements the command `lastbell' which hops to the window where the
last bell or monitored activity occured, if any.

        Hannes

-- 
3BD8 AF56 11AF 205C 9DB6  B10F 76F1 0634 71A4 DCA0
diff -Naur screen.orig/src/comm.c screen/src/comm.c
--- screen.orig/src/comm.c	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/comm.c	2007-05-27 11:39:38.000000000 +0200
@@ -203,6 +203,7 @@
   { "kanji",		NEED_FORE|ARGS_12 },
 #endif
   { "kill",		NEED_FORE|ARGS_0 },
+  { "lastbell",	ARGS_0 },
   { "lastmsg",		NEED_DISPLAY|ARGS_0 },
   { "layout",           ARGS_1|ARGS_ORMORE},
   { "license",		NEED_LAYER|ARGS_0 },
diff -Naur screen.orig/src/comm.h.dist screen/src/comm.h.dist
--- screen.orig/src/comm.h.dist	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/comm.h.dist	2007-05-27 11:39:38.000000000 +0200
@@ -223,5 +223,5 @@
 #define RC_XON 172
 #define RC_ZMODEM 173
 #define RC_ZOMBIE 174
-
 #define RC_LAST 174
+#define RC_LASTBELL 175
diff -Naur screen.orig/src/doc/screen.1 screen/src/doc/screen.1
--- screen.orig/src/doc/screen.1	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/doc/screen.1	2007-05-27 11:39:38.000000000 +0200
@@ -489,6 +489,10 @@
 .IP "\fBC-a C-p\fP	(prev)"
 .PD
 Switch to the previous window (opposite of \fBC-a n\fP).
+.IP "\fBC-a T\fP"	(lastbell)
+.PD
+Switch to the last window where bell or monitored activity
+occured. Think of \fIT\fP as in \fItrace\fP.
 .IP "\fBC-a q\fP"
 .PD 0
 .IP "\fBC-a C-q\fP	(xon)"
@@ -2069,6 +2073,12 @@
 escape key or to rebind kill to \*QC-a K\*U.
 .sp
 .ne 3
+.B lastbell
+.PP
+Switch to the last window where either a bell was emitted, or monitored activity
+occured.
+.sp
+.ne 3
 .B lastmsg
 .PP
 Redisplay the last contents of the message/status line.
diff -Naur screen.orig/src/doc/screen.texinfo screen/src/doc/screen.texinfo
--- screen.orig/src/doc/screen.texinfo	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/doc/screen.texinfo	2007-05-27 11:39:38.000000000 +0200
@@ -712,6 +712,12 @@
 (time)@*
 Show the load average and xref.  @xref{Time}.
 
[EMAIL PROTECTED] @kbd{C-a T}
[EMAIL PROTECTED] @kbd{C-a T}
+(lastbell)@*
+Switch to the last window where either a bell was emitted or where
+activity was monitored. @xref{Lastbell}
+
 @item @kbd{C-a v}
 (version)@*
 Display the version and compilation date.  @xref{Version}.
@@ -989,6 +995,8 @@
 Removed, use @code{paste} instead.  @xref{Registers}.
 @item kill
 Destroy the current window.  @xref{Kill}.
[EMAIL PROTECTED] lastbell
+Switch to the active window (bell or monitored activity).
 @item lastmsg
 Redisplay the last message.  @xref{Last Message}.
 @item license
@@ -1404,6 +1412,7 @@
 * Other Window::                Switch back and forth between two windows.
 * Select::                      Switch to a window (and to one after @code{kill}).
 * Windowlist::                  Present a list of all windows for selection.
+* Lastbell::                    Switch to the last active window.
 @end menu
 
 @node Next and Previous, Other Window,  , Selecting
@@ -1458,7 +1467,7 @@
 
 @end deffn
 
[EMAIL PROTECTED] Windowlist, , Select, Selecting
[EMAIL PROTECTED] Windowlist, Lastbell, Select, Selecting
 @section Windowlist
 @kindex "
 @deffn Command windowlist [-b] [-m]
@@ -1484,6 +1493,17 @@
 
 @end deffn
 
[EMAIL PROTECTED] Lastbell, , Windowlist, Selecting
[EMAIL PROTECTED] Lastbell
[EMAIL PROTECTED] T
[EMAIL PROTECTED] Command lastbell
+(@kbd{C-a T})@*
+Switch to the last window where a bell (@pxref{Bell}) occured, or to the
+last monitored window (@pxref{Monitor}) that had activity, whichever event
+is more recent.
+
[EMAIL PROTECTED] deffn
+
 @node Session Management, Regions, Selecting, Top
 @chapter Session Management Commands
 
diff -Naur screen.orig/src/process.c screen/src/process.c
--- screen.orig/src/process.c	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/process.c	2007-05-27 11:39:38.000000000 +0200
@@ -175,6 +175,8 @@
 
 struct win *wtab[MAXWIN];	/* window table, should be dynamic */
 
+extern struct win *lastbell;
+
 #ifdef MULTIUSER
 extern char *multi;
 extern int maxusercount;
@@ -486,6 +488,7 @@
     ktab['n'].nr = ktab[Ctrl('n')].nr = RC_NEXT;
   ktab['N'].nr = RC_NUMBER;
   ktab[Ctrl('h')].nr = ktab[0177].nr = ktab['p'].nr = ktab[Ctrl('p')].nr = RC_PREV;
+  ktab['T'].nr = RC_LASTBELL;
   ktab['k'].nr = ktab[Ctrl('k')].nr = RC_KILL;
   ktab['l'].nr = ktab[Ctrl('l')].nr = RC_REDISPLAY;
   ktab['w'].nr = ktab[Ctrl('w')].nr = RC_WINDOWS;
@@ -1199,6 +1202,15 @@
       if (MoreWindows())
 	SwitchWindow(PreviousWindow());
       break;
+    case RC_LASTBELL:
+      if (lastbell)
+        {
+	  SwitchWindow(lastbell->w_number);
+	  lastbell = NULL;
+	}
+      else
+        Msg(0, "No bell recently.");
+      break;
     case RC_KILL:
       {
 	char *name;
diff -Naur screen.orig/src/screen.c screen/src/screen.c
--- screen.orig/src/screen.c	2007-05-27 11:39:24.000000000 +0200
+++ screen/src/screen.c	2007-05-27 11:39:38.000000000 +0200
@@ -234,7 +234,7 @@
 struct win *windows;
 struct win *console_window;
 
-
+struct win *lastbell;
 
 /*
  * Do this last
@@ -3031,6 +3031,9 @@
 	  if (p->w_monitor == MON_FOUND)
 	    p->w_monitor = MON_DONE;
           WindowChanged(p, 'f');
+
+	  /* save the window for `lastbell' */
+	  lastbell = p;
 	}
       if (p->w_monitor == MON_FOUND)
 	{
@@ -3051,6 +3054,9 @@
 	      p->w_monitor = MON_DONE;
 	    }
           WindowChanged(p, 'f');
+	  
+	  /* save the window for `lastbell' */
+	  lastbell = p;
 	}
     }
 

Attachment: signature.asc
Description: Digital signature

_______________________________________________
screen-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/screen-users

Reply via email to