Hi
This is what I did, not much but I didn't have a lot of time... not sure
if it'll still apply.
Let me know if you have any questions.
Index: client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/client.c,v
retrieving revision 1.100
diff -u -p -r1.100 client.c
--- client.c 24 Oct 2010 19:54:41 -0000 1.100
+++ client.c 7 Dec 2010 01:17:52 -0000
@@ -175,22 +175,24 @@ client_main(int argc, char **argv, int f
client_send_identify(flags);
/* Send first command. */
- if (msg == MSG_COMMAND) {
- /* Fill in command line arguments. */
- cmddata.pid = environ_pid;
- cmddata.idx = environ_idx;
-
- /* Prepare command for server. */
- cmddata.argc = argc;
- if (cmd_pack_argv(
- argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
- log_warnx("command too long");
- return (1);
- }
+ if (!(flags & IDENTIFY_CONTROL)) {
+ if (msg == MSG_COMMAND) {
+ /* Fill in command line arguments. */
+ cmddata.pid = environ_pid;
+ cmddata.idx = environ_idx;
+
+ /* Prepare command for server. */
+ cmddata.argc = argc;
+ if (cmd_pack_argv(argc, argv,
+ cmddata.argv, sizeof cmddata.argv) != 0) {
+ log_warnx("command too long");
+ return (1);
+ }
- client_write_server(msg, &cmddata, sizeof cmddata);
- } else if (msg == MSG_SHELL)
- client_write_server(msg, NULL, 0);
+ client_write_server(msg, &cmddata, sizeof cmddata);
+ } else if (msg == MSG_SHELL)
+ client_write_server(msg, NULL, 0);
+ }
/* Set the event and dispatch. */
client_update_event();
@@ -220,11 +222,6 @@ client_send_identify(int flags)
strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
*data.term = '\0';
- if ((fd = dup(STDIN_FILENO)) == -1)
- fatal("dup failed");
- imsg_compose(&client_ibuf,
- MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
-
if ((fd = dup(STDOUT_FILENO)) == -1)
fatal("dup failed");
imsg_compose(&client_ibuf,
@@ -234,6 +231,11 @@ client_send_identify(int flags)
fatal("dup failed");
imsg_compose(&client_ibuf,
MSG_STDERR, PROTOCOL_VERSION, -1, fd, NULL, 0);
+
+ if ((fd = dup(STDIN_FILENO)) == -1)
+ fatal("dup failed");
+ imsg_compose(&client_ibuf,
+ MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
}
/* Forward entire environment to server. */
Index: cmd-new-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-session.c,v
retrieving revision 1.78
diff -u -p -r1.78 cmd-new-session.c
--- cmd-new-session.c 2 Jul 2010 02:49:19 -0000 1.78
+++ cmd-new-session.c 7 Dec 2010 01:17:53 -0000
@@ -165,6 +165,8 @@ cmd_new_session_exec(struct cmd *self, s
detached = data->flag_detached;
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
detached = 1;
+ if (ctx->cmdclient != NULL && ctx->cmdclient->flags & CLIENT_CONTROL)
+ detached = 1;
/*
* Save the termios settings, part of which is used for new windows in
Index: control.c
===================================================================
RCS file: control.c
diff -N control.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ control.c 7 Dec 2010 01:17:53 -0000
@@ -0,0 +1,133 @@
+/* $Id$ */
+
+/*
+ * Copyright (c) 2010 Nicholas Marriott <[email protected]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <event.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "tmux.h"
+
+/*
+ * XXX TODO
+ *
+ * Prevent other uses of stdin/stdout fds.
+ */
+
+void control_read_callback(struct bufferevent *, void *);
+void control_error_callback(struct bufferevent *, short, void *);
+
+void printflike2
+control_msg_error(struct cmd_ctx *ctx, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ evbuffer_add_vprintf(ctx->cmdclient->stdout_event->output, fmt, ap);
+ va_end(ap);
+
+ bufferevent_write(ctx->cmdclient->stdout_event, "\n", 1);
+}
+
+void printflike2
+control_msg_print(struct cmd_ctx *ctx, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ evbuffer_add_vprintf(ctx->cmdclient->stdout_event->output, fmt, ap);
+ va_end(ap);
+
+ bufferevent_write(ctx->cmdclient->stdout_event, "\n", 1);
+}
+
+void printflike2
+control_msg_info(unused struct cmd_ctx *ctx, unused const char *fmt, ...)
+{
+}
+
+/* Control input callback. */
+void
+control_read_callback(unused struct bufferevent *bufev, void *data)
+{
+ struct client *c = data;
+ struct bufferevent *out = c->stdout_event;
+ char *line;
+ struct cmd_ctx ctx;
+ struct cmd_list *cmdlist;
+ char *cause;
+
+ /* Read input line. */
+ line = evbuffer_readln(c->stdin_event->input, NULL, EVBUFFER_EOL_CRLF);
+ if (line == NULL)
+ return;
+
+ /* Parse command. */
+ if (*line != '%') {
+ /* This is a standard tmux command. */
+ ctx.msgdata = NULL;
+ ctx.curclient = NULL;
+
+ ctx.error = control_msg_error;
+ ctx.print = control_msg_print;
+ ctx.info = control_msg_info;
+
+ ctx.cmdclient = c;
+
+ if (cmd_string_parse(line, &cmdlist, &cause) != 0) {
+ evbuffer_add_printf(out->output, "%s", cause);
+ bufferevent_write(out, "\n", 1);
+ xfree(cause);
+ } else {
+ cmd_list_exec(cmdlist, &ctx);
+ cmd_list_free(cmdlist);
+ }
+ } else {
+ /* This is a protocol command. */
+ }
+
+ xfree(line);
+}
+
+/* Control error callback. */
+void
+control_error_callback(
+ unused struct bufferevent *bufev, unused short what, void *data)
+{
+ struct client *c = data;
+}
+
+/* Initialise as a control client. */
+void
+control_start(struct client *c)
+{
+ /* Enable reading from stdin. */
+ if (c->stdin_event != NULL)
+ bufferevent_free(c->stdin_event);
+ c->stdin_event = bufferevent_new(c->stdin_fd,
+ control_read_callback, NULL, control_error_callback, c);
+ if (c->stdin_event == NULL)
+ fatalx("failed to create stdin event");
+ bufferevent_enable(c->stdin_event, EV_READ);
+
+ /* Write the protocol identifier and version. */
+ evbuffer_add_printf(c->stdout_event->output,
+ "\033_tmux1\033\\%%noop tmux ready\n");
+ bufferevent_enable(c->stdout_event, EV_WRITE);
+}
Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.45
diff -u -p -r1.45 server-client.c
--- server-client.c 24 Oct 2010 01:51:34 -0000 1.45
+++ server-client.c 7 Dec 2010 01:17:53 -0000
@@ -901,6 +901,18 @@ server_client_msg_identify(
if (*data->cwd != '\0')
c->cwd = xstrdup(data->cwd);
+ /*
+ * If this is a control client, mark the client, send the ready message
+ * and continue.
+ */
+ if (data->flags & IDENTIFY_CONTROL) {
+ c->flags |= CLIENT_CONTROL;
+
+ control_start(c);
+ server_write_client(c, MSG_READY, NULL, 0);
+ return;
+ }
+
if (!isatty(fd))
return;
if ((tty_fd = dup(fd)) == -1)
Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.224
diff -u -p -r1.224 tmux.c
--- tmux.c 6 Dec 2010 22:52:21 -0000 1.224
+++ tmux.c 7 Dec 2010 01:17:53 -0000
@@ -243,7 +243,7 @@ main(int argc, char **argv)
quiet = flags = 0;
label = path = NULL;
login_shell = (**argv == '-');
- while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {
+ while ((opt = getopt(argc, argv, "28Cc:df:lL:qS:uUv")) != -1) {
switch (opt) {
case '2':
flags |= IDENTIFY_256COLOURS;
@@ -253,6 +253,9 @@ main(int argc, char **argv)
flags |= IDENTIFY_88COLOURS;
flags &= ~IDENTIFY_256COLOURS;
break;
+ case 'C':
+ flags |= IDENTIFY_CONTROL;
+ break;
case 'c':
if (shell_cmd != NULL)
xfree(shell_cmd);
@@ -294,6 +297,8 @@ main(int argc, char **argv)
if (shell_cmd != NULL && argc != 0)
usage();
+ if ((flags & IDENTIFY_CONTROL) && (argc != 0 || shell_cmd != NULL))
+ usage();
log_open_tty(debug_level);
Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.585
diff -u -p -r1.585 tmux.h
--- tmux.h 6 Dec 2010 22:52:21 -0000 1.585
+++ tmux.h 7 Dec 2010 01:17:54 -0000
@@ -396,6 +396,7 @@ struct msg_identify_data {
#define IDENTIFY_UTF8 0x1
#define IDENTIFY_256COLOURS 0x2
#define IDENTIFY_88COLOURS 0x4
+#define IDENTIFY_CONTROL 0x8
int flags;
};
@@ -1131,6 +1132,7 @@ struct client {
#define CLIENT_READONLY 0x800
#define CLIENT_BACKOFF 0x1000
#define CLIENT_REDRAWWINDOW 0x2000
+#define CLIENT_CONTROL 0x4000
int flags;
struct event identify_timer;
@@ -1608,6 +1610,9 @@ size_t cmd_buffer_print(struct cmd *, ch
/* client.c */
int client_main(int, char **, int);
+/* control.c */
+void control_start(struct client *);
+
/* key-bindings.c */
extern struct key_bindings key_bindings;
int key_bindings_cmp(struct key_binding *, struct key_binding *);
On Tue, May 03, 2011 at 10:22:48AM -0700, George Nachman wrote:
> Hi Nicholas,
>
> I've got some time coming up to work on this. Can you send me whatever
> you've done so far?
>
> Thanks,
> George
>
> On Wed, Mar 23, 2011 at 11:12 PM, Nicholas Marriott
> <[email protected]> wrote:
> > Yep this is a cool idea and I am happy but that George wrote up the
> > design doc but I haven't had time up to now although I did some basic
> > work and yes if anyone is interested in carrying on then let me know and
> > I will have time to give help if necessary.
> >
> > Many of the changes are relatively simple. The key problem point is that
> > we need to be able to redirect the tmux output so that instead of or as
> > well as, for example, writing to a terminal in xterm format (dictated by
> > TERM=xterm) it can suitable format and send that output to ssh. This may
> > be as simple as added a callback hook or two into the tty code and a
> > fake tty struct instance for clients which need to do this, or it may be
> > more complex. Or possibly it might be better to do it in the screen or
> > grid code in some terminal-independent format.
> >
> > I recently had a discussion with someone about another sort of
> > long-range idea: making tmux more network aware. This had some similar
> > themes - allowing the sessions and windows in a tmux server to be
> > controlled externally, in this case by another tmux server on another
> > host. A lot of the work that was in this design would probably make that
> > easier or at least help to work out the possibilites more fully.
> >
> > Of course if there are any talented C hackers out there who want
> > something to do, there are plenty of other ideas. Recently I
> > particularly liked the one in this mail:
> >
> > http://www.mail-archive.com/[email protected]/msg01248.html
> >
> > Which is quite simple but could make list-* commands so much more
> > flexible.
> >
> >
> > On Wed, Mar 23, 2011 at 05:34:05PM -0700, Joshua Keroes wrote:
> >> ? ?Imagine a reinvented terminal app.
> >> ? ?First, let's use tmux as the backend. Users would get autodetech and the
> >> ? ?safety that comes with it automatically. Session moves and dupes also
> >> come
> >> ? ?free.?We have this functionality today if you're clever with your
> >> startup
> >> ? ?dotfiles. This isn't new.
> >> ? ?Merging tmux and a terminal app together into one glorious zombified
> >> ? ?mutant is much more interesting.
> >> ? ?+ tmux could use app-level hotkeys without fear of stomping on someone
> >> ? ?else. Goodbye ctrl-b 4, hello ctrl-4.
> >> ? ?+ tmux would get pointy-clicky-draggy-reorderable tabs.
> >> ? ?+ tmux would get draggable pane separators.
> >> ? ?+ tmux would get moveable panes, too.
> >> ? ?+ tmux could potentially get a fancier status bar since it could now use
> >> ? ?the host's UI for bells and whistles. Growl and Gnotify come to mind.
> >> ? ?+ Right-click could do useful things too. For example, right-clicking
> >> on a
> >> ? ?tab or pane could display its available actions. Perhaps hovering over
> >> ? ?tabs could display thumbnails.
> >> ? ?+ Mouse gestures could be leveraged too: the "zoom out" gesture could
> >> ? ?display thumbnails of all terminals just like Firefox, Chrome, or OSX.
> >> ? ?These are just off the tip of my mind - I'm sure you can imagine plenty
> >> of
> >> ? ?other places where a left-click or a right-click could help rather than
> >> ? ?hinder.
> >> ? ?Yes, I love my keyboard. Mice do have their place and can definitely
> >> help
> >> ? ?tmux out. Contextual help and actions would make tmux management simpler
> >> ? ?for those who don't want to open up the help page every time an
> >> infrequent
> >> ? ?task pops up.
> >> ? ?I asked the other half of this question on the iterm2 mailing list
> >> ("Wanna
> >> ? ?zombify iterm2's brain with tmux?). George Nachman's already started
> >> ? ?working on an API. He wrote:
> >> ? ?> This is also my dream. I wrote a design doc,
> >> ? ?here:?[1]http://tinyurl.com/6cm5pd9?[docs.google]
> >> ? ?>
> >> ? ?> The tmux maintainer expressed interest but I think he didn't have time
> >> ? ?to do all the work required.
> >> ? ?> If there are any talented C hackers out there who want to help out,
> >> this
> >> ? ?is a big project that needs
> >> ? ?> doing, and it will earn you a place in heaven.
> >> ? ?-Joshua
> >>
> >> References
> >>
> >> ? ?Visible links
> >> ? ?1. http://tinyurl.com/6cm5pd9
> >
> >> ------------------------------------------------------------------------------
> >> Enable your software for Intel(R) Active Management Technology to meet the
> >> growing manageability and security demands of your customers. Businesses
> >> are taking advantage of Intel(R) vPro (TM) technology - will your software
> >> be a part of the solution? Download the Intel(R) Manageability Checker
> >> today! http://p.sf.net/sfu/intel-dev2devmar
> >
> >> _______________________________________________
> >> tmux-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/tmux-users
> >
> >
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users