=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.348 retrieving revision 1.349 diff -c -r1.348 -r1.349 *** src/usr.bin/tmux/tty.c 2020/04/16 13:35:24 1.348 --- src/usr.bin/tmux/tty.c 2020/04/16 14:03:51 1.349 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.348 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.349 2020/04/16 14:03:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 74,80 **** u_int); #define tty_use_margin(tty) \ ! ((tty->term->flags|tty->term_flags) & TERM_DECSLRM) #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) --- 74,80 ---- u_int); #define tty_use_margin(tty) \ ! (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,483 **** --- 478,491 ---- 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,581 **** { const char *acs; ! if ((tty->term->flags & TERM_NOXENL) && ch >= 0x20 && ch != 0x7f && tty->cy == tty->sy - 1 && tty->cx + 1 >= tty->sx) --- 583,589 ---- { const char *acs; ! if ((tty_get_flags(tty) & TERM_NOXENL) && ch >= 0x20 && ch != 0x7f && tty->cy == tty->sy - 1 && tty->cx + 1 >= tty->sx) *************** *** 601,607 **** * 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) tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); } else tty->cx++; --- 609,615 ---- * where we think it should be after a line wrap - this * means it works on sensible terminals as well. */ ! if (tty_get_flags(tty) & TERM_NOXENL) tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); } else tty->cx++; *************** *** 611,617 **** void tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) { ! if ((tty->term->flags & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx + len >= tty->sx) len = tty->sx - tty->cx - 1; --- 619,625 ---- void tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) { ! if ((tty_get_flags(tty) & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx + len >= tty->sx) len = tty->sx - tty->cx - 1; *************** *** 1167,1173 **** * background colour isn't default (because it doesn't work * after SGR 0). */ ! if (((tty->term->flags|tty->term_flags) & TERM_DECFRA) && !COLOUR_DEFAULT(bg)) { xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", py + 1, px + 1, py + ny, px + nx); --- 1175,1181 ---- * background colour isn't default (because it doesn't work * after SGR 0). */ ! 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); *************** *** 1429,1442 **** void tty_sync_start(struct tty *tty) { ! if ((tty->term->flags|tty->term_flags) & TERM_SYNC) tty_puts(tty, "\033P=1s\033\\"); } void tty_sync_end(struct tty *tty) { ! if ((tty->term->flags|tty->term_flags) & TERM_SYNC) tty_puts(tty, "\033P=2s\033\\"); } --- 1437,1450 ---- 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\\"); } *************** *** 1890,1896 **** ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || ! (tty->term->flags & TERM_NOXENL) || ctx->xoff + ctx->ocx != 0 || ctx->yoff + ctx->ocy != tty->cy + 1 || tty->cx < tty->sx || --- 1898,1904 ---- ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || ! (tty_get_flags(tty) & TERM_NOXENL) || ctx->xoff + ctx->ocx != 0 || ctx->yoff + ctx->ocy != tty->cy + 1 || tty->cx < tty->sx || *************** *** 1951,1957 **** const struct grid_cell *gcp; /* Skip last character if terminal is stupid. */ ! if ((tty->term->flags & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx == tty->sx - 1) return; --- 1959,1965 ---- const struct grid_cell *gcp; /* Skip last character if terminal is stupid. */ ! if ((tty_get_flags(tty) & TERM_NOXENL) && tty->cy == tty->sy - 1 && tty->cx == tty->sx - 1) return; *************** *** 2110,2116 **** { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || ! (tty->term->flags & TERM_NOXENL) || ctx->xoff + cx != 0 || ctx->yoff + cy != tty->cy + 1 || tty->cx < tty->sx || --- 2118,2124 ---- { if (!ctx->wrapped || !tty_pane_full_width(tty, ctx) || ! (tty_get_flags(tty) & TERM_NOXENL) || ctx->xoff + cx != 0 || ctx->yoff + cy != tty->cy + 1 || tty->cx < tty->sx || *************** *** 2447,2460 **** /* 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) 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) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); --- 2455,2468 ---- /* Is this a 24-bit colour? */ if (gc->fg & COLOUR_FLAG_RGB) { /* Not a 24-bit terminal? Translate to 256-colour palette. */ ! 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_get_flags(tty) & TERM_256COLOURS) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); *************** *** 2496,2509 **** /* 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) 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) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); --- 2504,2517 ---- /* Is this a 24-bit colour? */ if (gc->bg & COLOUR_FLAG_RGB) { /* Not a 24-bit terminal? Translate to 256-colour palette. */ ! 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_get_flags(tty) & TERM_256COLOURS) colours = 256; else colours = tty_term_number(tty->term, TTYC_COLORS); *************** *** 2564,2570 **** /* Is this an aixterm bright colour? */ if (gc->fg >= 90 && gc->fg <= 97) { ! if (tty->term_flags & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->fg); tty_puts(tty, s); } else --- 2572,2578 ---- /* Is this an aixterm bright colour? */ if (gc->fg >= 90 && gc->fg <= 97) { ! if (tty_get_flags(tty) & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->fg); tty_puts(tty, s); } else *************** *** 2596,2602 **** /* Is this an aixterm bright colour? */ if (gc->bg >= 90 && gc->bg <= 97) { ! if (tty->term_flags & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10); tty_puts(tty, s); } else --- 2604,2610 ---- /* Is this an aixterm bright colour? */ if (gc->bg >= 90 && gc->bg <= 97) { ! if (tty_get_flags(tty) & TERM_256COLOURS) { xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10); tty_puts(tty, s); } else *************** *** 2652,2658 **** * 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) || tty_term_has(tty->term, TTYC_RGB)) goto fallback_256; --- 2660,2666 ---- * Also if RGB is set, setaf and setab do not support the 256 * colour palette so use the sequences directly there too. */ ! if ((tty_get_flags(tty) & TERM_256COLOURS) || tty_term_has(tty->term, TTYC_RGB)) goto fallback_256; *************** *** 2660,2666 **** * If the terminfo entry has 256 colours and setaf and setab * exist, assume that they work correctly. */ ! if (tty->term->flags & TERM_256COLOURS) { if (*type == '3') { if (!tty_term_has(tty->term, TTYC_SETAF)) goto fallback_256; --- 2668,2674 ---- * If the terminfo entry has 256 colours and setaf and setab * exist, assume that they work correctly. */ ! if (tty_get_flags(tty) & TERM_256COLOURS) { if (*type == '3') { if (!tty_term_has(tty->term, TTYC_SETAF)) goto fallback_256;