diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-03-29 19:30:17 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-03-29 19:30:17 +0000 |
commit | 746d85368ae1784f473ab0330057b21b74b4c25a (patch) | |
tree | add78d2541e468fb6cd66ea67f8a948f0129f2d4 /usr.bin | |
parent | a2f6027b10bc852f5151c4efff81d6b2859b14db (diff) |
Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-display-message.c | 23 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-pipe-pane.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 49 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 14 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 |
6 files changed, 65 insertions, 36 deletions
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index 36e5f47c344..2576dfe6055 100644 --- a/usr.bin/tmux/cmd-display-message.c +++ b/usr.bin/tmux/cmd-display-message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-message.c,v 1.8 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.9 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -30,8 +30,8 @@ int cmd_display_message_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_display_message_entry = { "display-message", "display", - "pt:", 0, 1, - "[-p] " CMD_TARGET_CLIENT_USAGE " [message]", + "c:pt:", 0, 1, + "[-p] [-c target-client] [-t target-pane] [message]", 0, NULL, NULL, @@ -43,18 +43,31 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct client *c; + struct session *s; + struct winlink *wl; + struct window_pane *wp; const char *template; char *msg; - if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) + if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL) return (-1); + if (args_has(args, 't') != NULL) { + wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp); + if (wl == NULL) + return (-1); + } else { + s = NULL; + wl = NULL; + wp = NULL; + } + if (args->argc == 0) template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)"; else template = args->argv[0]; - msg = status_replace(c, NULL, template, time(NULL), 0); + msg = status_replace(c, s, wl, wp, template, time(NULL), 0); if (args_has(self->args, 'p')) ctx->print(ctx, "%s", msg); else diff --git a/usr.bin/tmux/cmd-pipe-pane.c b/usr.bin/tmux/cmd-pipe-pane.c index eb02e078829..405c49ffeb2 100644 --- a/usr.bin/tmux/cmd-pipe-pane.c +++ b/usr.bin/tmux/cmd-pipe-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-pipe-pane.c,v 1.18 2011/01/08 01:52:36 nicm Exp $ */ +/* $OpenBSD: cmd-pipe-pane.c,v 1.19 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -113,7 +113,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) closefrom(STDERR_FILENO + 1); - command = status_replace(c, NULL, args->argv[0], time(NULL), 0); + command = status_replace( + c, NULL, NULL, NULL, args->argv[0], time(NULL), 0); execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL); _exit(1); default: diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 62b6d9896c7..4b0b2d0a02c 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.51 2011/01/26 01:54:56 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.52 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -614,7 +614,7 @@ server_client_set_title(struct client *c) template = options_get_string(&s->options, "set-titles-string"); - title = status_replace(c, NULL, template, time(NULL), 1); + title = status_replace(c, NULL, NULL, NULL, template, time(NULL), 1); if (c->title == NULL || strcmp(title, c->title) != 0) { if (c->title != NULL) xfree(c->title); diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index 22fbbeda5d6..6448949cfa0 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.71 2011/01/26 01:54:56 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.72 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -38,8 +38,8 @@ void status_job_free(void *); void status_job_callback(struct job *); char *status_print( struct client *, struct winlink *, time_t, struct grid_cell *); -void status_replace1(struct client *, - struct winlink *, char **, char **, char *, size_t, int); +void status_replace1(struct client *, struct session *, struct winlink *, + struct window_pane *, char **, char **, char *, size_t, int); void status_message_callback(int, short, void *); const char *status_prompt_up_history(u_int *); @@ -80,8 +80,8 @@ status_redraw_get_left(struct client *c, if (attr != 0) gc->attr = attr; - left = status_replace( - c, NULL, options_get_string(&s->options, "status-left"), t, 1); + left = status_replace(c, NULL, + NULL, NULL, options_get_string(&s->options, "status-left"), t, 1); *size = options_get_number(&s->options, "status-left-length"); leftlen = screen_write_cstrlen(utf8flag, "%s", left); @@ -110,8 +110,8 @@ status_redraw_get_right(struct client *c, if (attr != 0) gc->attr = attr; - right = status_replace( - c, NULL, options_get_string(&s->options, "status-right"), t, 1); + right = status_replace(c, NULL, + NULL, NULL, options_get_string(&s->options, "status-right"), t, 1); *size = options_get_number(&s->options, "status-right-length"); rightlen = screen_write_cstrlen(utf8flag, "%s", right); @@ -347,16 +347,20 @@ out: /* Replace a single special sequence (prefixed by #). */ void -status_replace1(struct client *c,struct winlink *wl, - char **iptr, char **optr, char *out, size_t outsize, int jobsflag) +status_replace1(struct client *c, struct session *s, struct winlink *wl, + struct window_pane *wp, char **iptr, char **optr, char *out, + size_t outsize, int jobsflag) { - struct session *s = c->session; - char ch, tmp[256], *ptr, *endptr, *freeptr; - size_t ptrlen; - long limit; + char ch, tmp[256], *ptr, *endptr, *freeptr; + size_t ptrlen; + long limit; + if (s == NULL) + s = c->session; if (wl == NULL) wl = s->curw; + if (wp == NULL) + wp = wl->window->active; errno = 0; limit = strtol(*iptr, &endptr, 10); @@ -379,6 +383,10 @@ status_replace1(struct client *c,struct winlink *wl, if ((ptr = status_find_job(c, iptr)) == NULL) return; goto do_replace; + case 'D': + xsnprintf(tmp, sizeof tmp, "%%%u", wp->id); + ptr = tmp; + goto do_replace; case 'H': if (gethostname(tmp, sizeof tmp) != 0) fatal("gethostname failed"); @@ -389,15 +397,15 @@ status_replace1(struct client *c,struct winlink *wl, ptr = tmp; goto do_replace; case 'P': - xsnprintf(tmp, sizeof tmp, "%u", - window_pane_index(wl->window, wl->window->active)); + xsnprintf( + tmp, sizeof tmp, "%u", window_pane_index(wl->window, wp)); ptr = tmp; goto do_replace; case 'S': ptr = s->name; goto do_replace; case 'T': - ptr = wl->window->active->base.title; + ptr = wp->base.title; goto do_replace; case 'W': ptr = wl->window->name; @@ -449,8 +457,8 @@ skip_to: /* Replace special sequences in fmt. */ char * -status_replace(struct client *c, - struct winlink *wl, const char *fmt, time_t t, int jobsflag) +status_replace(struct client *c, struct session *s, struct winlink *wl, + struct window_pane *wp, const char *fmt, time_t t, int jobsflag) { static char out[BUFSIZ]; char in[BUFSIZ], ch, *iptr, *optr; @@ -470,7 +478,8 @@ status_replace(struct client *c, *optr++ = ch; continue; } - status_replace1(c, wl, &iptr, &optr, out, sizeof out, jobsflag); + status_replace1( + c, s, wl, wp, &iptr, &optr, out, sizeof out, jobsflag); } *optr = '\0'; @@ -657,7 +666,7 @@ status_print( gc->attr = attr; } - text = status_replace(c, wl, fmt, t, 1); + text = status_replace(c, NULL, wl, NULL, fmt, t, 1); return (text); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index d69b8cad434..c7d427576bf 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.214 2011/03/28 23:13:00 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.215 2011/03/29 19:30:16 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 28 2011 $ +.Dd $Mdocdate: March 29 2011 $ .Dt TMUX 1 .Os .Sh NAME @@ -2611,7 +2611,8 @@ This command works only from inside .Nm . .It Xo Ic display-message .Op Fl p -.Op Fl t Ar target-client +.Op Fl c Ar target-client +.Op Fl t Ar target-pane .Op Ar message .Xc .D1 (alias: Ic display ) @@ -2625,7 +2626,12 @@ The format of .Ar message is as for .Ic status-left , -with the exception that #() are not handled. +with the exception that #() are not handled; information is taken from +.Ar target-pane +if +.Fl t +is given, otherwise the active pane for the session attached to +.Ar target-client . .El .Sh BUFFERS .Nm diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index cfe1d27926c..1f315eb4425 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.276 2011/03/28 19:44:31 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.277 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1666,8 +1666,8 @@ RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp); void status_free_jobs(struct status_out_tree *); void status_update_jobs(struct client *); int status_redraw(struct client *); -char *status_replace( - struct client *, struct winlink *, const char *, time_t, int); +char *status_replace(struct client *, struct session *, + struct winlink *, struct window_pane *, const char *, time_t, int); void printflike2 status_message_set(struct client *, const char *, ...); void status_message_clear(struct client *); int status_message_redraw(struct client *); |