mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each pane.
This commit is contained in:
parent
8102ec3be5
commit
04319964b9
2
Makefile
2
Makefile
@ -26,7 +26,7 @@ SRCS= attributes.c buffer-poll.c buffer.c cfg.c client-fn.c \
|
|||||||
cmd-suspend-client.c cmd-swap-pane.c cmd-swap-window.c \
|
cmd-suspend-client.c cmd-swap-pane.c cmd-swap-window.c \
|
||||||
cmd-switch-client.c cmd-unbind-key.c cmd-unlink-window.c \
|
cmd-switch-client.c cmd-unbind-key.c cmd-unlink-window.c \
|
||||||
cmd-set-environment.c cmd-show-environment.c cmd-choose-client.c \
|
cmd-set-environment.c cmd-show-environment.c cmd-choose-client.c \
|
||||||
cmd-up-pane.c cmd-display-message.c cmd.c \
|
cmd-up-pane.c cmd-display-message.c cmd-display-panes.c cmd.c \
|
||||||
colour.c environ.c grid-view.c grid.c input-keys.c \
|
colour.c environ.c grid-view.c grid.c input-keys.c \
|
||||||
imsg.c imsg-buffer.c input.c key-bindings.c key-string.c \
|
imsg.c imsg-buffer.c input.c key-bindings.c key-string.c \
|
||||||
layout-set.c layout.c log.c \
|
layout-set.c layout.c log.c \
|
||||||
|
52
cmd-display-panes.c
Normal file
52
cmd-display-panes.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
@ -56,6 +56,8 @@ const struct set_option_entry set_option_table[] = {
|
|||||||
{ "default-command", SET_OPTION_STRING, 0, 0, NULL },
|
{ "default-command", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "default-terminal", 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 },
|
{ "display-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
|
||||||
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "history-limit", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "lock-after-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
|
1
cmd.c
1
cmd.c
@ -43,6 +43,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_delete_buffer_entry,
|
&cmd_delete_buffer_entry,
|
||||||
&cmd_detach_client_entry,
|
&cmd_detach_client_entry,
|
||||||
&cmd_display_message_entry,
|
&cmd_display_message_entry,
|
||||||
|
&cmd_display_panes_entry,
|
||||||
&cmd_down_pane_entry,
|
&cmd_down_pane_entry,
|
||||||
&cmd_find_window_entry,
|
&cmd_find_window_entry,
|
||||||
&cmd_has_session_entry,
|
&cmd_has_session_entry,
|
||||||
|
@ -137,6 +137,7 @@ key_bindings_init(void)
|
|||||||
{ 'n', 0, &cmd_next_window_entry },
|
{ 'n', 0, &cmd_next_window_entry },
|
||||||
{ 'o', 0, &cmd_down_pane_entry },
|
{ 'o', 0, &cmd_down_pane_entry },
|
||||||
{ 'p', 0, &cmd_previous_window_entry },
|
{ 'p', 0, &cmd_previous_window_entry },
|
||||||
|
{ 'q', 0, &cmd_display_panes_entry },
|
||||||
{ 'r', 0, &cmd_refresh_client_entry },
|
{ 'r', 0, &cmd_refresh_client_entry },
|
||||||
{ 's', 0, &cmd_choose_session_entry },
|
{ 's', 0, &cmd_choose_session_entry },
|
||||||
{ 't', 0, &cmd_clock_mode_entry },
|
{ 't', 0, &cmd_clock_mode_entry },
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
int screen_redraw_cell_border(struct client *, u_int, u_int);
|
int screen_redraw_cell_border(struct client *, u_int, u_int);
|
||||||
int screen_redraw_check_cell(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_INSIDE 0
|
||||||
#define CELL_LEFTRIGHT 1
|
#define CELL_LEFTRIGHT 1
|
||||||
@ -210,6 +211,8 @@ screen_redraw_screen(struct client *c, int status_only)
|
|||||||
continue;
|
continue;
|
||||||
tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff);
|
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. */
|
/* 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_draw_line(&c->tty, wp->screen, i, wp->xoff, wp->yoff);
|
||||||
tty_reset(&c->tty);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
29
server-fn.c
29
server-fn.c
@ -263,3 +263,32 @@ server_kill_window(struct window *w)
|
|||||||
}
|
}
|
||||||
recalculate_sizes();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
4
server.c
4
server.c
@ -632,6 +632,9 @@ server_check_timers(struct client *c)
|
|||||||
if (gettimeofday(&tv, NULL) != 0)
|
if (gettimeofday(&tv, NULL) != 0)
|
||||||
fatal("gettimeofday");
|
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, >))
|
if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >))
|
||||||
status_message_clear(c);
|
status_message_clear(c);
|
||||||
|
|
||||||
@ -809,6 +812,7 @@ server_handle_client(struct client *c)
|
|||||||
wp = c->session->curw->window->active; /* could die */
|
wp = c->session->curw->window->active; /* could die */
|
||||||
|
|
||||||
status_message_clear(c);
|
status_message_clear(c);
|
||||||
|
server_clear_identify(c);
|
||||||
if (c->prompt_string != NULL) {
|
if (c->prompt_string != NULL) {
|
||||||
status_prompt_key(c, key);
|
status_prompt_key(c, key);
|
||||||
continue;
|
continue;
|
||||||
|
7
status.c
7
status.c
@ -541,13 +541,14 @@ status_message_set(struct client *c, const char *fmt, ...)
|
|||||||
status_prompt_clear(c);
|
status_prompt_clear(c);
|
||||||
status_message_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");
|
delay = options_get_number(&c->session->options, "display-time");
|
||||||
tv.tv_sec = delay / 1000;
|
tv.tv_sec = delay / 1000;
|
||||||
tv.tv_usec = (delay % 1000) * 1000L;
|
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)
|
if (gettimeofday(&c->message_timer, NULL) != 0)
|
||||||
fatal("gettimeofday");
|
fatal("gettimeofday");
|
||||||
timeradd(&c->message_timer, &tv, &c->message_timer);
|
timeradd(&c->message_timer, &tv, &c->message_timer);
|
||||||
|
20
tmux.1
20
tmux.1
@ -675,6 +675,15 @@ If
|
|||||||
is not given, "select-window -t '%%'" is used.
|
is not given, "select-window -t '%%'" is used.
|
||||||
This command works only from inside
|
This command works only from inside
|
||||||
.Nm .
|
.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
|
.It Ic down-pane Op Fl t Ar target-pane
|
||||||
.D1 (alias: Ic downp )
|
.D1 (alias: Ic downp )
|
||||||
Move down a pane.
|
Move down a pane.
|
||||||
@ -1157,8 +1166,17 @@ to work correctly, this
|
|||||||
be set to
|
be set to
|
||||||
.Ql screen
|
.Ql screen
|
||||||
or a derivative of it.
|
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
|
.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
|
.Ar time
|
||||||
is in milliseconds.
|
is in milliseconds.
|
||||||
.It Ic history-limit Ar lines
|
.It Ic history-limit Ar lines
|
||||||
|
2
tmux.c
2
tmux.c
@ -347,6 +347,8 @@ main(int argc, char **argv)
|
|||||||
options_set_number(&global_s_options, "buffer-limit", 9);
|
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-command", "%s", "");
|
||||||
options_set_string(&global_s_options, "default-terminal", "screen");
|
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, "display-time", 750);
|
||||||
options_set_number(&global_s_options, "history-limit", 2000);
|
options_set_number(&global_s_options, "history-limit", 2000);
|
||||||
options_set_number(&global_s_options, "lock-after-time", 0);
|
options_set_number(&global_s_options, "lock-after-time", 0);
|
||||||
|
8
tmux.h
8
tmux.h
@ -935,8 +935,11 @@ struct client {
|
|||||||
#define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
|
#define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
|
||||||
#define CLIENT_SUSPENDED 0x40
|
#define CLIENT_SUSPENDED 0x40
|
||||||
#define CLIENT_BAD 0x80
|
#define CLIENT_BAD 0x80
|
||||||
|
#define CLIENT_IDENTIFY 0x100
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
struct timeval identify_timer;
|
||||||
|
|
||||||
char *message_string;
|
char *message_string;
|
||||||
struct timeval message_timer;
|
struct timeval message_timer;
|
||||||
|
|
||||||
@ -1164,6 +1167,7 @@ void environ_update(const char *, struct environ *, struct environ *);
|
|||||||
|
|
||||||
/* tty.c */
|
/* tty.c */
|
||||||
u_char tty_get_acs(struct tty *, u_char);
|
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_reset(struct tty *);
|
||||||
void tty_region(struct tty *, u_int, u_int, u_int);
|
void tty_region(struct tty *, u_int, u_int, u_int);
|
||||||
void tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
|
void tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
|
||||||
@ -1249,6 +1253,7 @@ void paste_add(struct paste_stack *, char *, u_int);
|
|||||||
int paste_replace(struct paste_stack *, u_int, char *);
|
int paste_replace(struct paste_stack *, u_int, char *);
|
||||||
|
|
||||||
/* clock.c */
|
/* clock.c */
|
||||||
|
extern const char clock_table[14][5][5];
|
||||||
void clock_draw(struct screen_write_ctx *, u_int, int);
|
void clock_draw(struct screen_write_ctx *, u_int, int);
|
||||||
|
|
||||||
/* cmd.c */
|
/* cmd.c */
|
||||||
@ -1285,6 +1290,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_delete_buffer_entry;
|
||||||
extern const struct cmd_entry cmd_detach_client_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_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_down_pane_entry;
|
||||||
extern const struct cmd_entry cmd_find_window_entry;
|
extern const struct cmd_entry cmd_find_window_entry;
|
||||||
extern const struct cmd_entry cmd_has_session_entry;
|
extern const struct cmd_entry cmd_has_session_entry;
|
||||||
@ -1435,6 +1441,8 @@ void server_status_window(struct window *);
|
|||||||
void server_lock(void);
|
void server_lock(void);
|
||||||
int server_unlock(const char *);
|
int server_unlock(const char *);
|
||||||
void server_kill_window(struct window *);
|
void server_kill_window(struct window *);
|
||||||
|
void server_set_identify(struct client *);
|
||||||
|
void server_clear_identify(struct client *);
|
||||||
|
|
||||||
/* status.c */
|
/* status.c */
|
||||||
int status_redraw(struct client *);
|
int status_redraw(struct client *);
|
||||||
|
1
tty.c
1
tty.c
@ -34,7 +34,6 @@ void tty_raw(struct tty *, const char *);
|
|||||||
int tty_try_256(struct tty *, u_char, const char *);
|
int tty_try_256(struct tty *, u_char, const char *);
|
||||||
int tty_try_88(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_fg(struct tty *, const struct grid_cell *);
|
||||||
void tty_attributes_bg(struct tty *, const struct grid_cell *);
|
void tty_attributes_bg(struct tty *, const struct grid_cell *);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user