diff options
author | 2012-03-17 22:56:04 +0000 | |
---|---|---|
committer | 2012-03-17 22:56:04 +0000 | |
commit | 5b492e4accbcf93df40764a4286e4f7e8f6dfa82 (patch) | |
tree | 0dcb4ac86c67a0f94514039acf9e09cf5b2fbaf2 /usr.bin/tmux/tty.c | |
parent | Add notify hooks for various events, the functions are currently empty (diff) | |
download | wireguard-openbsd-5b492e4accbcf93df40764a4286e4f7e8f6dfa82.tar.xz wireguard-openbsd-5b492e4accbcf93df40764a4286e4f7e8f6dfa82.zip |
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.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r-- | usr.bin/tmux/tty.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 91108068b5c..4c678e956e8 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.127 2012/03/17 21:27:51 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.128 2012/03/17 22:56:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -177,7 +177,7 @@ tty_error_callback( void 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) return; @@ -235,6 +235,27 @@ tty_start_tty(struct tty *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 tty_stop_tty(struct tty *tty) { struct winsize ws; @@ -276,6 +297,9 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, "\033[?1000l"); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); + + if (tty->xterm_version > 270) + tty_raw(tty, "\033[61;1\"p"); } void @@ -844,13 +868,28 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; + char tmp[64]; if (ctx->ocy != ctx->orlower) return; if (ctx->xoff != 0 || screen_size_x(s) < tty->sx || !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; } |