mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	More tty code tidying: move the saved cursor/region position (from before the
screen was updated) out of struct screen and into struct tty_ctx.
This commit is contained in:
		
							
								
								
									
										108
									
								
								screen-write.c
									
									
									
									
									
								
							
							
						
						
									
										108
									
								
								screen-write.c
									
									
									
									
									
								
							| @@ -22,7 +22,7 @@ | ||||
|  | ||||
| #include "tmux.h" | ||||
|  | ||||
| void	screen_write_save(struct screen_write_ctx *); | ||||
| void	screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *); | ||||
| void	screen_write_overwrite(struct screen_write_ctx *); | ||||
|  | ||||
| /* Initialise writing with a window. */ | ||||
| @@ -210,17 +210,19 @@ screen_write_copy(struct screen_write_ctx *ctx, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /* Save cursor and region positions. */ | ||||
| /* Set up context for TTY command. */ | ||||
| void | ||||
| screen_write_save(struct screen_write_ctx *ctx) | ||||
| screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
|  | ||||
| 	s->old_cx = s->cx; | ||||
| 	s->old_cy = s->cy; | ||||
| 	ttyctx->wp = ctx->wp; | ||||
|  | ||||
| 	s->old_rlower = s->rlower; | ||||
| 	s->old_rupper = s->rupper; | ||||
| 	ttyctx->ocx = s->cx; | ||||
| 	ttyctx->ocy = s->cy; | ||||
|  | ||||
| 	ttyctx->orlower = s->rlower; | ||||
| 	ttyctx->orupper = s->rupper; | ||||
| } | ||||
|  | ||||
| /* Cursor up by ny. */ | ||||
| @@ -310,9 +312,12 @@ void | ||||
| screen_write_alignmenttest(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen		*s = ctx->s; | ||||
| 	struct tty_ctx	 	 ttyctx; | ||||
| 	struct grid_cell       	 gc; | ||||
| 	u_int			 xx, yy; | ||||
|  | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	memcpy(&gc, &grid_default_cell, sizeof gc); | ||||
| 	gc.data = 'E'; | ||||
|  | ||||
| @@ -327,7 +332,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx) | ||||
| 	s->rupper = 0; | ||||
| 	s->rlower = screen_size_y(s) - 1; | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_alignmenttest); | ||||
| 	tty_write(tty_cmd_alignmenttest, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Insert nx characters. */ | ||||
| @@ -335,6 +340,7 @@ void | ||||
| screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	if (nx == 0) | ||||
| 		nx = 1; | ||||
| @@ -344,12 +350,13 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) | ||||
| 	if (nx == 0) | ||||
| 		return; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cx <= screen_size_x(s) - 1) | ||||
| 		grid_view_insert_cells(s->grid, s->cx, s->cy, nx); | ||||
|  | ||||
| 	tty_writenum(ctx->wp, tty_cmd_insertcharacter, nx); | ||||
| 	ttyctx.num = nx; | ||||
| 	tty_write(tty_cmd_insertcharacter, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Delete nx characters. */ | ||||
| @@ -357,6 +364,7 @@ void | ||||
| screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	if (nx == 0) | ||||
| 		nx = 1; | ||||
| @@ -366,12 +374,13 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) | ||||
| 	if (nx == 0) | ||||
| 		return; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cx <= screen_size_x(s) - 1) | ||||
| 		grid_view_delete_cells(s->grid, s->cx, s->cy, nx); | ||||
|  | ||||
| 	tty_writenum(ctx->wp, tty_cmd_deletecharacter, nx); | ||||
| 	ttyctx.num = nx; | ||||
| 	tty_write(tty_cmd_deletecharacter, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Insert ny lines. */ | ||||
| @@ -379,6 +388,7 @@ void | ||||
| screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	if (ny == 0) | ||||
| 		ny = 1; | ||||
| @@ -389,11 +399,12 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) | ||||
| 		if (ny == 0) | ||||
| 			return; | ||||
|  | ||||
| 		screen_write_save(ctx); | ||||
| 		screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 		grid_view_insert_lines(s->grid, s->cy, ny); | ||||
|  | ||||
| 		tty_writenum(ctx->wp, tty_cmd_insertline, ny); | ||||
| 		ttyctx.num = ny; | ||||
| 		tty_write(tty_cmd_insertline, &ttyctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| @@ -402,14 +413,15 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) | ||||
| 	if (ny == 0) | ||||
| 		return; | ||||
| 	 | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cy < s->rupper || s->cy > s->rlower) | ||||
| 		grid_view_insert_lines(s->grid, s->cy, ny); | ||||
| 	else | ||||
| 		grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny); | ||||
|  | ||||
| 	tty_writenum(ctx->wp, tty_cmd_insertline, ny); | ||||
| 	ttyctx.num = ny; | ||||
| 	tty_write(tty_cmd_insertline, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Delete ny lines. */ | ||||
| @@ -417,6 +429,7 @@ void | ||||
| screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	if (ny == 0) | ||||
| 		ny = 1; | ||||
| @@ -427,11 +440,12 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) | ||||
| 		if (ny == 0) | ||||
| 			return; | ||||
|  | ||||
| 		screen_write_save(ctx); | ||||
| 		screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 		grid_view_delete_lines(s->grid, s->cy, ny); | ||||
|  | ||||
| 		tty_writenum(ctx->wp, tty_cmd_deleteline, ny); | ||||
| 		ttyctx.num = ny; | ||||
| 		tty_write(tty_cmd_deleteline, &ttyctx); | ||||
| 		return; | ||||
| 	} | ||||
| 	 | ||||
| @@ -440,14 +454,15 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) | ||||
| 	if (ny == 0) | ||||
| 		return; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cy < s->rupper || s->cy > s->rlower) | ||||
| 		grid_view_delete_lines(s->grid, s->cy, ny); | ||||
| 	else | ||||
| 		grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny); | ||||
|  | ||||
| 	tty_writenum(ctx->wp, tty_cmd_deleteline, ny); | ||||
| 	ttyctx.num = ny; | ||||
| 	tty_write(tty_cmd_deleteline, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Clear line at cursor. */ | ||||
| @@ -455,12 +470,13 @@ void | ||||
| screen_write_clearline(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1); | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_clearline); | ||||
| 	tty_write(tty_cmd_clearline, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Clear to end of line from cursor. */ | ||||
| @@ -468,16 +484,17 @@ void | ||||
| screen_write_clearendofline(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
| 	u_int		 sx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	sx = screen_size_x(s); | ||||
|  | ||||
| 	if (s->cx <= sx - 1) | ||||
| 		grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); | ||||
|  | ||||
|  	tty_write0(ctx->wp, tty_cmd_clearendofline); | ||||
|  	tty_write(tty_cmd_clearendofline, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Clear to start of line from cursor. */ | ||||
| @@ -485,9 +502,10 @@ void | ||||
| screen_write_clearstartofline(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
| 	u_int		 sx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	sx = screen_size_x(s); | ||||
|  | ||||
| @@ -496,7 +514,7 @@ screen_write_clearstartofline(struct screen_write_ctx *ctx) | ||||
| 	else | ||||
| 		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1); | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_clearstartofline); | ||||
| 	tty_write(tty_cmd_clearstartofline, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Move cursor to px,py.  */ | ||||
| @@ -531,15 +549,16 @@ void | ||||
| screen_write_reverseindex(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cy == s->rupper) | ||||
| 		grid_view_scroll_region_down(s->grid, s->rupper, s->rlower); | ||||
| 	else if (s->cy > 0) | ||||
| 		s->cy--; | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_reverseindex); | ||||
| 	tty_write(tty_cmd_reverseindex, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Set scroll region. */ | ||||
| @@ -593,15 +612,16 @@ void | ||||
| screen_write_linefeed(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	if (s->cy == s->rlower) | ||||
| 		grid_view_scroll_region_up(s->grid, s->rupper, s->rlower); | ||||
| 	else if (s->cy < screen_size_y(s) - 1) | ||||
| 		s->cy++; | ||||
|  | ||||
|  	tty_write0(ctx->wp, tty_cmd_linefeed); | ||||
|  	tty_write(tty_cmd_linefeed, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Carriage return (cursor to start of line). */ | ||||
| @@ -642,9 +662,10 @@ void | ||||
| screen_write_clearendofscreen(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
| 	u_int		 sx, sy; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	sx = screen_size_x(s); | ||||
| 	sy = screen_size_y(s); | ||||
| @@ -653,7 +674,7 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx) | ||||
| 		grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); | ||||
| 	grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1)); | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_clearendofscreen); | ||||
| 	tty_write(tty_cmd_clearendofscreen, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Clear to start of screen. */ | ||||
| @@ -661,9 +682,10 @@ void | ||||
| screen_write_clearstartofscreen(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
| 	u_int		 sx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	sx = screen_size_x(s); | ||||
|  | ||||
| @@ -674,7 +696,7 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx) | ||||
| 	else | ||||
| 		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1); | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_clearstartofscreen); | ||||
| 	tty_write(tty_cmd_clearstartofscreen, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Clear entire screen. */ | ||||
| @@ -682,12 +704,13 @@ void | ||||
| screen_write_clearscreen(struct screen_write_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = ctx->s; | ||||
| 	struct tty_ctx	 ttyctx; | ||||
|  | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
|  | ||||
| 	grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s)); | ||||
|  | ||||
| 	tty_write0(ctx->wp, tty_cmd_clearscreen); | ||||
| 	tty_write(tty_cmd_clearscreen, &ttyctx); | ||||
| } | ||||
|  | ||||
| /* Write cell data. */ | ||||
| @@ -737,7 +760,9 @@ screen_write_cell( | ||||
| 		memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i); | ||||
|  | ||||
| 		/* Assume the previous character has just been input. */ | ||||
| 		tty_writeptr(ctx->wp, tty_cmd_utf8character, udata); | ||||
| 		screen_write_initctx(ctx, &ttyctx); | ||||
| 		ttyctx.ptr = udata; | ||||
| 		tty_write(tty_cmd_utf8character, &ttyctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| @@ -785,13 +810,14 @@ screen_write_cell( | ||||
| 		grid_view_set_utf8(gd, s->cx, s->cy, &gu); | ||||
|  | ||||
| 	/* Move the cursor. */ | ||||
| 	screen_write_save(ctx); | ||||
| 	screen_write_initctx(ctx, &ttyctx); | ||||
| 	s->cx += width; | ||||
|  | ||||
| 	/* Draw to the screen if necessary. */ | ||||
| 	if (insert) | ||||
| 		tty_writenum(ctx->wp, tty_cmd_insertcharacter, width); | ||||
| 	ttyctx.wp = ctx->wp; | ||||
| 	if (insert) { | ||||
| 		ttyctx.num = width; | ||||
| 		tty_write(tty_cmd_insertcharacter, &ttyctx); | ||||
| 	} | ||||
| 	ttyctx.utf8 = &gu; | ||||
| 	if (screen_check_selection(s, s->cx - width, s->cy)) { | ||||
| 		s->sel.cell.data = gc->data; | ||||
|   | ||||
							
								
								
									
										26
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -477,15 +477,9 @@ struct screen { | ||||
| 	u_int		 cx;		/* cursor x */ | ||||
| 	u_int		 cy;		/* cursor y */ | ||||
|  | ||||
| 	u_int		 old_cx; | ||||
| 	u_int		 old_cy; | ||||
|  | ||||
| 	u_int		 rupper;	/* scroll region top */ | ||||
| 	u_int		 rlower;	/* scroll region bottom */ | ||||
|  | ||||
| 	u_int		 old_rupper; | ||||
| 	u_int		 old_rlower; | ||||
|  | ||||
| 	int		 mode; | ||||
|  | ||||
| 	bitstr_t      	*tabs; | ||||
| @@ -783,8 +777,19 @@ struct tty_ctx { | ||||
| 	const struct grid_cell *cell; | ||||
| 	const struct grid_utf8 *utf8; | ||||
|  | ||||
| 	u_int		    num; | ||||
| 	void		   *ptr;  | ||||
| 	u_int		 num; | ||||
| 	void		*ptr;  | ||||
|  | ||||
| 	/*  | ||||
| 	 * Cursor and region position before the screen was updated - this is | ||||
| 	 * where the command should be applied; the values in the screen have | ||||
| 	 * already been updated. | ||||
| 	 */ | ||||
| 	u_int		 ocx; | ||||
| 	u_int		 ocy; | ||||
|  | ||||
| 	u_int		 orupper; | ||||
| 	u_int		 orlower; | ||||
| }; | ||||
| typedef void tty_cmd_func(struct tty *, struct tty_ctx *); | ||||
|  | ||||
| @@ -1032,10 +1037,10 @@ void	tty_detect_utf8(struct tty *); | ||||
| void	tty_set_title(struct tty *, const char *); | ||||
| void	tty_update_mode(struct tty *, int); | ||||
| void	tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int); | ||||
| void	tty_redraw_region(struct tty *, struct window_pane *); | ||||
| int	tty_open(struct tty *, char **); | ||||
| void	tty_close(struct tty *, int); | ||||
| void	tty_free(struct tty *, int); | ||||
| void	tty_write(void (*)(struct tty *, struct tty_ctx *), struct tty_ctx *); | ||||
| void	tty_cmd_alignmenttest(struct tty *, struct tty_ctx *); | ||||
| void	tty_cmd_cell(struct tty *, struct tty_ctx *); | ||||
| void	tty_cmd_clearendofline(struct tty *, struct tty_ctx *); | ||||
| @@ -1073,9 +1078,6 @@ void	tty_keys_free(struct tty *); | ||||
| int	tty_keys_next(struct tty *, int *, u_char *); | ||||
|  | ||||
| /* tty-write.c */ | ||||
| void	tty_write0(struct window_pane *, tty_cmd_func *); | ||||
| void	tty_writenum(struct window_pane *, tty_cmd_func *, u_int); | ||||
| void	tty_writeptr(struct window_pane *, tty_cmd_func *, void *); | ||||
| void	tty_write(tty_cmd_func *, struct tty_ctx *); | ||||
|  | ||||
| /* options-cmd.c */ | ||||
|   | ||||
							
								
								
									
										34
									
								
								tty-write.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								tty-write.c
									
									
									
									
									
								
							| @@ -18,42 +18,8 @@ | ||||
|  | ||||
| #include <sys/types.h> | ||||
|  | ||||
| #include <string.h> | ||||
|  | ||||
| #include "tmux.h" | ||||
|  | ||||
| void | ||||
| tty_write0(struct window_pane *wp, tty_cmd_func *cmdfn) | ||||
| { | ||||
| 	struct tty_ctx	ctx; | ||||
|  | ||||
| 	memset(&ctx, 0, sizeof ctx); | ||||
| 	ctx.wp = wp; | ||||
| 	tty_write(cmdfn, &ctx); | ||||
| } | ||||
|  | ||||
| void | ||||
| tty_writenum(struct window_pane *wp, tty_cmd_func *cmdfn, u_int num) | ||||
| { | ||||
| 	struct tty_ctx	ctx; | ||||
|  | ||||
| 	memset(&ctx, 0, sizeof ctx); | ||||
| 	ctx.wp = wp; | ||||
| 	ctx.num = num; | ||||
| 	tty_write(cmdfn, &ctx); | ||||
| } | ||||
|  | ||||
| void | ||||
| tty_writeptr(struct window_pane *wp, tty_cmd_func *cmdfn, void *ptr) | ||||
| { | ||||
| 	struct tty_ctx	ctx; | ||||
|  | ||||
| 	memset(&ctx, 0, sizeof ctx); | ||||
| 	ctx.wp = wp; | ||||
| 	ctx.ptr = ptr; | ||||
| 	tty_write(cmdfn, &ctx); | ||||
| } | ||||
|  | ||||
| void | ||||
| tty_write(tty_cmd_func *cmdfn, struct tty_ctx *ctx) | ||||
| { | ||||
|   | ||||
							
								
								
									
										90
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								tty.c
									
									
									
									
									
								
							| @@ -38,10 +38,11 @@ void	tty_attributes(struct tty *, const struct grid_cell *); | ||||
| void	tty_attributes_fg(struct tty *, const struct grid_cell *); | ||||
| void	tty_attributes_bg(struct tty *, const struct grid_cell *); | ||||
|  | ||||
| void	tty_redraw_region(struct tty *, struct tty_ctx *); | ||||
| void	tty_emulate_repeat( | ||||
| 	    struct tty *, enum tty_code_code, enum tty_code_code, u_int); | ||||
| void	 tty_cell(struct tty *, | ||||
|     		     const struct grid_cell *, const struct grid_utf8 *); | ||||
| void	tty_cell(struct tty *, | ||||
|     	    const struct grid_cell *, const struct grid_utf8 *); | ||||
|  | ||||
| void | ||||
| tty_init(struct tty *tty, char *path, char *term) | ||||
| @@ -449,10 +450,11 @@ tty_emulate_repeat( | ||||
|  * width of the terminal. | ||||
|  */ | ||||
| void | ||||
| tty_redraw_region(struct tty *tty, struct window_pane *wp) | ||||
| tty_redraw_region(struct tty *tty, struct tty_ctx *ctx) | ||||
| { | ||||
| 	struct screen	*s = wp->screen; | ||||
| 	u_int		 i; | ||||
| 	struct window_pane	*wp = ctx->wp; | ||||
| 	struct screen		*s = wp->screen; | ||||
| 	u_int		 	 i; | ||||
|  | ||||
| 	/* | ||||
| 	 * If region is >= 50% of the screen, just schedule a window redraw. In | ||||
| @@ -460,16 +462,16 @@ tty_redraw_region(struct tty *tty, struct window_pane *wp) | ||||
| 	 * without this, the entire pane ends up being redrawn many times which | ||||
| 	 * can be much more data. | ||||
| 	 */ | ||||
| 	if (s->old_rupper - s->old_rlower >= screen_size_y(s) / 2) { | ||||
| 	if (ctx->orupper - ctx->orlower >= screen_size_y(s) / 2) { | ||||
| 		wp->flags |= PANE_REDRAW; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) { | ||||
| 		for (i = s->old_cy; i < screen_size_y(s); i++) | ||||
| 	if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) { | ||||
| 		for (i = ctx->ocy; i < screen_size_y(s); i++) | ||||
| 			tty_draw_line(tty, s, i, wp->xoff, wp->yoff); | ||||
| 	} else { | ||||
| 		for (i = s->old_rupper; i <= s->old_rlower; i++) | ||||
| 		for (i = ctx->orupper; i <= ctx->orlower; i++) | ||||
| 			tty_draw_line(tty, s, i, wp->xoff, wp->yoff); | ||||
| 	} | ||||
| } | ||||
| @@ -522,13 +524,13 @@ tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx) | ||||
| 	struct screen		*s = wp->screen; | ||||
|  | ||||
| 	if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { | ||||
| 		tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); | ||||
| 		tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
|  	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	if (tty_term_has(tty->term, TTYC_ICH) || | ||||
| 	    tty_term_has(tty->term, TTYC_ICH1)) | ||||
| 		tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); | ||||
| @@ -547,13 +549,13 @@ tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx) | ||||
| 	struct screen		*s = wp->screen; | ||||
|  | ||||
| 	if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { | ||||
| 		tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); | ||||
| 		tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
|  	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); | ||||
| } | ||||
|  | ||||
| @@ -565,15 +567,15 @@ tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
|  	if (wp->xoff != 0 || screen_size_x(s) < tty->sx || | ||||
| 	    !tty_term_has(tty->term, TTYC_CSR)) { | ||||
| 		tty_redraw_region(tty, wp); | ||||
| 		tty_redraw_region(tty, ctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); | ||||
|  	tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); | ||||
|  | ||||
|  	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
|  	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); | ||||
| } | ||||
|  | ||||
| @@ -585,15 +587,15 @@ tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
|  	if (wp->xoff != 0 || screen_size_x(s) < tty->sx || | ||||
| 	    !tty_term_has(tty->term, TTYC_CSR)) { | ||||
| 		tty_redraw_region(tty, wp); | ||||
| 		tty_redraw_region(tty, ctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); | ||||
|  	tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); | ||||
|  | ||||
|  	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
|  	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); | ||||
| } | ||||
|  | ||||
| @@ -606,7 +608,7 @@ tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff); | ||||
|  	tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && | ||||
| 	    tty_term_has(tty->term, TTYC_EL)) { | ||||
| 		tty_putcode(tty, TTYC_EL); | ||||
| @@ -625,12 +627,12 @@ tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
| 	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
| 	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && | ||||
| 	    tty_term_has(tty->term, TTYC_EL)) | ||||
| 		tty_putcode(tty, TTYC_EL); | ||||
| 	else { | ||||
| 		for (i = s->old_cx; i < screen_size_x(s); i++) | ||||
| 		for (i = ctx->ocx; i < screen_size_x(s); i++) | ||||
| 			tty_putc(tty, ' '); | ||||
| 	} | ||||
| } | ||||
| @@ -639,17 +641,16 @@ void | ||||
| tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx) | ||||
| { | ||||
|   	struct window_pane	*wp = ctx->wp; | ||||
| 	struct screen		*s = wp->screen; | ||||
| 	u_int		 	 i; | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
| 	if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { | ||||
| 		tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
| 		tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 		tty_putcode(tty, TTYC_EL1); | ||||
| 	} else { | ||||
| 		tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff); | ||||
| 		for (i = 0; i < s->old_cx + 1; i++) | ||||
| 		tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 		for (i = 0; i < ctx->ocx + 1; i++) | ||||
| 			tty_putc(tty, ' '); | ||||
| 	} | ||||
| } | ||||
| @@ -662,16 +663,16 @@ tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
|  	if (wp->xoff != 0 || screen_size_x(s) < tty->sx || | ||||
| 	    !tty_term_has(tty->term, TTYC_CSR)) { | ||||
| 		tty_redraw_region(tty, wp); | ||||
| 		tty_redraw_region(tty, ctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); | ||||
|  	tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); | ||||
|  | ||||
| 	if (s->old_cy == s->old_rupper) { | ||||
| 		tty_cursor(tty, s->old_cx, s->old_rupper, wp->xoff, wp->yoff); | ||||
| 	if (ctx->ocy == ctx->orupper) { | ||||
| 		tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff); | ||||
| 		tty_putcode(tty, TTYC_RI); | ||||
| 	} | ||||
| } | ||||
| @@ -684,16 +685,16 @@ tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx) | ||||
|  | ||||
|  	if (wp->xoff != 0 || screen_size_x(s) < tty->sx || | ||||
| 	    !tty_term_has(tty->term, TTYC_CSR)) { | ||||
| 		tty_redraw_region(tty, wp); | ||||
| 		tty_redraw_region(tty, ctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	tty_reset(tty); | ||||
|  | ||||
|  	tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); | ||||
|  	tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); | ||||
|  | ||||
| 	if (s->old_cy == s->old_rlower) { | ||||
| 		tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
| 	if (ctx->ocy == ctx->orlower) { | ||||
| 		tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 		tty_putc(tty, '\n'); | ||||
| 	} | ||||
| } | ||||
| @@ -708,13 +709,13 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx) | ||||
| 	tty_reset(tty); | ||||
|  | ||||
| 	tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); | ||||
| 	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
| 	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
| 	if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && | ||||
| 	    tty_term_has(tty->term, TTYC_EL)) { | ||||
| 		tty_putcode(tty, TTYC_EL); | ||||
| 		if (s->old_cy != screen_size_y(s) - 1) { | ||||
| 			tty_cursor(tty, 0, s->old_cy + 1, wp->xoff, wp->yoff); | ||||
| 			for (i = s->old_cy + 1; i < screen_size_y(s); i++) { | ||||
| 		if (ctx->ocy != screen_size_y(s) - 1) { | ||||
| 			tty_cursor(tty, 0, ctx->ocy + 1, wp->xoff, wp->yoff); | ||||
| 			for (i = ctx->ocy + 1; i < screen_size_y(s); i++) { | ||||
| 				tty_putcode(tty, TTYC_EL); | ||||
| 				if (i == screen_size_y(s) - 1) | ||||
| 					continue; | ||||
| @@ -723,9 +724,9 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx) | ||||
| 			} | ||||
| 		} | ||||
| 	} else { | ||||
| 		for (i = s->old_cx; i < screen_size_x(s); i++) | ||||
| 		for (i = ctx->ocx; i < screen_size_x(s); i++) | ||||
| 			tty_putc(tty, ' '); | ||||
| 		for (j = s->old_cy; j < screen_size_y(s); j++) { | ||||
| 		for (j = ctx->ocy; j < screen_size_y(s); j++) { | ||||
| 			tty_cursor(tty, 0, j, wp->xoff, wp->yoff); | ||||
| 			for (i = 0; i < screen_size_x(s); i++) | ||||
| 				tty_putc(tty, ' '); | ||||
| @@ -746,19 +747,19 @@ tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx) | ||||
| 	tty_cursor(tty, 0, 0, wp->xoff, wp->yoff); | ||||
| 	if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && | ||||
| 	    tty_term_has(tty->term, TTYC_EL)) { | ||||
| 		for (i = 0; i < s->old_cy; i++) { | ||||
| 		for (i = 0; i < ctx->ocy; i++) { | ||||
| 			tty_putcode(tty, TTYC_EL); | ||||
| 			tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); | ||||
| 			tty->cy++; | ||||
| 		} | ||||
| 	} else { | ||||
| 		for (j = 0; j < s->old_cy; j++) { | ||||
| 		for (j = 0; j < ctx->ocy; j++) { | ||||
| 			tty_cursor(tty, 0, j, wp->xoff, wp->yoff); | ||||
| 			for (i = 0; i < screen_size_x(s); i++) | ||||
| 				tty_putc(tty, ' '); | ||||
| 		} | ||||
| 	} | ||||
| 	for (i = 0; i <= s->old_cx; i++) | ||||
| 	for (i = 0; i <= ctx->ocx; i++) | ||||
| 		tty_putc(tty, ' '); | ||||
| } | ||||
|  | ||||
| @@ -813,9 +814,8 @@ void | ||||
| tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx) | ||||
| { | ||||
| 	struct window_pane	*wp = ctx->wp; | ||||
| 	struct screen		*s = wp->screen; | ||||
|  | ||||
| 	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); | ||||
| 	tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); | ||||
|  | ||||
| 	tty_cell(tty, ctx->cell, ctx->utf8); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott