diff --git a/cmd-down-pane.c b/cmd-down-pane.c index 4d57b096..f436f2b2 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-down-pane.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */ +/* $Id: cmd-down-pane.c,v 1.14 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -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/cmd-select-pane.c b/cmd-select-pane.c index 67b0c777..985db8d9 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-pane.c,v 1.11 2009-11-14 17:56:39 tcunha Exp $ */ +/* $Id: cmd-select-pane.c,v 1.12 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -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/cmd-set-option.c b/cmd-set-option.c index d7ec75db..5f58e8d6 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.92 2009-12-16 01:09:01 tcunha Exp $ */ +/* $Id: cmd-set-option.c,v 1.93 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/cmd-up-pane.c b/cmd-up-pane.c index 0ba91538..43b740bc 100644 --- a/cmd-up-pane.c +++ b/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-up-pane.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */ +/* $Id: cmd-up-pane.c,v 1.14 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -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/screen-redraw.c b/screen-redraw.c index ba694ff8..610cb511 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,4 +1,4 @@ -/* $Id: screen-redraw.c,v 1.50 2009-12-04 22:14:47 tcunha Exp $ */ +/* $Id: screen-redraw.c,v 1.51 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/server-client.c b/server-client.c index e23b1aea..42d7dfba 100644 --- a/server-client.c +++ b/server-client.c @@ -1,4 +1,4 @@ -/* $Id: server-client.c,v 1.27 2009-12-10 16:59:02 tcunha Exp $ */ +/* $Id: server-client.c,v 1.28 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -462,8 +462,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) @@ -471,12 +471,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/server-fn.c b/server-fn.c index f1de20c1..506d73ff 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.100 2009-12-26 23:45:21 tcunha Exp $ */ +/* $Id: server-fn.c,v 1.101 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -164,6 +164,21 @@ server_redraw_window(struct window *w) w->flags |= WINDOW_REDRAW; } +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) { diff --git a/tmux.1 b/tmux.1 index 5bc3109c..0abd181e 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.216 2009-12-16 01:09:01 tcunha Exp $ +.\" $Id: tmux.1,v 1.217 2010-01-05 23:52:37 tcunha Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -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/tmux.c b/tmux.c index c321291a..3666d924 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.196 2009-12-16 01:09:01 tcunha Exp $ */ +/* $Id: tmux.c,v 1.197 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -342,6 +342,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/tmux.h b/tmux.h index 7940f762..93d90b14 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.534 2009-12-18 18:57:00 tcunha Exp $ */ +/* $Id: tmux.h,v 1.535 2010-01-05 23:52:37 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1082,6 +1082,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; @@ -1588,6 +1589,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 *); @@ -1748,7 +1750,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 */