diff options
-rw-r--r-- | cmd-display-panes.c | 52 | ||||
-rw-r--r-- | cmd-set-option.c | 4 | ||||
-rw-r--r-- | cmd.c | 3 | ||||
-rw-r--r-- | key-bindings.c | 3 | ||||
-rw-r--r-- | screen-redraw.c | 58 | ||||
-rw-r--r-- | server-fn.c | 31 | ||||
-rw-r--r-- | server.c | 6 | ||||
-rw-r--r-- | status.c | 9 | ||||
-rw-r--r-- | tmux.1 | 22 | ||||
-rw-r--r-- | tmux.c | 4 | ||||
-rw-r--r-- | tmux.h | 10 | ||||
-rw-r--r-- | tty.c | 3 |
12 files changed, 189 insertions, 16 deletions
diff --git a/cmd-display-panes.c b/cmd-display-panes.c new file mode 100644 index 00000000..f1bf5819 --- /dev/null +++ b/cmd-display-panes.c @@ -0,0 +1,52 @@ +/* $Id: cmd-display-panes.c,v 1.1 2009-08-31 22:30:15 tcunha 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 "tmux.h" + +/* + * Display panes on a client. + */ + +int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_display_panes_entry = { + "display-panes", "displayp", + CMD_TARGET_CLIENT_USAGE, + 0, 0, + cmd_target_init, + cmd_target_parse, + cmd_display_panes_exec, + cmd_target_free, + cmd_target_print +}; + +int +cmd_display_panes_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 (-1); + + server_set_identify(c); + + return (0); +} diff --git a/cmd-set-option.c b/cmd-set-option.c index d938d732..923d58fd 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.76 2009-08-16 19:16:27 tcunha Exp $ */ +/* $Id: cmd-set-option.c,v 1.77 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -56,6 +56,8 @@ const struct set_option_entry set_option_table[] = { { "default-command", SET_OPTION_STRING, 0, 0, NULL }, { "default-path", SET_OPTION_STRING, 0, 0, NULL }, { "default-terminal", SET_OPTION_STRING, 0, 0, NULL }, + { "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL }, + { "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL }, { "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL }, { "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL }, { "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL }, @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.114 2009-08-25 13:53:39 tcunha Exp $ */ +/* $Id: cmd.c,v 1.115 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -42,6 +42,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_delete_buffer_entry, &cmd_detach_client_entry, &cmd_display_message_entry, + &cmd_display_panes_entry, &cmd_down_pane_entry, &cmd_find_window_entry, &cmd_has_session_entry, diff --git a/key-bindings.c b/key-bindings.c index 0c711aa1..5350d7a5 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.81 2009-08-25 13:53:39 tcunha Exp $ */ +/* $Id: key-bindings.c,v 1.82 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -137,6 +137,7 @@ key_bindings_init(void) { 'n', 0, &cmd_next_window_entry }, { 'o', 0, &cmd_down_pane_entry }, { 'p', 0, &cmd_previous_window_entry }, + { 'q', 0, &cmd_display_panes_entry }, { 'r', 0, &cmd_refresh_client_entry }, { 's', 0, &cmd_choose_session_entry }, { 't', 0, &cmd_clock_mode_entry }, diff --git a/screen-redraw.c b/screen-redraw.c index 6d73fc7c..649b8f5f 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,4 +1,4 @@ -/* $Id: screen-redraw.c,v 1.45 2009-08-10 21:41:35 tcunha Exp $ */ +/* $Id: screen-redraw.c,v 1.46 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,6 +24,7 @@ int screen_redraw_cell_border(struct client *, u_int, u_int); int screen_redraw_check_cell(struct client *, u_int, u_int); +void screen_redraw_draw_number(struct client *, struct window_pane *); #define CELL_INSIDE 0 #define CELL_LEFTRIGHT 1 @@ -210,6 +211,8 @@ screen_redraw_screen(struct client *c, int status_only) continue; tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff); } + if (c->flags & CLIENT_IDENTIFY) + screen_redraw_draw_number(c, wp); } /* Draw the status line. */ @@ -228,3 +231,56 @@ screen_redraw_pane(struct client *c, struct window_pane *wp) tty_draw_line(&c->tty, wp->screen, i, wp->xoff, wp->yoff); tty_reset(&c->tty); } + +/* Draw number on a pane. */ +void +screen_redraw_draw_number(struct client *c, struct window_pane *wp) +{ + struct tty *tty = &c->tty; + struct session *s = c->session; + struct grid_cell gc; + u_int idx, px, py, i, j; + u_char colour; + char buf[16], *ptr; + size_t len; + + idx = window_pane_index(wp->window, wp); + len = xsnprintf(buf, sizeof buf, "%u", idx); + + if (wp->sx < len) + return; + colour = options_get_number(&s->options, "display-panes-colour"); + + px = wp->sx / 2; + py = wp->sy / 2; + if (wp->sx < len * 6 || wp->sy < 5) { + tty_cursor(tty, px - len / 2, py, wp->xoff, wp->yoff); + memcpy(&gc, &grid_default_cell, sizeof gc); + gc.fg = colour; + tty_attributes(tty, &gc); + tty_puts(tty, buf); + return; + } + + px -= len * 3; + py -= 2; + + memcpy(&gc, &grid_default_cell, sizeof gc); + gc.bg = colour; + tty_attributes(tty, &gc); + for (ptr = buf; *ptr != '\0'; ptr++) { + if (*ptr < '0' || *ptr > '9') + continue; + idx = *ptr - '0'; + + for (j = 0; j < 5; j++) { + for (i = px; i < px + 5; i++) { + tty_cursor(tty, i, py + j, wp->xoff, wp->yoff); + if (!clock_table[idx][j][i - px]) + continue; + tty_putc(tty, ' '); + } + } + px += 6; + } +} diff --git a/server-fn.c b/server-fn.c index d01c8ab4..74c18a4e 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.81 2009-08-14 21:04:04 tcunha Exp $ */ +/* $Id: server-fn.c,v 1.82 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -263,3 +263,32 @@ server_kill_window(struct window *w) } recalculate_sizes(); } + +void +server_set_identify(struct client *c) +{ + struct timeval tv; + int delay; + + delay = options_get_number(&c->session->options, "display-panes-time"); + tv.tv_sec = delay / 1000; + tv.tv_usec = (delay % 1000) * 1000L; + + if (gettimeofday(&c->identify_timer, NULL) != 0) + fatal("gettimeofday"); + timeradd(&c->identify_timer, &tv, &c->identify_timer); + + c->flags |= CLIENT_IDENTIFY; + c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR); + server_redraw_client(c); +} + +void +server_clear_identify(struct client *c) +{ + if (c->flags & CLIENT_IDENTIFY) { + c->flags &= ~CLIENT_IDENTIFY; + c->tty.flags &= ~(TTY_FREEZE|TTY_NOCURSOR); + server_redraw_client(c); + } +} @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.176 2009-08-31 22:24:18 tcunha Exp $ */ +/* $Id: server.c,v 1.177 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -635,6 +635,9 @@ server_check_timers(struct client *c) if (gettimeofday(&tv, NULL) != 0) fatal("gettimeofday"); + if (c->flags & CLIENT_IDENTIFY && timercmp(&tv, &c->identify_timer, >)) + server_clear_identify(c); + if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >)) status_message_clear(c); @@ -812,6 +815,7 @@ server_handle_client(struct client *c) wp = c->session->curw->window->active; /* could die */ status_message_clear(c); + server_clear_identify(c); if (c->prompt_string != NULL) { status_prompt_key(c, key); continue; @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.112 2009-08-20 11:51:20 tcunha Exp $ */ +/* $Id: status.c,v 1.113 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -541,13 +541,14 @@ status_message_set(struct client *c, const char *fmt, ...) status_prompt_clear(c); status_message_clear(c); + va_start(ap, fmt); + xvasprintf(&c->message_string, fmt, ap); + va_end(ap); + delay = options_get_number(&c->session->options, "display-time"); tv.tv_sec = delay / 1000; tv.tv_usec = (delay % 1000) * 1000L; - va_start(ap, fmt); - xvasprintf(&c->message_string, fmt, ap); - va_end(ap); if (gettimeofday(&c->message_timer, NULL) != 0) fatal("gettimeofday"); timeradd(&c->message_timer, &tv, &c->message_timer); @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.159 2009-08-31 22:25:33 tcunha Exp $ +.\" $Id: tmux.1,v 1.160 2009-08-31 22:30:15 tcunha Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -675,6 +675,15 @@ If is not given, "select-window -t '%%'" is used. This command works only from inside .Nm . +.It Ic display-panes Op Fl t Ar target-client +.D1 (alias: Ic displayp) +Display a visible indicator of each pane shown by +.Ar target-client . +See the +.Ic display-panes-time +and +.Ic display-panes-colour +session options. .It Ic down-pane Op Fl t Ar target-pane .D1 (alias: Ic downp ) Move down a pane. @@ -1157,8 +1166,17 @@ to work correctly, this be set to .Ql screen or a derivative of it. +.It Ic display-panes-colour Ar colour +Set the colour used for the +.Ic display-panes +command. +.It Ic display-panes-time Ar time +Set the time in milliseconds for which the indicators shown by the +.Ic display-panes +command appear. .It Ic display-time Ar time -Set the amount of time for which status line messages are displayed. +Set the amount of time for which status line messages and other on-screen +indicators are displayed. .Ar time is in milliseconds. .It Ic history-limit Ar lines @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.164 2009-08-24 16:35:24 tcunha Exp $ */ +/* $Id: tmux.c,v 1.165 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -356,6 +356,8 @@ main(int argc, char **argv) options_set_number(&global_s_options, "buffer-limit", 9); options_set_string(&global_s_options, "default-command", "%s", ""); options_set_string(&global_s_options, "default-terminal", "screen"); + options_set_number(&global_s_options, "display-panes-colour", 4); + options_set_number(&global_s_options, "display-panes-time", 1000); options_set_number(&global_s_options, "display-time", 750); options_set_number(&global_s_options, "history-limit", 2000); options_set_number(&global_s_options, "lock-after-time", 0); @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.429 2009-08-25 13:53:39 tcunha Exp $ */ +/* $Id: tmux.h,v 1.430 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -933,8 +933,11 @@ struct client { #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */ #define CLIENT_SUSPENDED 0x40 #define CLIENT_BAD 0x80 +#define CLIENT_IDENTIFY 0x100 int flags; + struct timeval identify_timer; + char *message_string; struct timeval message_timer; @@ -1162,6 +1165,7 @@ void environ_update(const char *, struct environ *, struct environ *); /* tty.c */ u_char tty_get_acs(struct tty *, u_char); +void tty_attributes(struct tty *, const struct grid_cell *); void tty_reset(struct tty *); void tty_region(struct tty *, u_int, u_int, u_int); void tty_cursor(struct tty *, u_int, u_int, u_int, u_int); @@ -1247,6 +1251,7 @@ void paste_add(struct paste_stack *, char *, u_int); int paste_replace(struct paste_stack *, u_int, char *); /* clock.c */ +extern const char clock_table[14][5][5]; void clock_draw(struct screen_write_ctx *, u_int, int); /* cmd.c */ @@ -1283,6 +1288,7 @@ extern const struct cmd_entry cmd_copy_mode_entry; extern const struct cmd_entry cmd_delete_buffer_entry; extern const struct cmd_entry cmd_detach_client_entry; extern const struct cmd_entry cmd_display_message_entry; +extern const struct cmd_entry cmd_display_panes_entry; extern const struct cmd_entry cmd_down_pane_entry; extern const struct cmd_entry cmd_find_window_entry; extern const struct cmd_entry cmd_has_session_entry; @@ -1433,6 +1439,8 @@ void server_status_window(struct window *); void server_lock(void); int server_unlock(const char *); void server_kill_window(struct window *); +void server_set_identify(struct client *); +void server_clear_identify(struct client *); /* status.c */ int status_redraw(struct client *); @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.130 2009-08-21 21:15:00 tcunha Exp $ */ +/* $Id: tty.c,v 1.131 2009-08-31 22:30:15 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,7 +34,6 @@ void tty_raw(struct tty *, const char *); int tty_try_256(struct tty *, u_char, const char *); int tty_try_88(struct tty *, u_char, const char *); -void tty_attributes(struct tty *, const struct grid_cell *); void tty_attributes_fg(struct tty *, const struct grid_cell *); void tty_attributes_bg(struct tty *, const struct grid_cell *); |