Add extension terminfo(5) capabilities for margins.

This commit is contained in:
nicm 2020-05-16 14:22:51 +00:00
parent 41dec585df
commit 4e0a718666
6 changed files with 33 additions and 16 deletions

2
tmux.1
View File

@ -5565,6 +5565,8 @@ to change the cursor colour from inside
.Bd -literal -offset indent .Bd -literal -offset indent
$ printf '\e033]12;red\e033\e\e' $ printf '\e033]12;red\e033\e\e'
.Ed .Ed
.It Em \&Cmg, \&Clmg, \&Dsmg , \&Enmg
Set, clear, disable or enable DECSLRM margins.
.It Em \&Smol .It Em \&Smol
Enable the overline attribute. Enable the overline attribute.
.It Em \&Smulx .It Em \&Smulx

10
tmux.h
View File

@ -254,6 +254,8 @@ enum tty_code_code {
TTYC_BOLD, TTYC_BOLD,
TTYC_CIVIS, TTYC_CIVIS,
TTYC_CLEAR, TTYC_CLEAR,
TTYC_CLMG,
TTYC_CMG,
TTYC_CNORM, TTYC_CNORM,
TTYC_COLORS, TTYC_COLORS,
TTYC_CR, TTYC_CR,
@ -274,12 +276,14 @@ enum tty_code_code {
TTYC_DIM, TTYC_DIM,
TTYC_DL, TTYC_DL,
TTYC_DL1, TTYC_DL1,
TTYC_DSMG,
TTYC_E3, TTYC_E3,
TTYC_ECH, TTYC_ECH,
TTYC_ED, TTYC_ED,
TTYC_EL, TTYC_EL,
TTYC_EL1, TTYC_EL1,
TTYC_ENACS, TTYC_ENACS,
TTYC_ENMG,
TTYC_FSL, TTYC_FSL,
TTYC_HOME, TTYC_HOME,
TTYC_HPA, TTYC_HPA,
@ -445,11 +449,11 @@ enum tty_code_code {
TTYC_SITM, TTYC_SITM,
TTYC_SMACS, TTYC_SMACS,
TTYC_SMCUP, TTYC_SMCUP,
TTYC_SMOL,
TTYC_SMKX, TTYC_SMKX,
TTYC_SMOL,
TTYC_SMSO, TTYC_SMSO,
TTYC_SMULX,
TTYC_SMUL, TTYC_SMUL,
TTYC_SMULX,
TTYC_SMXX, TTYC_SMXX,
TTYC_SS, TTYC_SS,
TTYC_SYNC, TTYC_SYNC,
@ -458,7 +462,7 @@ enum tty_code_code {
TTYC_U8, TTYC_U8,
TTYC_VPA, TTYC_VPA,
TTYC_XENL, TTYC_XENL,
TTYC_XT, TTYC_XT
}; };
/* Message codes. */ /* Message codes. */

View File

@ -34,7 +34,7 @@
* *
* Also: * Also:
* - XT is used to decide whether to send DA and XDA; * - 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. * - 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 = { static struct tty_feature tty_feature_rgb = {
"RGB", "RGB",
tty_feature_rgb_capabilities, tty_feature_rgb_capabilities,
(TERM_256COLOURS|TERM_RGBCOLOURS) TERM_256COLOURS|TERM_RGBCOLOURS
}; };
/* Terminal supports 256 colours. */ /* Terminal supports 256 colours. */
@ -159,9 +159,16 @@ static struct tty_feature tty_feature_sync = {
}; };
/* Terminal supports DECSLRM margins. */ /* 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 = { static struct tty_feature tty_feature_margins = {
"margins", "margins",
NULL, tty_feature_margins_capabilities,
TERM_DECSLRM TERM_DECSLRM
}; };
@ -194,6 +201,8 @@ tty_add_features(int *feat, const char *s, const char *separators)
char *next, *loop, *copy; char *next, *loop, *copy;
u_int i; u_int i;
log_debug("%s: %s", __func__, s);
loop = copy = xstrdup(s); loop = copy = xstrdup(s);
while ((next = strsep(&loop, separators)) != NULL) { while ((next = strsep(&loop, separators)) != NULL) {
for (i = 0; i < nitems(tty_features); i++) { for (i = 0; i < nitems(tty_features); i++) {

View File

@ -61,6 +61,8 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_BOLD] = { TTYCODE_STRING, "bold" }, [TTYC_BOLD] = { TTYCODE_STRING, "bold" },
[TTYC_CIVIS] = { TTYCODE_STRING, "civis" }, [TTYC_CIVIS] = { TTYCODE_STRING, "civis" },
[TTYC_CLEAR] = { TTYCODE_STRING, "clear" }, [TTYC_CLEAR] = { TTYCODE_STRING, "clear" },
[TTYC_CLMG] = { TTYCODE_STRING, "Clmg" },
[TTYC_CMG] = { TTYCODE_STRING, "Cmg" },
[TTYC_CNORM] = { TTYCODE_STRING, "cnorm" }, [TTYC_CNORM] = { TTYCODE_STRING, "cnorm" },
[TTYC_COLORS] = { TTYCODE_NUMBER, "colors" }, [TTYC_COLORS] = { TTYCODE_NUMBER, "colors" },
[TTYC_CR] = { TTYCODE_STRING, "Cr" }, [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_DIM] = { TTYCODE_STRING, "dim" },
[TTYC_DL1] = { TTYCODE_STRING, "dl1" }, [TTYC_DL1] = { TTYCODE_STRING, "dl1" },
[TTYC_DL] = { TTYCODE_STRING, "dl" }, [TTYC_DL] = { TTYCODE_STRING, "dl" },
[TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
[TTYC_E3] = { TTYCODE_STRING, "E3" }, [TTYC_E3] = { TTYCODE_STRING, "E3" },
[TTYC_ECH] = { TTYCODE_STRING, "ech" }, [TTYC_ECH] = { TTYCODE_STRING, "ech" },
[TTYC_ED] = { TTYCODE_STRING, "ed" }, [TTYC_ED] = { TTYCODE_STRING, "ed" },
[TTYC_EL1] = { TTYCODE_STRING, "el1" }, [TTYC_EL1] = { TTYCODE_STRING, "el1" },
[TTYC_EL] = { TTYCODE_STRING, "el" }, [TTYC_EL] = { TTYCODE_STRING, "el" },
[TTYC_ENACS] = { TTYCODE_STRING, "enacs" }, [TTYC_ENACS] = { TTYCODE_STRING, "enacs" },
[TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
[TTYC_FSL] = { TTYCODE_STRING, "fsl" }, [TTYC_FSL] = { TTYCODE_STRING, "fsl" },
[TTYC_HOME] = { TTYCODE_STRING, "home" }, [TTYC_HOME] = { TTYCODE_STRING, "home" },
[TTYC_HPA] = { TTYCODE_STRING, "hpa" }, [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_OP] = { TTYCODE_STRING, "op" },
[TTYC_REV] = { TTYCODE_STRING, "rev" }, [TTYC_REV] = { TTYCODE_STRING, "rev" },
[TTYC_RGB] = { TTYCODE_FLAG, "RGB" }, [TTYC_RGB] = { TTYCODE_FLAG, "RGB" },
[TTYC_RI] = { TTYCODE_STRING, "ri" },
[TTYC_RIN] = { TTYCODE_STRING, "rin" }, [TTYC_RIN] = { TTYCODE_STRING, "rin" },
[TTYC_RI] = { TTYCODE_STRING, "ri" },
[TTYC_RMACS] = { TTYCODE_STRING, "rmacs" }, [TTYC_RMACS] = { TTYCODE_STRING, "rmacs" },
[TTYC_RMCUP] = { TTYCODE_STRING, "rmcup" }, [TTYC_RMCUP] = { TTYCODE_STRING, "rmcup" },
[TTYC_RMKX] = { TTYCODE_STRING, "rmkx" }, [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_U8] = { TTYCODE_NUMBER, "U8" },
[TTYC_VPA] = { TTYCODE_STRING, "vpa" }, [TTYC_VPA] = { TTYCODE_STRING, "vpa" },
[TTYC_XENL] = { TTYCODE_FLAG, "xenl" }, [TTYC_XENL] = { TTYCODE_FLAG, "xenl" },
[TTYC_XT] = { TTYCODE_FLAG, "XT" }, [TTYC_XT] = { TTYCODE_FLAG, "XT" }
}; };
u_int u_int

13
tty.c
View File

@ -426,7 +426,7 @@ tty_stop_tty(struct tty *tty)
} }
if (tty_use_margin(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)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
setblocking(tty->fd, 1); setblocking(tty->fd, 1);
@ -473,7 +473,7 @@ tty_update_features(struct tty *tty)
tty_term_apply_overrides(tty->term); tty_term_apply_overrides(tty->term);
if (tty_use_margin(tty)) if (tty_use_margin(tty))
tty_puts(tty, "\033[?69h"); /* DECLRMM */ tty_putcode(tty, TTYC_ENMG);
} }
void void
@ -2028,7 +2028,7 @@ tty_invalidate(struct tty *tty)
if (tty->flags & TTY_STARTED) { if (tty->flags & TTY_STARTED) {
if (tty_use_margin(tty)) if (tty_use_margin(tty))
tty_puts(tty, "\033[?69h"); /* DECLRMM */ tty_putcode(tty, TTYC_ENMG);
tty_putcode(tty, TTYC_SGR0); tty_putcode(tty, TTYC_SGR0);
tty->mode = ALL_MODES; tty->mode = ALL_MODES;
@ -2105,8 +2105,6 @@ tty_margin_pane(struct tty *tty, const struct tty_ctx *ctx)
static void static void
tty_margin(struct tty *tty, u_int rleft, u_int rright) tty_margin(struct tty *tty, u_int rleft, u_int rright)
{ {
char s[64];
if (!tty_use_margin(tty)) if (!tty_use_margin(tty))
return; return;
if (tty->rleft == rleft && tty->rright == rright) 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; tty->rright = rright;
if (rleft == 0 && rright == tty->sx - 1) if (rleft == 0 && rright == tty->sx - 1)
snprintf(s, sizeof s, "\033[s"); tty_putcode(tty, TTYC_CLMG);
else else
snprintf(s, sizeof s, "\033[%u;%us", rleft + 1, rright + 1); tty_putcode2(tty, TTYC_CMG, rleft, rright);
tty_puts(tty, s);
tty->cx = tty->cy = UINT_MAX; tty->cx = tty->cy = UINT_MAX;
} }

View File

@ -22,6 +22,7 @@
#include <regex.h> #include <regex.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "tmux.h" #include "tmux.h"