diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-03 12:51:06 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-03 12:51:06 +0000 |
commit | 753fb84f15e11c44c8685795d7b697f140220545 (patch) | |
tree | 6d6836155398fe3c2436d3dd69f9ae8dd4fac687 /usr.bin/tmux | |
parent | cf7a04fc89256d70368808863280c114fa14cddc (diff) |
Options to set the colour of the pane borders, with different colours for the
active pane.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-down-pane.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-select-pane.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-up-pane.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 99 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 17 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 10 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 |
10 files changed, 117 insertions, 49 deletions
diff --git a/usr.bin/tmux/cmd-down-pane.c b/usr.bin/tmux/cmd-down-pane.c index c7f573f8e65..59697f18759 100644 --- a/usr.bin/tmux/cmd-down-pane.c +++ b/usr.bin/tmux/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-down-pane.c,v 1.7 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-down-pane.c,v 1.8 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -54,6 +54,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_FIRST(&w->panes); } while (!window_pane_visible(w->active)); server_status_window(wl->window); + server_redraw_window_borders(wl->window); return (0); } diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c index 800e910b32f..ce151111170 100644 --- a/usr.bin/tmux/cmd-select-pane.c +++ b/usr.bin/tmux/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-pane.c,v 1.8 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-select-pane.c,v 1.9 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -53,6 +53,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } window_set_active_pane(wl->window, wp); server_status_window(wl->window); + server_redraw_window_borders(wl->window); return (0); } diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index d9b9eeadd30..6c08a8c8c63 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.31 2009/12/14 10:43:41 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.32 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -99,6 +99,10 @@ const struct set_option_entry set_session_option_table[] = { { "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 }, + { "pane-active-border-bg", SET_OPTION_COLOUR, 0, 0, NULL }, + { "pane-active-border-fg", SET_OPTION_COLOUR, 0, 0, NULL }, + { "pane-border-bg", SET_OPTION_COLOUR, 0, 0, NULL }, + { "pane-border-fg", SET_OPTION_COLOUR, 0, 0, NULL }, { "prefix", SET_OPTION_KEYS, 0, 0, NULL }, { "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL }, { "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL }, diff --git a/usr.bin/tmux/cmd-up-pane.c b/usr.bin/tmux/cmd-up-pane.c index cbe572d2c1c..297857efd24 100644 --- a/usr.bin/tmux/cmd-up-pane.c +++ b/usr.bin/tmux/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-up-pane.c,v 1.7 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-up-pane.c,v 1.8 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -54,6 +54,7 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_LAST(&w->panes, window_panes); } while (!window_pane_visible(w->active)); server_status_window(wl->window); + server_redraw_window_borders(wl->window); return (0); } diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index c89d5fb2967..1de8d0f101e 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.14 2009/12/03 22:50:10 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.15 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -22,6 +22,7 @@ #include "tmux.h" +int screen_redraw_cell_border1(struct window_pane *, 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); void screen_redraw_draw_number(struct client *, struct window_pane *); @@ -40,40 +41,49 @@ void screen_redraw_draw_number(struct client *, struct window_pane *); #define CELL_JOIN 11 #define CELL_OUTSIDE 12 +/* Check if cell is on the border of a particular pane. */ +int +screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py) +{ + /* Inside pane. */ + if (px >= wp->xoff && px < wp->xoff + wp->sx && + py >= wp->yoff && py < wp->yoff + wp->sy) + return (0); + + /* Left/right borders. */ + if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= wp->yoff + wp->sy) { + if (wp->xoff != 0 && px == wp->xoff - 1) + return (1); + if (px == wp->xoff + wp->sx) + return (1); + } + + /* Top/bottom borders. */ + if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= wp->xoff + wp->sx) { + if (wp->yoff != 0 && py == wp->yoff - 1) + return (1); + if (py == wp->yoff + wp->sy) + return (1); + } + + /* Outside pane. */ + return (-1); +} + /* Check if a cell is on the pane border. */ int screen_redraw_cell_border(struct client *c, u_int px, u_int py) { struct window *w = c->session->curw->window; struct window_pane *wp; + int retval; /* Check all the panes. */ TAILQ_FOREACH(wp, &w->panes, entry) { if (!window_pane_visible(wp)) continue; - - /* Inside pane. */ - if (px >= wp->xoff && px < wp->xoff + wp->sx && - py >= wp->yoff && py < wp->yoff + wp->sy) - return (0); - - /* Left/right borders. */ - if ((wp->yoff == 0 || py >= wp->yoff - 1) && - py <= wp->yoff + wp->sy) { - if (wp->xoff != 0 && px == wp->xoff - 1) - return (1); - if (px == wp->xoff + wp->sx) - return (1); - } - - /* Top/bottom borders. */ - if ((wp->xoff == 0 || px >= wp->xoff - 1) && - px <= wp->xoff + wp->sx) { - if (wp->yoff != 0 && py == wp->yoff - 1) - return (1); - if (py == wp->yoff + wp->sy) - return (1); - } + if ((retval = screen_redraw_cell_border1(wp, px, py)) != -1) + return (retval); } return (0); @@ -155,13 +165,14 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py) /* Redraw entire screen. */ void -screen_redraw_screen(struct client *c, int status_only) +screen_redraw_screen(struct client *c, int status_only, int borders_only) { struct window *w = c->session->curw->window; struct tty *tty = &c->tty; struct window_pane *wp; + struct grid_cell active_gc, other_gc; u_int i, j, type; - int status; + int status, fg, bg; const u_char *base, *ptr; u_char ch, border[20]; @@ -178,8 +189,20 @@ screen_redraw_screen(struct client *c, int status_only) return; } + /* Set up pane border attributes. */ + memcpy(&other_gc, &grid_default_cell, sizeof other_gc); + memcpy(&active_gc, &grid_default_cell, sizeof active_gc); + active_gc.data = other_gc.data = 'x'; /* not space */ + fg = options_get_number(&c->session->options, "pane-border-fg"); + colour_set_fg(&other_gc, fg); + bg = options_get_number(&c->session->options, "pane-border-bg"); + colour_set_bg(&other_gc, bg); + fg = options_get_number(&c->session->options, "pane-active-border-fg"); + colour_set_fg(&active_gc, fg); + bg = options_get_number(&c->session->options, "pane-active-border-bg"); + colour_set_bg(&active_gc, bg); + /* Draw background and borders. */ - tty_reset(tty); strlcpy(border, " |-....--||+.", sizeof border); if (tty_term_has(tty->term, TTYC_ACSC)) { base = " xqlkmjwvtun~"; @@ -187,22 +210,30 @@ screen_redraw_screen(struct client *c, int status_only) if ((ch = tty_get_acs(tty, *ptr)) != '\0') border[ptr - base] = ch; } - tty_putcode(tty, TTYC_SMACS); + other_gc.attr |= GRID_ATTR_CHARSET; + active_gc.attr |= GRID_ATTR_CHARSET; } for (j = 0; j < tty->sy - status; j++) { if (status_only && j != tty->sy - 1) continue; for (i = 0; i < tty->sx; i++) { type = screen_redraw_check_cell(c, i, j); - if (type != CELL_INSIDE) { - tty_cursor(tty, i, j); - tty_putc(tty, border[type]); - } + if (type == CELL_INSIDE) + continue; + if (screen_redraw_cell_border1(w->active, i, j) == 1) + tty_attributes(tty, &active_gc); + else + tty_attributes(tty, &other_gc); + tty_cursor(tty, i, j); + tty_putc(tty, border[type]); } } - tty_putcode(tty, TTYC_RMACS); - /* Draw the panes. */ + /* If only drawing borders, that's it. */ + if (borders_only) + return; + + /* Draw the panes, if necessary. */ TAILQ_FOREACH(wp, &w->panes, entry) { if (!window_pane_visible(wp)) continue; diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 2e33154ec15..93130d06616 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.26 2009/12/10 09:16:52 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.27 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -463,8 +463,8 @@ server_client_check_redraw(struct client *c) } if (c->flags & CLIENT_REDRAW) { - screen_redraw_screen(c, 0); - c->flags &= ~CLIENT_STATUS; + screen_redraw_screen(c, 0, 0); + c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS); } else { TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { if (wp->flags & PANE_REDRAW) @@ -472,12 +472,15 @@ server_client_check_redraw(struct client *c) } } + if (c->flags & CLIENT_BORDERS) + screen_redraw_screen(c, 0, 1); + if (c->flags & CLIENT_STATUS) - screen_redraw_screen(c, 1); + screen_redraw_screen(c, 1, 0); c->tty.flags |= flags; - c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS); + c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS); } /* Set client title. */ diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 8364f314913..47787fad308 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.32 2009/12/22 10:20:08 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.33 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -165,6 +165,21 @@ server_redraw_window(struct window *w) } void +server_redraw_window_borders(struct window *w) +{ + struct client *c; + u_int i; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + if (c->session->curw->window == w) + c->flags |= CLIENT_BORDERS; + } +} + +void server_status_window(struct window *w) { struct session *s; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index e286ee6f192..f7ceb2be07a 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.134 2009/12/14 10:43:41 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.135 2010/01/03 12:51:05 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: December 14 2009 $ +.Dd $Mdocdate: January 3 2010 $ .Dt TMUX 1 .Os .Sh NAME @@ -1457,6 +1457,12 @@ If on, captures the mouse and when a window is split into multiple panes the mouse may be used to select the current pane. The mouse click is also passed through to the application as normal. +.It Ic pane-border-fg Ar colour +.It Ic pane-border-bg Ar colour +Set the pane border colour for panes aside from the active pane. +.It Ic pane-active-border-fg Ar colour +.It Ic pane-active-border-bg Ar colour +Set the pane border colour for the currently active pane. .It Ic prefix Ar keys Set the keys accepted as a prefix key. .Ar keys diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index edff9be2501..951e2f4b858 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.65 2009/12/14 10:43:41 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.66 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -339,6 +339,10 @@ main(int argc, char **argv) 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, "pane-active-border-bg", 2); + options_set_number(so, "pane-active-border-fg", 8); + options_set_number(so, "pane-border-bg", 8); + options_set_number(so, "pane-border-fg", 8); options_set_number(so, "repeat-time", 500); options_set_number(so, "set-remain-on-exit", 0); options_set_number(so, "set-titles", 0); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 4907d3fd30b..259401d0537 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.196 2009/12/17 17:39:56 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.197 2010/01/03 12:51:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1083,6 +1083,7 @@ struct client { #define CLIENT_BAD 0x80 #define CLIENT_IDENTIFY 0x100 #define CLIENT_DEAD 0x200 +#define CLIENT_BORDERS 0x400 int flags; struct event identify_timer; @@ -1589,6 +1590,7 @@ void server_redraw_session_group(struct session *); void server_status_session(struct session *); void server_status_session_group(struct session *); void server_redraw_window(struct window *); +void server_redraw_window_borders(struct window *); void server_status_window(struct window *); void server_lock(void); void server_lock_session(struct session *); @@ -1749,7 +1751,7 @@ void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *, const struct utf8_data *); /* screen-redraw.c */ -void screen_redraw_screen(struct client *, int); +void screen_redraw_screen(struct client *, int, int); void screen_redraw_pane(struct client *, struct window_pane *); /* screen.c */ |