mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Sync OpenBSD patchset 597:
Options to set the colour of the pane borders, with different colours for the active pane.
This commit is contained in:
parent
97c40b1f37
commit
106011aa53
@ -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 <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);
|
||||
}
|
||||
|
@ -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 <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);
|
||||
}
|
||||
|
@ -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 <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 },
|
||||
|
@ -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 <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);
|
||||
}
|
||||
|
@ -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 <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;
|
||||
|
@ -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 <nicm@users.sourceforge.net>
|
||||
@ -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. */
|
||||
|
17
server-fn.c
17
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 <nicm@users.sourceforge.net>
|
||||
@ -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)
|
||||
{
|
||||
|
10
tmux.1
10
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 <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
|
||||
|
6
tmux.c
6
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 <nicm@users.sourceforge.net>
|
||||
@ -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);
|
||||
|
6
tmux.h
6
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 <nicm@users.sourceforge.net>
|
||||
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user