aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com>2017-05-27 12:38:14 +0100
committerJonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com>2017-06-03 18:53:28 +0100
commit16300d02c7fbe95396697fc6c09012e2c2b47b69 (patch)
tree0ad044491f2d66b5c363de3d7fa53b6a02749fc7 /src
parent67e2120459268494c589cc5be6a20b05fdd9ca84 (diff)
downloadrneovim-16300d02c7fbe95396697fc6c09012e2c2b47b69.tar.gz
rneovim-16300d02c7fbe95396697fc6c09012e2c2b47b69.tar.bz2
rneovim-16300d02c7fbe95396697fc6c09012e2c2b47b69.zip
tui: Improvements to RGB colour support.
The details are in the on-line help under :help true-color . The brief precis is that nvim is (I hope.) converging with tmux and libvte. It is taking the same approach with setrgbf and setrgbb terminfo capabilities that it does with the Ss and Se terminfo capabilities.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/tui/tui.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 58c9e75de8..3c985bcbcb 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -2447,7 +2447,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
// Dickey ncurses terminfo has included the Ss and Se capabilities, pioneered
// by tmux, since 2011-07-14. So adding them to terminal types, that do
- // actually have such control sequences but lack the currect definitions in
+ // actually have such control sequences but lack the correct definitions in
// terminfo, is a fixup, not an augmentation.
data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se");
data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss");
@@ -2479,7 +2479,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
// form.
data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss",
"\x1b[%?"
- "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values
+ "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values
"%e%p1" // the conventional codes are just passed through
"%;%d q");
if (-1 == data->unibi_ext.reset_cursor_style) {
@@ -2537,6 +2537,7 @@ static void augment_terminfo(TUIData *data, const char *term,
const char *colorterm, long vte_version, bool konsole, bool iterm)
{
unibi_term *ut = data->ut;
+ bool true_xterm = !!os_getenv("XTERM_VERSION");
bool xterm = term && STARTS_WITH(term, "xterm");
bool dtterm = term && STARTS_WITH(term, "dtterm");
bool linuxvt = term && STARTS_WITH(term, "linux");
@@ -2544,6 +2545,7 @@ static void augment_terminfo(TUIData *data, const char *term,
bool teraterm = term && STARTS_WITH(term, "teraterm");
bool putty = term && STARTS_WITH(term, "putty");
bool screen = term && STARTS_WITH(term, "screen");
+ bool st = term && STARTS_WITH(term, "st");
bool tmux_wrap = screen && !!os_getenv("TMUX");
bool truecolor = colorterm
&& (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit"));
@@ -2561,13 +2563,43 @@ static void augment_terminfo(TUIData *data, const char *term,
data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL,
"\x1b[r");
}
- // See https://gist.github.com/XVilka/8346728 for more about this.
- if (putty || xterm || rxvt || linuxvt || konsole || iterm || truecolor) {
- data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, NULL,
- "\x1b[38;2;%p1%d;%p2%d;%p3%dm");
- data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL,
- "\x1b[48;2;%p1%d;%p2%d;%p3%dm");
+
+ // Dickey ncurses terminfo does not include the setrgbf and setrgbb
+ // capabilities, proposed by RĂ¼diger Sonderfeld on 2013-10-15. So adding
+ // them to terminal types, that do actually have such control sequences but
+ // lack the correct definitions in terminfo, is an augmentation, not a
+ // fixup. See https://gist.github.com/XVilka/8346728 for more about this.
+ bool has_standard_rgb = vte_version >= 3600 // per GNOME bug #685759
+ || true_xterm;
+ // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says.
+ bool has_non_standard_rgb =
+ linuxvt // Linux 4.8+ supports true-colour SGR.
+ || konsole // per commentary in VT102Emulation.cpp
+ // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
+ || rxvt
+ || st // per experimentation
+ || iterm || truecolor;
+ data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf");
+ if (-1 == data->unibi_ext.set_rgb_foreground) {
+ if (has_standard_rgb) {
+ data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf",
+ "\x1b[38:2:%p1%d:%p2%d:%p3%dm");
+ } else if (has_non_standard_rgb) {
+ data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf",
+ "\x1b[38;2;%p1%d;%p2%d;%p3%dm");
+ }
+ }
+ data->unibi_ext.set_rgb_background = unibi_find_ext_str(ut, "setrgbb");
+ if (-1 == data->unibi_ext.set_rgb_background) {
+ if (has_standard_rgb) {
+ data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb",
+ "\x1b[48:2:%p1%d:%p2%d:%p3%dm");
+ } else if (has_non_standard_rgb) {
+ data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb",
+ "\x1b[48;2;%p1%d;%p2%d;%p3%dm");
+ }
}
+
if (iterm) {
data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str(
ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\"));