diff --git a/tmux.1 b/tmux.1 index a519b6b5..daa0739c 100644 --- a/tmux.1 +++ b/tmux.1 @@ -5565,6 +5565,8 @@ to change the cursor colour from inside .Bd -literal -offset indent $ printf '\e033]12;red\e033\e\e' .Ed +.It Em \&Cmg, \&Clmg, \&Dsmg , \&Enmg +Set, clear, disable or enable DECSLRM margins. .It Em \&Smol Enable the overline attribute. .It Em \&Smulx diff --git a/tmux.h b/tmux.h index c58be54f..97024310 100644 --- a/tmux.h +++ b/tmux.h @@ -254,6 +254,8 @@ enum tty_code_code { TTYC_BOLD, TTYC_CIVIS, TTYC_CLEAR, + TTYC_CLMG, + TTYC_CMG, TTYC_CNORM, TTYC_COLORS, TTYC_CR, @@ -274,12 +276,14 @@ enum tty_code_code { TTYC_DIM, TTYC_DL, TTYC_DL1, + TTYC_DSMG, TTYC_E3, TTYC_ECH, TTYC_ED, TTYC_EL, TTYC_EL1, TTYC_ENACS, + TTYC_ENMG, TTYC_FSL, TTYC_HOME, TTYC_HPA, @@ -445,11 +449,11 @@ enum tty_code_code { TTYC_SITM, TTYC_SMACS, TTYC_SMCUP, - TTYC_SMOL, TTYC_SMKX, + TTYC_SMOL, TTYC_SMSO, - TTYC_SMULX, TTYC_SMUL, + TTYC_SMULX, TTYC_SMXX, TTYC_SS, TTYC_SYNC, @@ -458,7 +462,7 @@ enum tty_code_code { TTYC_U8, TTYC_VPA, TTYC_XENL, - TTYC_XT, + TTYC_XT }; /* Message codes. */ diff --git a/tty-features.c b/tty-features.c index a7f2a4b0..9eb446d4 100644 --- a/tty-features.c +++ b/tty-features.c @@ -34,7 +34,7 @@ * * Also: * - XT is used to decide whether to send DA and XDA; - * - DECSLRM and DECFRA use a flag instead of capabilities; + * - DECFRA uses a flag instead of capabilities; * - UTF-8 is a separate flag on the client; needed for unattached clients. */ @@ -84,7 +84,7 @@ static const char *tty_feature_rgb_capabilities[] = { static struct tty_feature tty_feature_rgb = { "RGB", tty_feature_rgb_capabilities, - (TERM_256COLOURS|TERM_RGBCOLOURS) + TERM_256COLOURS|TERM_RGBCOLOURS }; /* Terminal supports 256 colours. */ @@ -159,9 +159,16 @@ static struct tty_feature tty_feature_sync = { }; /* Terminal supports DECSLRM margins. */ +static const char *tty_feature_margins_capabilities[] = { + "Enmg=\\E[?69h", + "Dsmg=\\E[?69l", + "Clmg=\\E[s", + "Cmg=\\E[%i%p1%d;%p2%ds", + NULL +}; static struct tty_feature tty_feature_margins = { "margins", - NULL, + tty_feature_margins_capabilities, TERM_DECSLRM }; @@ -194,6 +201,8 @@ tty_add_features(int *feat, const char *s, const char *separators) char *next, *loop, *copy; u_int i; + log_debug("%s: %s", __func__, s); + loop = copy = xstrdup(s); while ((next = strsep(&loop, separators)) != NULL) { for (i = 0; i < nitems(tty_features); i++) { diff --git a/tty-term.c b/tty-term.c index f3dbae5c..78ba5a37 100644 --- a/tty-term.c +++ b/tty-term.c @@ -61,6 +61,8 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_BOLD] = { TTYCODE_STRING, "bold" }, [TTYC_CIVIS] = { TTYCODE_STRING, "civis" }, [TTYC_CLEAR] = { TTYCODE_STRING, "clear" }, + [TTYC_CLMG] = { TTYCODE_STRING, "Clmg" }, + [TTYC_CMG] = { TTYCODE_STRING, "Cmg" }, [TTYC_CNORM] = { TTYCODE_STRING, "cnorm" }, [TTYC_COLORS] = { TTYCODE_NUMBER, "colors" }, [TTYC_CR] = { TTYCODE_STRING, "Cr" }, @@ -81,12 +83,14 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_DIM] = { TTYCODE_STRING, "dim" }, [TTYC_DL1] = { TTYCODE_STRING, "dl1" }, [TTYC_DL] = { TTYCODE_STRING, "dl" }, + [TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" }, [TTYC_E3] = { TTYCODE_STRING, "E3" }, [TTYC_ECH] = { TTYCODE_STRING, "ech" }, [TTYC_ED] = { TTYCODE_STRING, "ed" }, [TTYC_EL1] = { TTYCODE_STRING, "el1" }, [TTYC_EL] = { TTYCODE_STRING, "el" }, [TTYC_ENACS] = { TTYCODE_STRING, "enacs" }, + [TTYC_ENMG] = { TTYCODE_STRING, "Enmg" }, [TTYC_FSL] = { TTYCODE_STRING, "fsl" }, [TTYC_HOME] = { TTYCODE_STRING, "home" }, [TTYC_HPA] = { TTYCODE_STRING, "hpa" }, @@ -237,8 +241,8 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_OP] = { TTYCODE_STRING, "op" }, [TTYC_REV] = { TTYCODE_STRING, "rev" }, [TTYC_RGB] = { TTYCODE_FLAG, "RGB" }, - [TTYC_RI] = { TTYCODE_STRING, "ri" }, [TTYC_RIN] = { TTYCODE_STRING, "rin" }, + [TTYC_RI] = { TTYCODE_STRING, "ri" }, [TTYC_RMACS] = { TTYCODE_STRING, "rmacs" }, [TTYC_RMCUP] = { TTYCODE_STRING, "rmcup" }, [TTYC_RMKX] = { TTYCODE_STRING, "rmkx" }, @@ -265,7 +269,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_U8] = { TTYCODE_NUMBER, "U8" }, [TTYC_VPA] = { TTYCODE_STRING, "vpa" }, [TTYC_XENL] = { TTYCODE_FLAG, "xenl" }, - [TTYC_XT] = { TTYCODE_FLAG, "XT" }, + [TTYC_XT] = { TTYCODE_FLAG, "XT" } }; u_int diff --git a/tty.c b/tty.c index 5d7d2c0d..5d84c9e8 100644 --- a/tty.c +++ b/tty.c @@ -426,7 +426,7 @@ tty_stop_tty(struct tty *tty) } if (tty_use_margin(tty)) - tty_raw(tty, "\033[?69l"); /* DECLRMM */ + tty_raw(tty, tty_term_string(tty->term, TTYC_DSMG)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); setblocking(tty->fd, 1); @@ -473,7 +473,7 @@ tty_update_features(struct tty *tty) tty_term_apply_overrides(tty->term); if (tty_use_margin(tty)) - tty_puts(tty, "\033[?69h"); /* DECLRMM */ + tty_putcode(tty, TTYC_ENMG); } void @@ -2028,7 +2028,7 @@ tty_invalidate(struct tty *tty) if (tty->flags & TTY_STARTED) { if (tty_use_margin(tty)) - tty_puts(tty, "\033[?69h"); /* DECLRMM */ + tty_putcode(tty, TTYC_ENMG); tty_putcode(tty, TTYC_SGR0); tty->mode = ALL_MODES; @@ -2105,8 +2105,6 @@ tty_margin_pane(struct tty *tty, const struct tty_ctx *ctx) static void tty_margin(struct tty *tty, u_int rleft, u_int rright) { - char s[64]; - if (!tty_use_margin(tty)) return; if (tty->rleft == rleft && tty->rright == rright) @@ -2118,10 +2116,9 @@ tty_margin(struct tty *tty, u_int rleft, u_int rright) tty->rright = rright; if (rleft == 0 && rright == tty->sx - 1) - snprintf(s, sizeof s, "\033[s"); + tty_putcode(tty, TTYC_CLMG); else - snprintf(s, sizeof s, "\033[%u;%us", rleft + 1, rright + 1); - tty_puts(tty, s); + tty_putcode2(tty, TTYC_CMG, rleft, rright); tty->cx = tty->cy = UINT_MAX; } diff --git a/window-copy.c b/window-copy.c index 2bda5d56..a803f3b3 100644 --- a/window-copy.c +++ b/window-copy.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "tmux.h"