diff options
author | Thomas Adam <thomas@xteddy.org> | 2020-04-16 16:01:35 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2020-04-16 16:01:35 +0100 |
commit | 5e38d262579662f33570c520b6661e15c215f702 (patch) | |
tree | 99b52461946c4a128d6a475f81ae0d4a8ce022c7 /tty.c | |
parent | b3cadf826034ec356d0bf3dda26b7699bff4649c (diff) | |
parent | 5ec80bd249a37147207ec2ef420086336ccf78a8 (diff) | |
download | rtmux-5e38d262579662f33570c520b6661e15c215f702.tar.gz rtmux-5e38d262579662f33570c520b6661e15c215f702.tar.bz2 rtmux-5e38d262579662f33570c520b6661e15c215f702.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 68 |
1 files changed, 51 insertions, 17 deletions
@@ -74,7 +74,7 @@ static void tty_default_attributes(struct tty *, struct window_pane *, u_int); #define tty_use_margin(tty) \ - ((tty->term->flags|tty->term_flags) & TERM_DECSLRM) + (tty_get_flags(tty) & TERM_DECSLRM) #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) @@ -478,6 +478,14 @@ tty_set_flags(struct tty *tty, int flags) tty_puts(tty, "\033[?69h"); /* DECLRMM */ } +int +tty_get_flags(struct tty *tty) +{ + if (tty->term != NULL) + return (tty->term->flags|tty->term_flags); + return (tty->term_flags); +} + void tty_raw(struct tty *tty, const char *s) { @@ -575,7 +583,7 @@ tty_putc(struct tty *tty, u_char ch) { const char *acs; - if ((tty->term->flags & TERM_NOXENL) && + if ((tty_get_flags(tty) & TERM_NOXENL) && ch >= 0x20 && ch != 0x7f && tty->cy == tty->sy - 1 && tty->cx + 1 >= tty->sx) @@ -601,7 +609,7 @@ tty_putc(struct tty *tty, u_char ch) * where we think it should be after a line wrap - this * means it works on sensible terminals as well. */ - if (tty->term->flags & TERM_NOXENL) + if (tty_get_flags(tty) & TERM_NOXENL) tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); } else tty->cx++; @@ -611,7 +619,7 @@ tty_putc(struct tty *tty, u_char ch) void tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) { - if ((tty->term->flags & TERM_NOXENL) && + if ((tty_get_flags(tty) & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx + len >= tty->sx) len = tty->sx - tty->cx - 1; @@ -1167,7 +1175,7 @@ tty_clear_area(struct tty *tty, struct window_pane *wp, u_int py, u_int ny, * background colour isn't default (because it doesn't work * after SGR 0). */ - if (((tty->term->flags|tty->term_flags) & TERM_DECFRA) && + if ((tty_get_flags(tty) & TERM_DECFRA) && !COLOUR_DEFAULT(bg)) { xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", py + 1, px + 1, py + ny, px + nx); @@ -1247,7 +1255,7 @@ tty_check_codeset(struct tty *tty, const struct grid_cell *gc) return (gc); /* UTF-8 terminal and a UTF-8 character - fine. */ - if (tty->flags & TTY_UTF8) + if (tty_get_flags(tty) & TERM_UTF8) return (gc); /* Replace by the right number of underscores. */ @@ -1426,6 +1434,20 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s, tty_update_mode(tty, tty->mode, s); } +void +tty_sync_start(struct tty *tty) +{ + if (tty_get_flags(tty) & TERM_SYNC) + tty_puts(tty, "\033P=1s\033\\"); +} + +void +tty_sync_end(struct tty *tty) +{ + if (tty_get_flags(tty) & TERM_SYNC) + tty_puts(tty, "\033P=2s\033\\"); +} + static int tty_client_ready(struct client *c, struct window_pane *wp) { @@ -1876,7 +1898,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx) ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || - (tty->term->flags & TERM_NOXENL) || + (tty_get_flags(tty) & TERM_NOXENL) || ctx->xoff + ctx->ocx != 0 || ctx->yoff + ctx->ocy != tty->cy + 1 || tty->cx < tty->sx || @@ -1919,13 +1941,25 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) tty_invalidate(tty); } +void +tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx) +{ + tty_sync_start(tty); +} + +void +tty_cmd_syncend(struct tty *tty, __unused const struct tty_ctx *ctx) +{ + tty_sync_end(tty); +} + static void tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp) { const struct grid_cell *gcp; /* Skip last character if terminal is stupid. */ - if ((tty->term->flags & TERM_NOXENL) && + if ((tty_get_flags(tty) & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx == tty->sx - 1) return; @@ -2084,7 +2118,7 @@ tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx, { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || - (tty->term->flags & TERM_NOXENL) || + (tty_get_flags(tty) & TERM_NOXENL) || ctx->xoff + cx != 0 || ctx->yoff + cy != tty->cy + 1 || tty->cx < tty->sx || @@ -2421,14 +2455,14 @@ tty_check_fg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc) /* Is this a 24-bit colour? */ if (gc->fg & COLOUR_FLAG_RGB) { /* Not a 24-bit terminal? Translate to 256-colour palette. */ - if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS) + if (tty_get_flags(tty) & TERM_RGBCOLOURS) return; colour_split_rgb(gc->fg, &r, &g, &b); gc->fg = colour_find_rgb(r, g, b); } /* How many colours does this terminal have? */ - if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS) + if (tty_get_flags(tty) & TERM_256COLOURS) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); @@ -2470,14 +2504,14 @@ tty_check_bg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc) /* Is this a 24-bit colour? */ if (gc->bg & COLOUR_FLAG_RGB) { /* Not a 24-bit terminal? Translate to 256-colour palette. */ - if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS) + if (tty_get_flags(tty) & TERM_RGBCOLOURS) return; colour_split_rgb(gc->bg, &r, &g, &b); gc->bg = colour_find_rgb(r, g, b); } /* How many colours does this terminal have? */ - if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS) + if (tty_get_flags(tty) & TERM_256COLOURS) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); @@ -2538,7 +2572,7 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc) /* Is this an aixterm bright colour? */ if (gc->fg >= 90 && gc->fg <= 97) { - if (tty->term_flags & TERM_256COLOURS) { + if (tty_get_flags(tty) & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->fg); tty_puts(tty, s); } else @@ -2570,7 +2604,7 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc) /* Is this an aixterm bright colour? */ if (gc->bg >= 90 && gc->bg <= 97) { - if (tty->term_flags & TERM_256COLOURS) { + if (tty_get_flags(tty) & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10); tty_puts(tty, s); } else @@ -2626,7 +2660,7 @@ tty_try_colour(struct tty *tty, int colour, const char *type) * Also if RGB is set, setaf and setab do not support the 256 * colour palette so use the sequences directly there too. */ - if ((tty->term_flags & TERM_256COLOURS) || + if ((tty_get_flags(tty) & TERM_256COLOURS) || tty_term_has(tty->term, TTYC_RGB)) goto fallback_256; @@ -2634,7 +2668,7 @@ tty_try_colour(struct tty *tty, int colour, const char *type) * If the terminfo entry has 256 colours and setaf and setab * exist, assume that they work correctly. */ - if (tty->term->flags & TERM_256COLOURS) { + if (tty_get_flags(tty) & TERM_256COLOURS) { if (*type == '3') { if (!tty_term_has(tty->term, TTYC_SETAF)) goto fallback_256; |