On Tue, Feb 07, 2012 at 12:06:23AM +0100, Amadeusz Sławiński wrote:
> Attached patch adds support for multiple windows input.
Made version 2
> To use it apply patch and ./configure --enable-multiinput
Decided to remove ./configure option, there is enough of them already
>
> Windows can be marked via C-a :
> multiinput - toggles multi input on current window
> multiinput n - toggles on nth window
>
> Input to all chosen windows occurs only from window which is itself
> selected to allow normal usage of unselected windows.
on :windowlist '>' key can now be used to select windows
>
> Chosen windows on the window list are marked with '>'.
Also fixed the loop for writing so it goes in only when needed
Amadeusz
diff --git a/src/comm.c b/src/comm.c
index 5f4af8a..7ef168f 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -238,6 +238,7 @@ struct comm comms[RC_LAST + 1] =
{ "mousetrack", NEED_DISPLAY | ARGS_01 },
{ "msgminwait", ARGS_1 },
{ "msgwait", ARGS_1 },
+ { "multiinput", ARGS_01 },
#ifdef MULTIUSER
{ "multiuser", ARGS_1 },
#endif
diff --git a/src/list_window.c b/src/list_window.c
index 2242de9..ce97193 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -335,6 +335,10 @@ gl_Window_input(struct ListData *ldata, char **inp, int
*len)
gl_Window_rebuild(ldata);
break;
+ case '>':
+ win->w_miflag = win->w_miflag ? 0 : 1;
+ WindowChangeNumber(win, win->w_number);
+ break;
case 'a':
/* All-window view */
if (wdata->group)
diff --git a/src/process.c b/src/process.c
index 70e59f3..0645385 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1237,6 +1237,29 @@ int key;
else if (queryflag >= 0)
queryflag = -1; /* ParseWinNum already prints out an appropriate error
message. */
break;
+ case RC_MULTIINPUT:
+ if (!*args)
+ {
+ if (!fore)
+ OutputMsg(0, "multiinput needs a window");
+ else
+ fore->w_miflag = (fore->w_miflag) ? 0 : 1;
+ }
+ else
+ {
+ if (ParseWinNum(act, &n) == 0)
+ {
+ struct win *p;
+ if ((p = wtab[n]) == 0)
+ {
+ ShowWindows(n);
+ break;
+ }
+ else
+ p->w_miflag = (p->w_miflag) ? 0 : 1;
+ }
+ }
+ break;
#ifdef AUTO_NUKE
case RC_DEFAUTONUKE:
if (ParseOnOff(act, &defautonuke) == 0 && msgok)
@@ -5494,6 +5517,8 @@ struct win *p;
}
if (p->w_ptyfd < 0 && p->w_type != W_TYPE_GROUP)
*s++ = 'Z';
+ if (p->w_miflag)
+ *s++ = '>';
*s = 0;
return s;
}
diff --git a/src/window.c b/src/window.c
index 1c6f5b6..d9f5993 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1944,14 +1944,22 @@ struct event *ev;
char *data;
{
struct win *p = (struct win *)data;
+ struct win *win;
int len;
if (p->w_inlen)
{
debug2("writing %d bytes to win %d\n", p->w_inlen, p->w_number);
if ((len = write(ev->fd, p->w_inbuf, p->w_inlen)) <= 0)
len = p->w_inlen; /* dead window */
+
+ if (p->w_miflag) /* don't loop if not needed */
+ for (win = windows; win; win = win->w_next)
+ if (win != p && win->w_miflag)
+ write(win->w_ptyfd, p->w_inbuf, p->w_inlen);
+
if ((p->w_inlen -= len))
bcopy(p->w_inbuf + len, p->w_inbuf, p->w_inlen);
+
}
#ifdef COPY_PASTE
if (p->w_paster.pa_pastelen && !p->w_slowpaste)
diff --git a/src/window.h b/src/window.h
index 7311ecb..cec9e78 100644
--- a/src/window.h
+++ b/src/window.h
@@ -299,6 +299,7 @@ struct win
#else
int w_exitstatus;
#endif
+ int w_miflag; /* multiple windows input flag */
};