Add a feature for bracketed paste.

This commit is contained in:
Nicholas Marriott 2020-04-24 07:13:02 +01:00
parent 2d8fd35de2
commit 5d69b9c4a7
5 changed files with 29 additions and 11 deletions

2
tmux.1
View File

@ -5568,6 +5568,8 @@ $ printf '\e033]12;red\e033\e\e'
.Ed
.It Em \&Cmg, \&Clmg, \&Dsmg , \&Enmg
Set, clear, disable or enable DECSLRM margins.
.It Em \&Dsbp , \&Enbp
Disable and enable bracketed paste.
.It Em \&Smol
Enable the overline attribute.
.It Em \&Smulx

2
tmux.h
View File

@ -281,6 +281,7 @@ enum tty_code_code {
TTYC_DIM,
TTYC_DL,
TTYC_DL1,
TTYC_DSBP,
TTYC_DSMG,
TTYC_E3,
TTYC_ECH,
@ -288,6 +289,7 @@ enum tty_code_code {
TTYC_EL,
TTYC_EL1,
TTYC_ENACS,
TTYC_ENBP,
TTYC_ENMG,
TTYC_FSL,
TTYC_HOME,

View File

@ -25,7 +25,6 @@
/*
* Still hardcoded:
* - bracket paste (sent if application asks for it);
* - mouse (under kmous capability);
* - focus events (under XT and focus-events option);
* - default colours (under AX or op capabilities);
@ -123,6 +122,18 @@ static struct tty_feature tty_feature_usstyle = {
0
};
/* Terminal supports cursor bracketed paste. */
static const char *tty_feature_bpaste_capabilities[] = {
"Enbp=\E[?2004h",
"Dsbp=\\E[?2004l",
NULL
};
static struct tty_feature tty_feature_bpaste = {
"bpaste",
tty_feature_bpaste_capabilities,
0
};
/* Terminal supports cursor styles. */
static const char *tty_feature_cstyle_capabilities[] = {
"Ss=\\E[%p1%d q",
@ -193,6 +204,7 @@ static struct tty_feature tty_feature_rectfill = {
/* Available terminal features. */
static const struct tty_feature *tty_features[] = {
&tty_feature_256,
&tty_feature_bpaste,
&tty_feature_clipboard,
&tty_feature_ccolour,
&tty_feature_cstyle,
@ -297,19 +309,19 @@ tty_default_features(int *feat, const char *name, u_int version)
const char *features;
} table[] = {
{ .name = "mintty",
.features = "256,RGB,ccolour,clipboard,cstyle,margins,strikethrough,overline,title"
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,margins,overline,strikethrough,title"
},
{ .name = "tmux",
.features = "256,RGB,ccolour,clipboard,cstyle,overline,strikethough,title,usstyle"
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,overline,strikethough,title,usstyle"
},
{ .name = "rxvt-unicode",
.features = "256,title"
},
{ .name = "iTerm2",
.features = "256,RGB,clipboard,cstyle,margins,strikethrough,sync,title"
.features = "256,RGB,bpaste,clipboard,cstyle,margins,strikethrough,sync,title"
},
{ .name = "XTerm",
.features = "256,RGB,ccolour,clipboard,cstyle,margins,rectfill,strikethrough,title"
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,margins,rectfill,strikethrough,title"
}
};
u_int i;

View File

@ -86,6 +86,7 @@ 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_DSBP] = { TTYCODE_STRING, "Dsbp" },
[TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
[TTYC_E3] = { TTYCODE_STRING, "E3" },
[TTYC_ECH] = { TTYCODE_STRING, "ech" },
@ -93,6 +94,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_EL1] = { TTYCODE_STRING, "el1" },
[TTYC_EL] = { TTYCODE_STRING, "el" },
[TTYC_ENACS] = { TTYCODE_STRING, "enacs" },
[TTYC_ENBP] = { TTYCODE_STRING, "Enbp" },
[TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
[TTYC_FSL] = { TTYCODE_STRING, "fsl" },
[TTYC_HOME] = { TTYCODE_STRING, "home" },
@ -561,11 +563,11 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
if ((tty_term_flag(term, TTYC_TC) || tty_term_has(term, TTYC_RGB)) &&
(!tty_term_has(term, TTYC_SETRGBF) ||
!tty_term_has(term, TTYC_SETRGBB)))
tty_add_features(feat, "RGB", ":,");
tty_add_features(feat, "RGB", ",");
/* Add feature if terminal has XT. */
/* Add some features if terminal has XT. */
if (tty_term_flag(term, TTYC_XT))
tty_add_features(feat, "title", ":,");
tty_add_features(feat, "bpaste,title", ",");
/* Apply the features and overrides again. */
tty_apply_features(term, *feat);

6
tty.c
View File

@ -407,7 +407,7 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, tty_term_string1(tty->term, TTYC_SS, 0));
}
if (tty->mode & MODE_BRACKETPASTE)
tty_raw(tty, "\033[?2004l");
tty_raw(tty, tty_term_string(tty->term, TTYC_DSBP));
if (*tty->ccolour != '\0')
tty_raw(tty, tty_term_string(tty->term, TTYC_CR));
@ -729,9 +729,9 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
}
if (changed & MODE_BRACKETPASTE) {
if (mode & MODE_BRACKETPASTE)
tty_puts(tty, "\033[?2004h");
tty_putcode(tty, TTYC_ENBP);
else
tty_puts(tty, "\033[?2004l");
tty_putcode(tty, TTYC_DSBP);
}
tty->mode = mode;
}