mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Options to set the colour of the pane borders, with different colours for the
active pane.
This commit is contained in:
		| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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 }, | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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. */ | ||||
|   | ||||
							
								
								
									
										15
									
								
								server-fn.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								server-fn.c
									
									
									
									
									
								
							| @@ -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) | ||||
| { | ||||
|   | ||||
							
								
								
									
										6
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								tmux.1
									
									
									
									
									
								
							| @@ -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 | ||||
|   | ||||
							
								
								
									
										4
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.c
									
									
									
									
									
								
							| @@ -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); | ||||
|   | ||||
							
								
								
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -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 */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott