mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		@@ -200,6 +200,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
		status_timer_start_all();
 | 
			
		||||
	if (strcmp(oe->name, "monitor-silence") == 0)
 | 
			
		||||
		alerts_reset_all();
 | 
			
		||||
	if (strcmp(oe->name, "window-style") == 0 ||
 | 
			
		||||
	    strcmp(oe->name, "window-active-style") == 0) {
 | 
			
		||||
		RB_FOREACH(w, windows, &windows)
 | 
			
		||||
			w->flags |= WINDOW_STYLECHANGED;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* When the pane-border-status option has been changed, resize panes. */
 | 
			
		||||
	if (strcmp(oe->name, "pane-border-status") == 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,8 @@ static void	screen_write_initctx(struct screen_write_ctx *,
 | 
			
		||||
static void	screen_write_save_last(struct screen_write_ctx *,
 | 
			
		||||
		    struct tty_ctx *);
 | 
			
		||||
 | 
			
		||||
static void	screen_write_overwrite(struct screen_write_ctx *, u_int);
 | 
			
		||||
static int	screen_write_overwrite(struct screen_write_ctx *,
 | 
			
		||||
		    struct grid_cell *, u_int);
 | 
			
		||||
static int	screen_write_combine(struct screen_write_ctx *,
 | 
			
		||||
		    const struct utf8_data *);
 | 
			
		||||
 | 
			
		||||
@@ -917,8 +918,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
	struct grid		*gd = s->grid;
 | 
			
		||||
	struct tty_ctx		 ttyctx;
 | 
			
		||||
	u_int		 	 width, xx, last;
 | 
			
		||||
	struct grid_cell 	 tmp_gc;
 | 
			
		||||
	int			 insert;
 | 
			
		||||
	struct grid_cell 	 tmp_gc, now_gc;
 | 
			
		||||
	int			 insert, skip, selected;
 | 
			
		||||
 | 
			
		||||
	/* Ignore padding. */
 | 
			
		||||
	if (gc->flags & GRID_FLAG_PADDING)
 | 
			
		||||
@@ -947,9 +948,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Initialise the redraw context, saving the last cell. */
 | 
			
		||||
	/* Initialise the redraw context. */
 | 
			
		||||
	screen_write_initctx(ctx, &ttyctx);
 | 
			
		||||
	screen_write_save_last(ctx, &ttyctx);
 | 
			
		||||
 | 
			
		||||
	/* If in insert mode, make space for the cells. */
 | 
			
		||||
	if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) {
 | 
			
		||||
@@ -958,11 +958,13 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
		insert = 1;
 | 
			
		||||
	} else
 | 
			
		||||
		insert = 0;
 | 
			
		||||
	skip = !insert;
 | 
			
		||||
 | 
			
		||||
	/* Check this will fit on the current line and wrap if not. */
 | 
			
		||||
	if ((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width) {
 | 
			
		||||
		screen_write_linefeed(ctx, 1);
 | 
			
		||||
		s->cx = 0;	/* carriage return */
 | 
			
		||||
		skip = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Sanity check cursor position. */
 | 
			
		||||
@@ -970,17 +972,26 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Handle overwriting of UTF-8 characters. */
 | 
			
		||||
	screen_write_overwrite(ctx, width);
 | 
			
		||||
	grid_view_get_cell(gd, s->cx, s->cy, &now_gc);
 | 
			
		||||
	if (screen_write_overwrite(ctx, &now_gc, width))
 | 
			
		||||
		skip = 0;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * If the new character is UTF-8 wide, fill in padding cells. Have
 | 
			
		||||
	 * already ensured there is enough room.
 | 
			
		||||
	 */
 | 
			
		||||
	for (xx = s->cx + 1; xx < s->cx + width; xx++)
 | 
			
		||||
	for (xx = s->cx + 1; xx < s->cx + width; xx++) {
 | 
			
		||||
		grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
 | 
			
		||||
		skip = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* If no change, do not draw. */
 | 
			
		||||
	if (skip)
 | 
			
		||||
		skip = (memcmp(&now_gc, gc, sizeof now_gc) == 0);
 | 
			
		||||
 | 
			
		||||
	/* Set the cell. */
 | 
			
		||||
	grid_view_set_cell(gd, s->cx, s->cy, gc);
 | 
			
		||||
	if (!skip)
 | 
			
		||||
		grid_view_set_cell(gd, s->cx, s->cy, gc);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Move the cursor. If not wrapping, stick at the last character and
 | 
			
		||||
@@ -992,12 +1003,23 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
	else
 | 
			
		||||
		s->cx = screen_size_x(s) - last;
 | 
			
		||||
 | 
			
		||||
	/* Draw to the screen if necessary. */
 | 
			
		||||
	/* Create space for character in insert mode. */
 | 
			
		||||
	if (insert) {
 | 
			
		||||
		ttyctx.num = width;
 | 
			
		||||
		tty_write(tty_cmd_insertcharacter, &ttyctx);
 | 
			
		||||
	}
 | 
			
		||||
	if (screen_check_selection(s, s->cx - width, s->cy)) {
 | 
			
		||||
 | 
			
		||||
	/* Check if this is selected. */
 | 
			
		||||
	selected = screen_check_selection(s, s->cx - width, s->cy);
 | 
			
		||||
	if (selected)
 | 
			
		||||
		skip = 0;
 | 
			
		||||
 | 
			
		||||
	/* Save last cell if it will be needed. */
 | 
			
		||||
	if (!skip && ctx->wp != NULL && ttyctx.ocx > ctx->wp->sx - width)
 | 
			
		||||
		screen_write_save_last(ctx, &ttyctx);
 | 
			
		||||
 | 
			
		||||
	/* Write to the screen. */
 | 
			
		||||
	if (selected) {
 | 
			
		||||
		memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc);
 | 
			
		||||
		utf8_copy(&tmp_gc.data, &gc->data);
 | 
			
		||||
		tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET;
 | 
			
		||||
@@ -1009,7 +1031,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
 | 
			
		||||
		    (GRID_FLAG_FG256|GRID_FLAG_BG256);
 | 
			
		||||
		ttyctx.cell = &tmp_gc;
 | 
			
		||||
		tty_write(tty_cmd_cell, &ttyctx);
 | 
			
		||||
	} else {
 | 
			
		||||
	} else if (!skip) {
 | 
			
		||||
		ttyctx.cell = gc;
 | 
			
		||||
		tty_write(tty_cmd_cell, &ttyctx);
 | 
			
		||||
	}
 | 
			
		||||
@@ -1057,16 +1079,17 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud)
 | 
			
		||||
 * character, it is necessary to also overwrite any other cells which covered
 | 
			
		||||
 * by the same character.
 | 
			
		||||
 */
 | 
			
		||||
static void
 | 
			
		||||
screen_write_overwrite(struct screen_write_ctx *ctx, u_int width)
 | 
			
		||||
static int
 | 
			
		||||
screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
 | 
			
		||||
    u_int width)
 | 
			
		||||
{
 | 
			
		||||
	struct screen		*s = ctx->s;
 | 
			
		||||
	struct grid		*gd = s->grid;
 | 
			
		||||
	struct grid_cell	 gc;
 | 
			
		||||
	struct grid_cell	 tmp_gc;
 | 
			
		||||
	u_int			 xx;
 | 
			
		||||
	int			 done = 0;
 | 
			
		||||
 | 
			
		||||
	grid_view_get_cell(gd, s->cx, s->cy, &gc);
 | 
			
		||||
	if (gc.flags & GRID_FLAG_PADDING) {
 | 
			
		||||
	if (gc->flags & GRID_FLAG_PADDING) {
 | 
			
		||||
		/*
 | 
			
		||||
		 * A padding cell, so clear any following and leading padding
 | 
			
		||||
		 * cells back to the character. Don't overwrite the current
 | 
			
		||||
@@ -1074,27 +1097,33 @@ screen_write_overwrite(struct screen_write_ctx *ctx, u_int width)
 | 
			
		||||
		 */
 | 
			
		||||
		xx = s->cx + 1;
 | 
			
		||||
		while (--xx > 0) {
 | 
			
		||||
			grid_view_get_cell(gd, xx, s->cy, &gc);
 | 
			
		||||
			if (~gc.flags & GRID_FLAG_PADDING)
 | 
			
		||||
			grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
 | 
			
		||||
			if (~tmp_gc.flags & GRID_FLAG_PADDING)
 | 
			
		||||
				break;
 | 
			
		||||
			grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Overwrite the character at the start of this padding. */
 | 
			
		||||
		grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
 | 
			
		||||
		done = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Overwrite any padding cells that belong to a UTF-8 character
 | 
			
		||||
	 * we'll be overwriting with the current character.
 | 
			
		||||
	 */
 | 
			
		||||
	xx = s->cx + width - 1;
 | 
			
		||||
	while (++xx < screen_size_x(s)) {
 | 
			
		||||
		grid_view_get_cell(gd, xx, s->cy, &gc);
 | 
			
		||||
		if (~gc.flags & GRID_FLAG_PADDING)
 | 
			
		||||
			break;
 | 
			
		||||
		grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
 | 
			
		||||
	if (gc->data.width != 1 || gc->flags & GRID_FLAG_PADDING) {
 | 
			
		||||
		xx = s->cx + width - 1;
 | 
			
		||||
		while (++xx < screen_size_x(s)) {
 | 
			
		||||
			grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
 | 
			
		||||
			if (~tmp_gc.flags & GRID_FLAG_PADDING)
 | 
			
		||||
				break;
 | 
			
		||||
			grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
 | 
			
		||||
			done = 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (done);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							@@ -945,10 +945,14 @@ struct window {
 | 
			
		||||
#define WINDOW_ZOOMED 0x1000
 | 
			
		||||
#define WINDOW_FORCEWIDTH 0x2000
 | 
			
		||||
#define WINDOW_FORCEHEIGHT 0x4000
 | 
			
		||||
#define WINDOW_STYLECHANGED 0x8000
 | 
			
		||||
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
 | 
			
		||||
 | 
			
		||||
	struct options	*options;
 | 
			
		||||
 | 
			
		||||
	struct grid_cell style;
 | 
			
		||||
	struct grid_cell active_style;
 | 
			
		||||
 | 
			
		||||
	u_int		 references;
 | 
			
		||||
 | 
			
		||||
	RB_ENTRY(window) entry;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										42
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								tty.c
									
									
									
									
									
								
							@@ -676,7 +676,8 @@ tty_fake_bce(const struct tty *tty, const struct window_pane *wp)
 | 
			
		||||
	struct grid_cell	gc;
 | 
			
		||||
 | 
			
		||||
	memcpy(&gc, &grid_default_cell, sizeof gc);
 | 
			
		||||
	tty_default_colours(&gc, wp);
 | 
			
		||||
	if (wp != NULL)
 | 
			
		||||
		tty_default_colours(&gc, wp);
 | 
			
		||||
 | 
			
		||||
	if (gc.bg == 8 && !(gc.flags & GRID_FLAG_BG256))
 | 
			
		||||
		return (0);
 | 
			
		||||
@@ -1133,10 +1134,10 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
	struct window_pane	*wp = ctx->wp;
 | 
			
		||||
	struct screen		*s = wp->screen;
 | 
			
		||||
	u_int			 cx;
 | 
			
		||||
	u_int			 width;
 | 
			
		||||
	u_int			 cx, width;
 | 
			
		||||
 | 
			
		||||
	tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
 | 
			
		||||
	if (ctx->ocy == ctx->orlower)
 | 
			
		||||
		tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
 | 
			
		||||
 | 
			
		||||
	/* Is the cursor in the very last position? */
 | 
			
		||||
	width = ctx->cell->data.width;
 | 
			
		||||
@@ -1345,7 +1346,7 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
 | 
			
		||||
		 */
 | 
			
		||||
 | 
			
		||||
		/* To left edge. */
 | 
			
		||||
		if (cx == 0)	{
 | 
			
		||||
		if (cx == 0) {
 | 
			
		||||
			tty_putc(tty, '\r');
 | 
			
		||||
			goto out;
 | 
			
		||||
		}
 | 
			
		||||
@@ -1373,6 +1374,11 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
 | 
			
		||||
			tty_putcode1(tty, TTYC_HPA, cx);
 | 
			
		||||
			goto out;
 | 
			
		||||
		} else if (change > 0 && tty_term_has(term, TTYC_CUB)) {
 | 
			
		||||
			if (change == 2 && tty_term_has(term, TTYC_CUB1)) {
 | 
			
		||||
				tty_putcode(tty, TTYC_CUB1);
 | 
			
		||||
				tty_putcode(tty, TTYC_CUB1);
 | 
			
		||||
				goto out;
 | 
			
		||||
			}
 | 
			
		||||
			tty_putcode1(tty, TTYC_CUB, change);
 | 
			
		||||
			goto out;
 | 
			
		||||
		} else if (change < 0 && tty_term_has(term, TTYC_CUF)) {
 | 
			
		||||
@@ -1438,7 +1444,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
 | 
			
		||||
	u_char			 changed;
 | 
			
		||||
 | 
			
		||||
	memcpy(&gc2, gc, sizeof gc2);
 | 
			
		||||
	tty_default_colours(&gc2, wp);
 | 
			
		||||
	if (wp != NULL)
 | 
			
		||||
		tty_default_colours(&gc2, wp);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * If no setab, try to use the reverse attribute as a best-effort for a
 | 
			
		||||
@@ -1788,20 +1795,27 @@ tty_try_rgb(struct tty *tty, const struct grid_cell_rgb *rgb, const char *type)
 | 
			
		||||
void
 | 
			
		||||
tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
 | 
			
		||||
{
 | 
			
		||||
	const struct grid_cell        *agc, *pgc, *wgc;
 | 
			
		||||
 | 
			
		||||
	if (wp == NULL)
 | 
			
		||||
		return;
 | 
			
		||||
	struct window		*w = wp->window;
 | 
			
		||||
	struct options		*oo = w->options;
 | 
			
		||||
	const struct grid_cell	*agc, *pgc, *wgc;
 | 
			
		||||
 | 
			
		||||
	if (w->flags & WINDOW_STYLECHANGED) {
 | 
			
		||||
		w->flags &= ~WINDOW_STYLECHANGED;
 | 
			
		||||
		agc = options_get_style(oo, "window-active-style");
 | 
			
		||||
		memcpy(&w->active_style, agc, sizeof w->active_style);
 | 
			
		||||
		wgc = options_get_style(oo, "window-style");
 | 
			
		||||
		memcpy(&w->style, wgc, sizeof w->style);
 | 
			
		||||
	} else {
 | 
			
		||||
		agc = &w->active_style;
 | 
			
		||||
		wgc = &w->style;
 | 
			
		||||
	}
 | 
			
		||||
	pgc = &wp->colgc;
 | 
			
		||||
	agc = options_get_style(wp->window->options, "window-active-style");
 | 
			
		||||
	wgc = options_get_style(wp->window->options, "window-style");
 | 
			
		||||
 | 
			
		||||
	if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) {
 | 
			
		||||
		if (pgc->fg != 8 || (pgc->flags & GRID_FLAG_FG256)) {
 | 
			
		||||
			gc->fg = pgc->fg;
 | 
			
		||||
			gc->flags |= (pgc->flags & GRID_FLAG_FG256);
 | 
			
		||||
		} else if (wp == wp->window->active &&
 | 
			
		||||
		} else if (wp == w->active &&
 | 
			
		||||
		    (agc->fg != 8 || (agc->flags & GRID_FLAG_FG256))) {
 | 
			
		||||
			gc->fg = agc->fg;
 | 
			
		||||
			gc->flags |= (agc->flags & GRID_FLAG_FG256);
 | 
			
		||||
@@ -1815,7 +1829,7 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
 | 
			
		||||
		if (pgc->bg != 8 || (pgc->flags & GRID_FLAG_BG256)) {
 | 
			
		||||
			gc->bg = pgc->bg;
 | 
			
		||||
			gc->flags |= (pgc->flags & GRID_FLAG_BG256);
 | 
			
		||||
		} else if (wp == wp->window->active &&
 | 
			
		||||
		} else if (wp == w->active &&
 | 
			
		||||
		    (agc->bg != 8 || (agc->flags & GRID_FLAG_BG256))) {
 | 
			
		||||
			gc->bg = agc->bg;
 | 
			
		||||
			gc->flags |= (agc->flags & GRID_FLAG_BG256);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user