From 5d69b9c4a7e8adc570e965189de0e5936fbf8e1c Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 24 Apr 2020 07:13:02 +0100 Subject: Add a feature for bracketed paste. --- tmux.1 | 2 ++ tmux.h | 2 ++ tty-features.c | 22 +++++++++++++++++----- tty-term.c | 8 +++++--- tty.c | 6 +++--- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/tmux.1 b/tmux.1 index dcb6f4c4..cd7c0869 100644 --- a/tmux.1 +++ b/tmux.1 @@ -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 diff --git a/tmux.h b/tmux.h index 85276aea..b9f48dd7 100644 --- a/tmux.h +++ b/tmux.h @@ -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, diff --git a/tty-features.c b/tty-features.c index b0e4b8ca..6dfc26aa 100644 --- a/tty-features.c +++ b/tty-features.c @@ -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; diff --git a/tty-term.c b/tty-term.c index 20022fd9..102359f1 100644 --- a/tty-term.c +++ b/tty-term.c @@ -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); diff --git a/tty.c b/tty.c index 5d84c9e8..7e044540 100644 --- a/tty.c +++ b/tty.c @@ -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; } -- cgit v1.2.3