mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Add support for origin mode (DECOM, SM/RM ?6), from Marc Reisner.
This commit is contained in:
		
							
								
								
									
										8
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								input.c
									
									
									
									
									
								
							| @@ -1572,6 +1572,10 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx) | |||||||
| 			screen_write_clearscreen(&ictx->ctx, | 			screen_write_clearscreen(&ictx->ctx, | ||||||
| 			    ictx->cell.cell.bg); | 			    ictx->cell.cell.bg); | ||||||
| 			break; | 			break; | ||||||
|  | 		case 6:		/* DECOM */ | ||||||
|  | 			screen_write_mode_clear(&ictx->ctx, MODE_ORIGIN); | ||||||
|  | 			screen_write_cursormove(&ictx->ctx, 0, 0); | ||||||
|  | 			break; | ||||||
| 		case 7:		/* DECAWM */ | 		case 7:		/* DECAWM */ | ||||||
| 			screen_write_mode_clear(&ictx->ctx, MODE_WRAP); | 			screen_write_mode_clear(&ictx->ctx, MODE_WRAP); | ||||||
| 			break; | 			break; | ||||||
| @@ -1655,6 +1659,10 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx) | |||||||
| 			screen_write_clearscreen(&ictx->ctx, | 			screen_write_clearscreen(&ictx->ctx, | ||||||
| 			    ictx->cell.cell.bg); | 			    ictx->cell.cell.bg); | ||||||
| 			break; | 			break; | ||||||
|  | 		case 6:		/* DECOM */ | ||||||
|  | 			screen_write_mode_set(&ictx->ctx, MODE_ORIGIN); | ||||||
|  | 			screen_write_cursormove(&ictx->ctx, 0, 0); | ||||||
|  | 			break; | ||||||
| 		case 7:		/* DECAWM */ | 		case 7:		/* DECAWM */ | ||||||
| 			screen_write_mode_set(&ictx->ctx, MODE_WRAP); | 			screen_write_mode_set(&ictx->ctx, MODE_WRAP); | ||||||
| 			break; | 			break; | ||||||
|   | |||||||
| @@ -74,10 +74,16 @@ screen_write_set_cursor(struct screen_write_ctx *ctx, int cx, int cy) | |||||||
| 	if (cx != -1 && (u_int)cx == s->cx && cy != -1 && (u_int)cy == s->cy) | 	if (cx != -1 && (u_int)cx == s->cx && cy != -1 && (u_int)cy == s->cy) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	if (cx != -1) | 	if (cx != -1) { | ||||||
|  | 		if ((u_int)cx > screen_size_x(s) - 1) | ||||||
|  | 			cx = screen_size_x(s) - 1; | ||||||
| 		s->cx = cx; | 		s->cx = cx; | ||||||
| 	if (cy != -1) | 	} | ||||||
|  | 	if (cy != -1) { | ||||||
|  | 		if ((u_int)cy > screen_size_y(s) - 1) | ||||||
|  | 			cy = screen_size_y(s) - 1; | ||||||
| 		s->cy = cy; | 		s->cy = cy; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if (wp == NULL) | 	if (wp == NULL) | ||||||
| 		return; | 		return; | ||||||
| @@ -147,7 +153,7 @@ screen_write_reset(struct screen_write_ctx *ctx) | |||||||
| 	s->mode = MODE_CURSOR | MODE_WRAP; | 	s->mode = MODE_CURSOR | MODE_WRAP; | ||||||
|  |  | ||||||
| 	screen_write_clearscreen(ctx, 8); | 	screen_write_clearscreen(ctx, 8); | ||||||
| 	screen_write_cursormove(ctx, 0, 0); | 	screen_write_set_cursor(ctx, 0, 0); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Write character. */ | /* Write character. */ | ||||||
| @@ -419,7 +425,7 @@ screen_write_copy(struct screen_write_ctx *ctx, struct screen *src, u_int px, | |||||||
| 				screen_write_cell(ctx, &gc); | 				screen_write_cell(ctx, &gc); | ||||||
| 		} | 		} | ||||||
| 		cy++; | 		cy++; | ||||||
| 		screen_write_cursormove(ctx, cx, cy); | 		screen_write_set_cursor(ctx, cx, cy); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -477,7 +483,7 @@ screen_write_hline(struct screen_write_ctx *ctx, u_int nx, int left, int right) | |||||||
| 		screen_write_putc(ctx, &gc, 'q'); | 		screen_write_putc(ctx, &gc, 'q'); | ||||||
| 	screen_write_putc(ctx, &gc, right ? 'u' : 'q'); | 	screen_write_putc(ctx, &gc, right ? 'u' : 'q'); | ||||||
|  |  | ||||||
| 	screen_write_cursormove(ctx, cx, cy); | 	screen_write_set_cursor(ctx, cx, cy); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Draw a horizontal line on screen. */ | /* Draw a horizontal line on screen. */ | ||||||
| @@ -496,13 +502,13 @@ screen_write_vline(struct screen_write_ctx *ctx, u_int ny, int top, int bottom) | |||||||
|  |  | ||||||
| 	screen_write_putc(ctx, &gc, top ? 'w' : 'x'); | 	screen_write_putc(ctx, &gc, top ? 'w' : 'x'); | ||||||
| 	for (i = 1; i < ny - 1; i++) { | 	for (i = 1; i < ny - 1; i++) { | ||||||
| 		screen_write_cursormove(ctx, cx, cy + i); | 		screen_write_set_cursor(ctx, cx, cy + i); | ||||||
| 		screen_write_putc(ctx, &gc, 'x'); | 		screen_write_putc(ctx, &gc, 'x'); | ||||||
| 	} | 	} | ||||||
| 	screen_write_cursormove(ctx, cx, cy + ny - 1); | 	screen_write_set_cursor(ctx, cx, cy + ny - 1); | ||||||
| 	screen_write_putc(ctx, &gc, bottom ? 'v' : 'x'); | 	screen_write_putc(ctx, &gc, bottom ? 'v' : 'x'); | ||||||
|  |  | ||||||
| 	screen_write_cursormove(ctx, cx, cy); | 	screen_write_set_cursor(ctx, cx, cy); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Draw a box on screen. */ | /* Draw a box on screen. */ | ||||||
| @@ -524,22 +530,22 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny) | |||||||
| 		screen_write_putc(ctx, &gc, 'q'); | 		screen_write_putc(ctx, &gc, 'q'); | ||||||
| 	screen_write_putc(ctx, &gc, 'k'); | 	screen_write_putc(ctx, &gc, 'k'); | ||||||
|  |  | ||||||
| 	screen_write_cursormove(ctx, cx, cy + ny - 1); | 	screen_write_set_cursor(ctx, cx, cy + ny - 1); | ||||||
| 	screen_write_putc(ctx, &gc, 'm'); | 	screen_write_putc(ctx, &gc, 'm'); | ||||||
| 	for (i = 1; i < nx - 1; i++) | 	for (i = 1; i < nx - 1; i++) | ||||||
| 		screen_write_putc(ctx, &gc, 'q'); | 		screen_write_putc(ctx, &gc, 'q'); | ||||||
| 	screen_write_putc(ctx, &gc, 'j'); | 	screen_write_putc(ctx, &gc, 'j'); | ||||||
|  |  | ||||||
| 	for (i = 1; i < ny - 1; i++) { | 	for (i = 1; i < ny - 1; i++) { | ||||||
| 		screen_write_cursormove(ctx, cx, cy + i); | 		screen_write_set_cursor(ctx, cx, cy + i); | ||||||
| 		screen_write_putc(ctx, &gc, 'x'); | 		screen_write_putc(ctx, &gc, 'x'); | ||||||
| 	} | 	} | ||||||
| 	for (i = 1; i < ny - 1; i++) { | 	for (i = 1; i < ny - 1; i++) { | ||||||
| 		screen_write_cursormove(ctx, cx + nx - 1, cy + i); | 		screen_write_set_cursor(ctx, cx + nx - 1, cy + i); | ||||||
| 		screen_write_putc(ctx, &gc, 'x'); | 		screen_write_putc(ctx, &gc, 'x'); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	screen_write_cursormove(ctx, cx, cy); | 	screen_write_set_cursor(ctx, cx, cy); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -594,7 +600,7 @@ screen_write_preview(struct screen_write_ctx *ctx, struct screen *src, u_int nx, | |||||||
| 	if (src->mode & MODE_CURSOR) { | 	if (src->mode & MODE_CURSOR) { | ||||||
| 		grid_view_get_cell(src->grid, src->cx, src->cy, &gc); | 		grid_view_get_cell(src->grid, src->cx, src->cy, &gc); | ||||||
| 		gc.attr |= GRID_ATTR_REVERSE; | 		gc.attr |= GRID_ATTR_REVERSE; | ||||||
| 		screen_write_cursormove(ctx, cx + (src->cx - px), | 		screen_write_set_cursor(ctx, cx + (src->cx - px), | ||||||
| 		    cy + (src->cy - py)); | 		    cy + (src->cy - py)); | ||||||
| 		screen_write_cell(ctx, &gc); | 		screen_write_cell(ctx, &gc); | ||||||
| 	} | 	} | ||||||
| @@ -1032,10 +1038,12 @@ screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py) | |||||||
| { | { | ||||||
| 	struct screen	*s = ctx->s; | 	struct screen	*s = ctx->s; | ||||||
|  |  | ||||||
| 	if (px > screen_size_x(s) - 1) | 	if (s->mode & MODE_ORIGIN) { | ||||||
| 		px = screen_size_x(s) - 1; | 		if (py > s->rlower - s->rupper) | ||||||
| 	if (py > screen_size_y(s) - 1) | 			py = s->rlower; | ||||||
| 		py = screen_size_y(s) - 1; | 		else | ||||||
|  | 			py += s->rupper; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	screen_write_set_cursor(ctx, px, py); | 	screen_write_set_cursor(ctx, px, py); | ||||||
| } | } | ||||||
| @@ -1296,7 +1304,7 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only) | |||||||
| 	cx = s->cx; cy = s->cy; | 	cx = s->cx; cy = s->cy; | ||||||
| 	for (y = 0; y < screen_size_y(s); y++) { | 	for (y = 0; y < screen_size_y(s); y++) { | ||||||
| 		TAILQ_FOREACH_SAFE(ci, &ctx->list[y].items, entry, tmp) { | 		TAILQ_FOREACH_SAFE(ci, &ctx->list[y].items, entry, tmp) { | ||||||
| 			screen_write_cursormove(ctx, ci->x, y); | 			screen_write_set_cursor(ctx, ci->x, y); | ||||||
| 			screen_write_initctx(ctx, &ttyctx); | 			screen_write_initctx(ctx, &ttyctx); | ||||||
| 			ttyctx.cell = &ci->gc; | 			ttyctx.cell = &ci->gc; | ||||||
| 			ttyctx.wrapped = ci->wrapped; | 			ttyctx.wrapped = ci->wrapped; | ||||||
| @@ -1441,7 +1449,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) | |||||||
| 		screen_write_collect_flush(ctx, 0); | 		screen_write_collect_flush(ctx, 0); | ||||||
| 		if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) { | 		if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) { | ||||||
| 			cx = s->cx; cy = s->cy; | 			cx = s->cx; cy = s->cy; | ||||||
| 			screen_write_cursormove(ctx, xx, s->cy); | 			screen_write_set_cursor(ctx, xx, s->cy); | ||||||
| 			screen_write_initctx(ctx, &ttyctx); | 			screen_write_initctx(ctx, &ttyctx); | ||||||
| 			ttyctx.cell = gc; | 			ttyctx.cell = gc; | ||||||
| 			tty_write(tty_cmd_cell, &ttyctx); | 			tty_write(tty_cmd_cell, &ttyctx); | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -517,6 +517,7 @@ struct msg_stderr_data { | |||||||
| #define MODE_BRACKETPASTE 0x400 | #define MODE_BRACKETPASTE 0x400 | ||||||
| #define MODE_FOCUSON 0x800 | #define MODE_FOCUSON 0x800 | ||||||
| #define MODE_MOUSE_ALL 0x1000 | #define MODE_MOUSE_ALL 0x1000 | ||||||
|  | #define MODE_ORIGIN 0x2000 | ||||||
|  |  | ||||||
| #define ALL_MODES 0xffffff | #define ALL_MODES 0xffffff | ||||||
| #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL) | #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nicm
					nicm