diff options
68 files changed, 458 insertions, 494 deletions
@@ -1,5 +1,8 @@ 19 January 2009 +* An error in a command sequence now stops execution of that sequence. + Internally, each command code now passes a return code back rather than + talking to the calling client (if any) directly. * attach-session now tries to start the server if it isn't already started - if no sessions are created in .tmux.conf this will cause an error. * Clean up starting server by making initial client get a special socketpair. @@ -23,9 +26,9 @@ bind x lsk \; lsc - Commands are executed from left to right and, importantly, an error does NOT - stop execution. Also note that command sequences do not support repeat-time - repetition unless all commands making up the sequence support it. + Commands are executed from left to right. Also note that command sequences do + not support repeat-time repetition unless all commands making up the sequence + support it. * suspend-client command to suspend a client. Don't try to background it though... * Mark attached sessions in sessions lists. Suggested by Simon Kuhnle. @@ -964,7 +967,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.221 2009-01-19 17:16:09 nicm Exp $ +$Id: CHANGES,v 1.222 2009-01-19 18:23:40 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms @@ -83,4 +83,3 @@ - bring back -l/-p on splitw so i can do "splitw -p 75 elinks" - UTF-8 combining characters don't work (probably should be width 1 but are listed as 2) - diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 2686563a..1a403c65 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.22 2009-01-19 17:16:09 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.23 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Attach existing session to the current terminal. */ -void cmd_attach_session_exec(struct cmd *, struct cmd_ctx *); +int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_attach_session_entry = { "attach-session", "attach", @@ -39,7 +39,7 @@ const struct cmd_entry cmd_attach_session_entry = { cmd_target_print }; -void +int cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -47,24 +47,24 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) char *cause; if (ctx->curclient != NULL) - return; + return (0); if (ARRAY_LENGTH(&sessions) == 0) { ctx->error(ctx, "no sessions"); - return; + return (-1); } if ((s = cmd_find_session(ctx, data->target)) == NULL) - return; + return (-1); if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) { ctx->error(ctx, "not a terminal"); - return; + return (-1); } if (tty_open(&ctx->cmdclient->tty, &cause) != 0) { ctx->error(ctx, "%s", cause); xfree(cause); - return; + return (-1); } if (data->flags & CMD_DFLAG) @@ -74,5 +74,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) server_write_client(ctx->cmdclient, MSG_READY, NULL, 0); recalculate_sizes(); server_redraw_client(ctx->cmdclient); + + return (1); } diff --git a/cmd-bind-key.c b/cmd-bind-key.c index ba00f244..d8dc0dff 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.18 2009-01-18 14:40:48 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.19 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,7 +25,7 @@ */ int cmd_bind_key_parse(struct cmd *, int, char **, char **); -void cmd_bind_key_exec(struct cmd *, struct cmd_ctx *); +int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *); void cmd_bind_key_send(struct cmd *, struct buffer *); void cmd_bind_key_recv(struct cmd *, struct buffer *); void cmd_bind_key_free(struct cmd *); @@ -89,19 +89,18 @@ error: return (-1); } -void -cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx) +int +cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) { struct cmd_bind_key_data *data = self->data; if (data == NULL) - return; + return (0); key_bindings_add(data->key, data->cmdlist); data->cmdlist = NULL; /* avoid free */ - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } void diff --git a/cmd-choose-session.c b/cmd-choose-session.c index 151a8e64..dd637a55 100644 --- a/cmd-choose-session.c +++ b/cmd-choose-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-session.c,v 1.5 2009-01-18 19:10:08 nicm Exp $ */ +/* $Id: cmd-choose-session.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Enter choice mode to choose a session. */ -void cmd_choose_session_exec(struct cmd *, struct cmd_ctx *); +int cmd_choose_session_exec(struct cmd *, struct cmd_ctx *); void cmd_choose_session_callback(void *, int); @@ -45,7 +45,7 @@ struct cmd_choose_session_data { u_int client; }; -void +int cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -56,14 +56,14 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); - return; + return (-1); } if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) - goto out; + return (0); cur = idx = 0; for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { @@ -86,9 +86,7 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx) window_choose_ready( wl->window->active, cur, cmd_choose_session_callback, cdata); -out: - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } void diff --git a/cmd-choose-window.c b/cmd-choose-window.c index b7f90dc6..9820c01e 100644 --- a/cmd-choose-window.c +++ b/cmd-choose-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-window.c,v 1.6 2009-01-18 19:10:08 nicm Exp $ */ +/* $Id: cmd-choose-window.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Enter choice mode to choose a window. */ -void cmd_choose_window_exec(struct cmd *, struct cmd_ctx *); +int cmd_choose_window_exec(struct cmd *, struct cmd_ctx *); void cmd_choose_window_callback(void *, int); @@ -45,7 +45,7 @@ struct cmd_choose_window_data { u_int session; }; -void +int cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -57,15 +57,15 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); - return; + return (-1); } s = ctx->curclient->session; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) - goto out; + return (0); cur = idx = 0; RB_FOREACH(wm, winlinks, &s->windows) { @@ -87,9 +87,7 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) window_choose_ready( wl->window->active, cur, cmd_choose_window_callback, cdata); -out: - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } void diff --git a/cmd-clock-mode.c b/cmd-clock-mode.c index 9c8e72d0..de10833d 100644 --- a/cmd-clock-mode.c +++ b/cmd-clock-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-clock-mode.c,v 1.2 2009-01-11 23:31:46 nicm Exp $ */ +/* $Id: cmd-clock-mode.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Enter clock mode. */ -void cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *); +int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_clock_mode_entry = { "clock-mode", NULL, @@ -39,17 +39,16 @@ const struct cmd_entry cmd_clock_mode_entry = { cmd_target_print }; -void +int cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); window_pane_set_mode(wl->window->active, &window_clock_mode); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index eca662fe..be962173 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-command-prompt.c,v 1.11 2009-01-18 17:20:52 nicm Exp $ */ +/* $Id: cmd-command-prompt.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,7 +28,7 @@ */ void cmd_command_prompt_init(struct cmd *, int); -void cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *); +int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *); int cmd_command_prompt_callback(void *, const char *); @@ -68,7 +68,7 @@ cmd_command_prompt_init(struct cmd *self, int key) } } -void +int cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -77,10 +77,10 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) char *hdr, *ptr; if ((c = cmd_find_client(ctx, data->target)) == NULL) - return; + return (-1); if (c->prompt_string != NULL) - return; + return (0); cdata = xmalloc(sizeof *cdata); cdata->c = c; @@ -96,8 +96,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) server_set_client_prompt(c, hdr, cmd_command_prompt_callback, cdata, 0); xfree(hdr); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } int diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index f342e3fe..b15106e9 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-copy-mode.c,v 1.13 2009-01-11 23:31:46 nicm Exp $ */ +/* $Id: cmd-copy-mode.c,v 1.14 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Enter copy mode. */ -void cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *); +int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_copy_mode_entry = { "copy-mode", NULL, @@ -39,17 +39,16 @@ const struct cmd_entry cmd_copy_mode_entry = { NULL }; -void +int cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); window_pane_set_mode(wl->window->active, &window_copy_mode); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } diff --git a/cmd-delete-buffer.c b/cmd-delete-buffer.c index 073dbf04..377ff622 100644 --- a/cmd-delete-buffer.c +++ b/cmd-delete-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-delete-buffer.c,v 1.3 2008-12-10 20:25:41 nicm Exp $ */ +/* $Id: cmd-delete-buffer.c,v 1.4 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,7 +26,7 @@ * Delete a paste buffer. */ -void cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *); +int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_delete_buffer_entry = { "delete-buffer", "deleteb", @@ -41,22 +41,21 @@ const struct cmd_entry cmd_delete_buffer_entry = { cmd_buffer_print }; -void +int cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_buffer_data *data = self->data; struct session *s; if ((s = cmd_find_session(ctx, data->target)) == NULL) - return; + return (-1); if (data->buffer == -1) paste_free_top(&s->buffers); - else { - if (paste_free_index(&s->buffers, data->buffer) != 0) - ctx->error(ctx, "no buffer %d", data->buffer); + else if (paste_free_index(&s->buffers, data->buffer) != 0) { + ctx->error(ctx, "no buffer %d", data->buffer); + return (-1); } - - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + + return (0); } diff --git a/cmd-detach-client.c b/cmd-detach-client.c index 1697adcd..3c0879e1 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-detach-client.c,v 1.6 2008-06-05 21:25:00 nicm Exp $ */ +/* $Id: cmd-detach-client.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Detach a client. */ -void cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); +int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_detach_client_entry = { "detach-client", "detach", @@ -39,17 +39,16 @@ const struct cmd_entry cmd_detach_client_entry = { cmd_target_print }; -void +int cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct client *c; if ((c = cmd_find_client(ctx, data->target)) == NULL) - return; + return (-1); server_write_client(c, MSG_DETACH, NULL, 0); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } diff --git a/cmd-down-pane.c b/cmd-down-pane.c index 8958a353..7e436fe0 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-down-pane.c,v 1.2 2009-01-14 22:13:30 nicm Exp $ */ +/* $Id: cmd-down-pane.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Move down a pane. */ -void cmd_down_pane_exec(struct cmd *, struct cmd_ctx *); +int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_down_pane_entry = { "down-pane", "downp", @@ -39,7 +39,7 @@ const struct cmd_entry cmd_down_pane_entry = { cmd_target_print }; -void +int cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -47,7 +47,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct window *w; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); w = wl->window; do { @@ -56,6 +56,5 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_FIRST(&w->panes); } while (w->active->flags & PANE_HIDDEN); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } diff --git a/cmd-find-window.c b/cmd-find-window.c index b46884e0..cae763fe 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-find-window.c,v 1.2 2009-01-18 19:10:08 nicm Exp $ */ +/* $Id: cmd-find-window.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,7 +26,7 @@ * Find window containing text. */ -void cmd_find_window_exec(struct cmd *, struct cmd_ctx *); +int cmd_find_window_exec(struct cmd *, struct cmd_ctx *); void cmd_find_window_callback(void *, int); char *cmd_find_window_search(struct window_pane *, const char *); @@ -48,7 +48,7 @@ struct cmd_find_window_data { u_int session; }; -void +int cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; @@ -64,12 +64,12 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); - return; + return (-1); } s = ctx->curclient->session; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) - return; + return (-1); ARRAY_INIT(&list_idx); ARRAY_INIT(&list_ctx); @@ -106,7 +106,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) ctx->error(ctx, "no windows matching: %s", data->arg); ARRAY_FREE(&list_idx); ARRAY_FREE(&list_ctx); - return; + return (-1); } if (ARRAY_LENGTH(&list_idx) == 1) { @@ -142,8 +142,7 @@ out: ARRAY_FREE(&list_idx); ARRAY_FREE(&list_ctx); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } void diff --git a/cmd-has-session.c b/cmd-has-session.c index e5aa2e22..9cd3f128 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-has-session.c,v 1.11 2008-06-23 19:51:48 nicm Exp $ */ +/* $Id: cmd-has-session.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Cause client to report an error and exit with 1 if session doesn't exist. */ -void cmd_has_session_exec(struct cmd *, struct cmd_ctx *); +int cmd_has_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_has_session_entry = { "has-session", "has", @@ -39,14 +39,13 @@ const struct cmd_entry cmd_has_session_entry = { cmd_target_print }; -void +int cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; if (cmd_find_session(ctx, data->target) == NULL) - return; + return (-1); - if (ctx->cmdclient != NULL) - server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); + return (0); } diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index 81040cc1..aaeea59b 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-pane.c,v 1.2 2009-01-14 19:29:32 nicm Exp $ */ |