diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-show-messages.c | 65 | ||||
-rw-r--r-- | usr.bin/tmux/cmd.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 11 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 28 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 16 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 10 |
10 files changed, 136 insertions, 20 deletions
diff --git a/usr.bin/tmux/Makefile b/usr.bin/tmux/Makefile index 172476eec96..1d2cd72c773 100644 --- a/usr.bin/tmux/Makefile +++ b/usr.bin/tmux/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2009/11/04 22:44:53 nicm Exp $ +# $OpenBSD: Makefile,v 1.29 2009/11/18 13:16:33 nicm Exp $ PROG= tmux SRCS= attributes.c cfg.c client.c clock.c \ @@ -22,7 +22,7 @@ SRCS= attributes.c cfg.c client.c clock.c \ cmd-select-layout.c cmd-select-pane.c \ cmd-select-prompt.c cmd-select-window.c cmd-send-keys.c \ cmd-send-prefix.c cmd-server-info.c cmd-set-buffer.c cmd-set-option.c \ - cmd-set-window-option.c cmd-show-buffer.c \ + cmd-set-window-option.c cmd-show-buffer.c cmd-show-messages.c \ cmd-show-options.c cmd-show-window-options.c cmd-source-file.c \ cmd-split-window.c cmd-start-server.c cmd-string.c cmd-if-shell.c \ cmd-run-shell.c cmd-suspend-client.c cmd-swap-pane.c cmd-swap-window.c \ diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index e8696367a8b..5f1fad90b1f 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.25 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.26 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -67,6 +67,7 @@ const struct set_option_entry set_option_table[] = { { "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL }, { "message-bg", SET_OPTION_COLOUR, 0, 0, NULL }, { "message-fg", SET_OPTION_COLOUR, 0, 0, NULL }, + { "message-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL }, { "mouse-select-pane", SET_OPTION_FLAG, 0, 0, NULL }, { "prefix", SET_OPTION_KEYS, 0, 0, NULL }, { "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL }, diff --git a/usr.bin/tmux/cmd-show-messages.c b/usr.bin/tmux/cmd-show-messages.c new file mode 100644 index 00000000000..8c0292ed4d4 --- /dev/null +++ b/usr.bin/tmux/cmd-show-messages.c @@ -0,0 +1,65 @@ +/* $OpenBSD: cmd-show-messages.c,v 1.1 2009/11/18 13:16:33 nicm Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> + * + * 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 <string.h> +#include <time.h> + +#include "tmux.h" + +/* + * Show client message log. + */ + +int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_show_messages_entry = { + "show-messages", "showmsgs", + CMD_TARGET_CLIENT_USAGE, + 0, "", + cmd_target_init, + cmd_target_parse, + cmd_show_messages_exec, + cmd_target_free, + cmd_target_print +}; + +int +cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx) +{ + struct cmd_target_data *data = self->data; + struct client *c; + struct message_entry *msg; + char *tim; + u_int i; + + if ((c = cmd_find_client(ctx, data->target)) == NULL) + return (-1); + + for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { + msg = &ARRAY_ITEM(&c->message_log, i); + + tim = ctime(&msg->msg_time); + *strchr(tim, '\n') = '\0'; + + ctx->print(ctx, "%s %s", tim, msg->msg); + } + + return (0); +} diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 828dbda6bbd..c121d173614 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.31 2009/11/03 22:40:40 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.32 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -95,6 +95,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_set_window_option_entry, &cmd_show_buffer_entry, &cmd_show_environment_entry, + &cmd_show_messages_entry, &cmd_show_options_entry, &cmd_show_window_options_entry, &cmd_source_file_entry, diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index 45f04d5273c..98b4a26d1db 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.13 2009/11/13 07:00:54 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.14 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -105,8 +105,8 @@ key_bindings_init(void) { ' ', 0, &cmd_next_layout_entry }, { '!', 0, &cmd_break_pane_entry }, { '"', 0, &cmd_split_window_entry }, - { '%', 0, &cmd_split_window_entry }, { '#', 0, &cmd_list_buffers_entry }, + { '%', 0, &cmd_split_window_entry }, { '&', 0, &cmd_confirm_before_entry }, { ',', 0, &cmd_command_prompt_entry }, { '-', 0, &cmd_delete_buffer_entry }, @@ -123,13 +123,15 @@ key_bindings_init(void) { '9', 0, &cmd_select_window_entry }, { ':', 0, &cmd_command_prompt_entry }, { '?', 0, &cmd_list_keys_entry }, + { 'D', 0, &cmd_choose_client_entry }, { '[', 0, &cmd_copy_mode_entry }, { '\'', 0, &cmd_select_prompt_entry }, + { '\002', /* C-b */ 0, &cmd_send_prefix_entry }, + { '\017', /* C-o */ 0, &cmd_rotate_window_entry }, { '\032', /* C-z */ 0, &cmd_suspend_client_entry }, { ']', 0, &cmd_paste_buffer_entry }, { 'c', 0, &cmd_new_window_entry }, { 'd', 0, &cmd_detach_client_entry }, - { 'D', 0, &cmd_choose_client_entry }, { 'f', 0, &cmd_command_prompt_entry }, { 'i', 0, &cmd_display_message_entry }, { 'l', 0, &cmd_last_window_entry }, @@ -144,13 +146,14 @@ key_bindings_init(void) { 'x', 0, &cmd_confirm_before_entry }, { '{', 0, &cmd_swap_pane_entry }, { '}', 0, &cmd_swap_pane_entry }, - { '\002', /* C-b */ 0, &cmd_send_prefix_entry }, + { '~', 0, &cmd_show_messages_entry }, { '1' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, { '2' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, { '3' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, { '4' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, { KEYC_PPAGE, 0, &cmd_copy_mode_entry }, { 'n' | KEYC_ESCAPE, 0, &cmd_next_window_entry }, + { 'o' | KEYC_ESCAPE, 0, &cmd_rotate_window_entry }, { 'p' | KEYC_ESCAPE, 0, &cmd_previous_window_entry }, { KEYC_UP, 0, &cmd_up_pane_entry }, { KEYC_DOWN, 0, &cmd_down_pane_entry }, @@ -162,8 +165,6 @@ key_bindings_init(void) { KEYC_DOWN | KEYC_CTRL, 1, &cmd_resize_pane_entry }, { KEYC_LEFT | KEYC_CTRL, 1, &cmd_resize_pane_entry }, { KEYC_RIGHT | KEYC_CTRL, 1, &cmd_resize_pane_entry }, - { 'o' | KEYC_ESCAPE, 0, &cmd_rotate_window_entry }, - { '\017', /* C-o */ 0, &cmd_rotate_window_entry }, }; u_int i; struct cmd *cmd; diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 50cebd4ddf6..6115c9469d5 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.20 2009/11/13 18:13:18 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.21 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -80,6 +80,7 @@ server_client_create(int fd) job_tree_init(&c->status_jobs); c->message_string = NULL; + ARRAY_INIT(&c->message_log); c->prompt_string = NULL; c->prompt_buffer = NULL; @@ -101,7 +102,8 @@ server_client_create(int fd) void server_client_lost(struct client *c) { - u_int i; + struct message_entry *msg; + u_int i; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { if (ARRAY_ITEM(&clients, i) == c) @@ -129,6 +131,11 @@ server_client_lost(struct client *c) if (c->message_string != NULL) xfree(c->message_string); evtimer_del(&c->message_timer); + for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { + msg = &ARRAY_ITEM(&c->message_log, i); + xfree(msg->msg); + } + ARRAY_FREE(&c->message_log); if (c->prompt_string != NULL) xfree(c->prompt_string); diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index 44646637fa3..088d1fc22f8 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.43 2009/11/17 13:30:07 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.44 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -566,9 +566,12 @@ status_print(struct session *s, struct winlink *wl, struct grid_cell *gc) void printflike2 status_message_set(struct client *c, const char *fmt, ...) { - struct timeval tv; - va_list ap; - int delay; + struct timeval tv; + struct session *s = c->session; + struct message_entry *msg; + va_list ap; + int delay; + u_int i, limit; status_prompt_clear(c); status_message_clear(c); @@ -577,10 +580,25 @@ status_message_set(struct client *c, const char *fmt, ...) xvasprintf(&c->message_string, fmt, ap); va_end(ap); + ARRAY_EXPAND(&c->message_log, 1); + msg = &ARRAY_LAST(&c->message_log); + msg->msg_time = time(NULL); + msg->msg = xstrdup(c->message_string); + + if (s == NULL) + limit = 0; + else + limit = options_get_number(&s->options, "message-limit"); + for (i = ARRAY_LENGTH(&c->message_log); i > limit; i--) { + msg = &ARRAY_ITEM(&c->message_log, i - 1); + xfree(msg->msg); + ARRAY_REMOVE(&c->message_log, i - 1); + } + delay = options_get_number(&c->session->options, "display-time"); tv.tv_sec = delay / 1000; tv.tv_usec = (delay % 1000) * 1000L; - + evtimer_del(&c->message_timer); evtimer_set(&c->message_timer, status_message_callback, c); evtimer_add(&c->message_timer, &tv); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 8e74a3026a6..261b083ef0a 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.119 2009/11/18 10:18:25 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.120 2009/11/18 13:16:33 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -454,6 +454,16 @@ with .D1 (alias: Ic rename ) Rename the session to .Ar new-name . +.It Xo Ic show-messages +.Op Fl t Ar target-client +.Xc +.D1 (alias: Ic showmsgs ) +Any messages displayed on the status line are saved in a per-client message +log, up to a maximum of the limit set by the +.Ar message-limit +session option for the session attached to that client. +This command displays the log for +.Ar target-client . .It Ic source-file Ar path .D1 (alias: Ic source ) Execute commands from @@ -1373,6 +1383,10 @@ from the 256-colour palette, or .Ic default . .It Ic message-fg Ar colour Set status line message foreground colour. +.It Ic message-limit Ar number +Set the number of error or information messages to save in the message log for +each client. +The default is 20. .It Xo Ic mouse-select-pane .Op Ic on | off .Xc diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 62a983063c1..d9872a72d54 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.57 2009/11/10 18:53:11 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.58 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -332,6 +332,7 @@ main(int argc, char **argv) options_set_number(so, "message-attr", 0); options_set_number(so, "message-bg", 3); options_set_number(so, "message-fg", 0); + options_set_number(so, "message-limit", 20); options_set_number(so, "mouse-select-pane", 0); options_set_number(so, "repeat-time", 500); options_set_number(so, "set-remain-on-exit", 0); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index bdf016115e1..45644600d89 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.179 2009/11/13 19:58:32 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.180 2009/11/18 13:16:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1041,6 +1041,12 @@ struct mouse_event { u_char y; }; +/* Saved message entry. */ +struct message_entry { + char *msg; + time_t msg_time; +}; + /* Client connection. */ struct client { struct imsgbuf ibuf; @@ -1077,6 +1083,7 @@ struct client { char *message_string; struct event message_timer; + ARRAY_DECL(, struct message_entry) message_log; char *prompt_string; char *prompt_buffer; @@ -1481,6 +1488,7 @@ extern const struct cmd_entry cmd_set_option_entry; extern const struct cmd_entry cmd_set_window_option_entry; extern const struct cmd_entry cmd_show_buffer_entry; extern const struct cmd_entry cmd_show_environment_entry; +extern const struct cmd_entry cmd_show_messages_entry; extern const struct cmd_entry cmd_show_options_entry; extern const struct cmd_entry cmd_show_window_options_entry; extern const struct cmd_entry cmd_source_file_entry; |