mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	On xterm 271 and later, put the terminal into SCL 5 and use DECCRA for
scrolling the region in panes (if the large region check isn't hit). With help from Ailin Nemui.
This commit is contained in:
		
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1472,8 +1472,9 @@ void	tty_putc(struct tty *, u_char);
 | 
				
			|||||||
void	tty_pututf8(struct tty *, const struct grid_utf8 *);
 | 
					void	tty_pututf8(struct tty *, const struct grid_utf8 *);
 | 
				
			||||||
void	tty_init(struct tty *, int, char *);
 | 
					void	tty_init(struct tty *, int, char *);
 | 
				
			||||||
int	tty_resize(struct tty *);
 | 
					int	tty_resize(struct tty *);
 | 
				
			||||||
int	tty_set_size(struct tty *tty, u_int sx, u_int sy);
 | 
					int	tty_set_size(struct tty *, u_int, u_int);
 | 
				
			||||||
void	tty_start_tty(struct tty *);
 | 
					void	tty_start_tty(struct tty *);
 | 
				
			||||||
 | 
					void	tty_set_version(struct tty *, u_int);
 | 
				
			||||||
void	tty_stop_tty(struct tty *);
 | 
					void	tty_stop_tty(struct tty *);
 | 
				
			||||||
void	tty_set_title(struct tty *, const char *);
 | 
					void	tty_set_title(struct tty *, const char *);
 | 
				
			||||||
void	tty_update_mode(struct tty *, int, struct screen *);
 | 
					void	tty_update_mode(struct tty *, int, struct screen *);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -728,8 +728,7 @@ tty_keys_device(struct tty *tty, const char *buf, size_t len, size_t *size)
 | 
				
			|||||||
		a = b = 0;
 | 
							a = b = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log_debug("received xterm version %u", b);
 | 
						log_debug("received xterm version %u", b);
 | 
				
			||||||
	if (tty->xterm_version == 0)
 | 
						tty_set_version(tty, b);
 | 
				
			||||||
		tty->xterm_version = b;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										43
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								tty.c
									
									
									
									
									
								
							@@ -177,7 +177,7 @@ tty_error_callback(
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev)
 | 
					tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct termios	 tio;
 | 
						struct termios	tio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (fd == -1 || tcgetattr(fd, orig_tio) != 0)
 | 
						if (fd == -1 || tcgetattr(fd, orig_tio) != 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
@@ -234,6 +234,27 @@ tty_start_tty(struct tty *tty)
 | 
				
			|||||||
	tty_force_cursor_colour(tty, "");
 | 
						tty_force_cursor_colour(tty, "");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					tty_set_version(struct tty *tty, u_int version)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (tty->xterm_version != 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						tty->xterm_version = version;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (tty->xterm_version > 270) {
 | 
				
			||||||
 | 
							tty_puts(tty, "\033[65;1\"p");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tty_putcode(tty, TTYC_RMACS);
 | 
				
			||||||
 | 
							memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tty->cx = UINT_MAX;
 | 
				
			||||||
 | 
							tty->cy = UINT_MAX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tty->rupper = UINT_MAX;
 | 
				
			||||||
 | 
							tty->rlower = UINT_MAX;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
tty_stop_tty(struct tty *tty)
 | 
					tty_stop_tty(struct tty *tty)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -276,6 +297,9 @@ tty_stop_tty(struct tty *tty)
 | 
				
			|||||||
		tty_raw(tty, "\033[?1000l");
 | 
							tty_raw(tty, "\033[?1000l");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
 | 
						tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (tty->xterm_version > 270)
 | 
				
			||||||
 | 
							tty_raw(tty, "\033[61;1\"p");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
@@ -844,13 +868,28 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp = ctx->wp;
 | 
						struct window_pane	*wp = ctx->wp;
 | 
				
			||||||
	struct screen		*s = wp->screen;
 | 
						struct screen		*s = wp->screen;
 | 
				
			||||||
 | 
						char			 tmp[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ctx->ocy != ctx->orlower)
 | 
						if (ctx->ocy != ctx->orlower)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
 | 
						if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
 | 
				
			||||||
	    !tty_term_has(tty->term, TTYC_CSR)) {
 | 
						    !tty_term_has(tty->term, TTYC_CSR)) {
 | 
				
			||||||
		tty_redraw_region(tty, ctx);
 | 
							if (tty_large_region(tty, ctx))
 | 
				
			||||||
 | 
								wp->flags |= PANE_REDRAW;
 | 
				
			||||||
 | 
							else if (tty->xterm_version > 270) {
 | 
				
			||||||
 | 
								snprintf(tmp, sizeof tmp,
 | 
				
			||||||
 | 
								    "\033[%u;%u;%u;%u;1;%u;%u;1$v",
 | 
				
			||||||
 | 
								    ctx->yoff + ctx->orupper + 2,
 | 
				
			||||||
 | 
								    ctx->xoff + 1,
 | 
				
			||||||
 | 
								    ctx->yoff + ctx->orlower + 1,
 | 
				
			||||||
 | 
								    ctx->xoff + screen_size_x(s),
 | 
				
			||||||
 | 
								    ctx->yoff + ctx->orupper + 1,
 | 
				
			||||||
 | 
								    ctx->xoff + 1);
 | 
				
			||||||
 | 
								tty_puts(tty, tmp);
 | 
				
			||||||
 | 
								tty_cmd_clearline(tty, ctx);
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
								tty_redraw_region(tty, ctx);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user