diff -ur screen-4.0.2/comm.c /usr/local/src/screen-4.0.2/comm.c --- screen-4.0.2/comm.c 2003-09-08 16:25:08.000000000 +0200 +++ /usr/local/src/screen-4.0.2/comm.c 2006-02-27 02:53:59.000000000 +0100 @@ -272,6 +272,7 @@ #ifdef COPY_PASTE { "scrollback", NEED_FORE|ARGS_1 }, #endif + { "search", ARGS_01 }, { "select", ARGS_01 }, { "sessionname", ARGS_01 }, { "setenv", ARGS_012 }, diff -ur screen-4.0.2/doc/screen.1 /usr/local/src/screen-4.0.2/doc/screen.1 --- screen-4.0.2/doc/screen.1 2003-12-05 14:51:57.000000000 +0100 +++ /usr/local/src/screen-4.0.2/doc/screen.1 2006-03-19 22:27:30.000000000 +0100 @@ -384,6 +384,8 @@ The following table shows the default key bindings: .IP "\fBC-a '\fP (select)" Prompt for a window name or number to switch to. +.IP "\fBC-a /\fP (search)" +Prompt for a window name to search. .IP "\fBC-a ""\fP (windowlist -b)" Present a list of all windows for selection. .IP "\fBC-a 0\fP (select 0)" @@ -2575,6 +2577,14 @@ current setting. .sp .ne 3 +.BR "search " [ \fIText ] +.PP +Search for \fIText\fP in window names/titles. +If any windows which contains \fIText\fP in the name are found, switch to +the last used one. The parameter is optional and if omitted, you get +prompted for a search text. +.sp +.ne 3 .BR "select " [ \fIWindowID ] .PP Switch to the window identified by \fIWindowID\fP. diff -ur screen-4.0.2/process.c /usr/local/src/screen-4.0.2/process.c --- screen-4.0.2/process.c 2003-09-18 14:53:54.000000000 +0200 +++ /usr/local/src/screen-4.0.2/process.c 2006-03-19 22:44:50.000000000 +0100 @@ -123,6 +123,8 @@ static int IsNum __P((char *, int)); static void Colonfin __P((char *, int, char *)); static void InputSelect __P((void)); +static void InputSearch __P((void)); +static void SearchFin __P((char *, int, char *)); static void InputSetenv __P((char *)); static void InputAKA __P((void)); #ifdef MULTIUSER @@ -457,6 +459,7 @@ } #endif + ktab['/'].nr = RC_SEARCH; ktab['h'].nr = RC_HARDCOPY; #ifdef BSDJOBS ktab['z'].nr = ktab[Ctrl('z')].nr = RC_SUSPEND; @@ -1073,6 +1076,12 @@ msgok = display && !*rc_name; switch(nr) { + case RC_SEARCH: + if(!*args) + InputSearch(); + else + SearchFin(args[0], strlen(args[0]), NULL); + break; case RC_SELECT: if (!*args) InputSelect(); @@ -5116,13 +5125,45 @@ return; SwitchWindow(n); } - + +/* + * Search for a window title pattern. + * If we find any, switch to the first (which is the last used one) + * -- Fernando Vezzosi + */ +static void +SearchFin(buf, len, data) +char *buf; +int len; +char *data; +{ + int i=0; + struct win *wptr; + if(!len || !display) + return; + + for(wptr=windows; wptr; wptr=wptr->w_next, i++){ + if(strstr(wptr->w_title, buf)){ + SwitchWindow(wptr->w_number); +/* Msg(0, "Found, crossed %d windows", i);*/ + return; + } + } + Msg(0, "Pattern '%s' not found [%d windows]", buf, i); +} + static void InputSelect() { Input("Switch to window: ", 20, INP_COOKED, SelectFin, NULL); } +static void +InputSearch() +{ + Input("Search: ", 100, INP_COOKED, SearchFin, NULL); +} + static char setenv_var[31];