Permalink
Browse files

patch 8.0.1174: Mac Terminal.app has wrong color for white

Problem:    Mac Terminal.app has wrong color for white.
Solution:   Use white from the color cube.
  • Loading branch information...
brammool committed Oct 4, 2017
1 parent 19a3d68 commit a0a6f2776eabfbd4d9174fabdf3921beb7348eda
Showing with 12 additions and 0 deletions.
  1. +3 −0 src/globals.h
  2. +4 −0 src/syntax.c
  3. +3 −0 src/term.c
  4. +2 −0 src/version.c
View
@@ -380,6 +380,9 @@ EXTERN int cterm_normal_bg_color INIT(= 0);
EXTERN guicolor_T cterm_normal_fg_gui_color INIT(= INVALCOLOR);
EXTERN guicolor_T cterm_normal_bg_gui_color INIT(= INVALCOLOR);
#endif
#ifdef FEAT_TERMRESPONSE
EXTERN int is_mac_terminal INIT(= FALSE); /* recognized Terminal.app */
#endif
#ifdef FEAT_AUTOCMD
EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */
View
@@ -7350,6 +7350,10 @@ lookup_color(int idx, int foreground, int *boldp)
else
color = color_numbers_8[idx];
}
if (t_colors >= 256 && color == 15 && is_mac_terminal)
/* Terminal.app has a bug: 15 is light grey. Use white
* from the color cube instead. */
color = 231;
}
return color;
}
View
@@ -4557,7 +4557,10 @@ check_termcode(
/* Mac Terminal.app sends 1;95;0 */
if (version == 95
&& STRNCMP(tp + extra - 2, "1;95;0c", 7) == 0)
{
is_not_xterm = TRUE;
is_mac_terminal = TRUE;
}
/* Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0.
* xfce4-terminal sends 1;2802;0.
View
@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1174,
/**/
1173,
/**/

8 comments on commit a0a6f27

@ichizok

This comment has been minimized.

Show comment
Hide comment
@ichizok

ichizok Oct 5, 2017

https://en.wikipedia.org/wiki/ANSI_escape_code#3.2F4_bit
Terminal.app sets the profile of ANSI color white not to RGB(255,255,255) by default, but this is user-configurable, and so do other some terminal applications (e.g. gnome-terminal with "Tango" profile, on Ubuntu 16.04).
Thus I think should not do this color-correction on vim-side.

ichizok replied Oct 5, 2017

https://en.wikipedia.org/wiki/ANSI_escape_code#3.2F4_bit
Terminal.app sets the profile of ANSI color white not to RGB(255,255,255) by default, but this is user-configurable, and so do other some terminal applications (e.g. gnome-terminal with "Tango" profile, on Ubuntu 16.04).
Thus I think should not do this color-correction on vim-side.

@brammool

This comment has been minimized.

Show comment
Hide comment
@brammool

brammool Oct 5, 2017

Contributor
Contributor

brammool replied Oct 5, 2017

@ichizok

This comment has been minimized.

Show comment
Hide comment
@ichizok

ichizok Oct 5, 2017

Perhaps Terminal.app has a different default for color 15, but then why
does it not get used for the normal background?

There is no terminal-color attribute on Terminal.app window. The window background color is application config, not terminal attribute.

Examples:

When set application background color to grey:

2017-10-05 23 26 56

2017-10-05 23 26 49

The looks of terminal-colors: (color 231, color 15 == ANSI bright white, ANSI white)

2017-10-05 23 40 46

vim --clean

2017-10-05 23 29 49

Vim window has no terminal-color attribute. (:hi Normal ctermbg=NONE)

:hi Normal ctermbg=231 (RGB(255,255,255))

2017-10-05 23 27 32

:hi Normal ctermbg=15 (ANSI bright white, RGB(230,230,230) by Terminal.app)

2017-10-05 23 27 43

On the other hand, :terminal window uses ANSI bright white on background (set bg=light).

2017-10-05 23 39 50

ichizok replied Oct 5, 2017

Perhaps Terminal.app has a different default for color 15, but then why
does it not get used for the normal background?

There is no terminal-color attribute on Terminal.app window. The window background color is application config, not terminal attribute.

Examples:

When set application background color to grey:

2017-10-05 23 26 56

2017-10-05 23 26 49

The looks of terminal-colors: (color 231, color 15 == ANSI bright white, ANSI white)

2017-10-05 23 40 46

vim --clean

2017-10-05 23 29 49

Vim window has no terminal-color attribute. (:hi Normal ctermbg=NONE)

:hi Normal ctermbg=231 (RGB(255,255,255))

2017-10-05 23 27 32

:hi Normal ctermbg=15 (ANSI bright white, RGB(230,230,230) by Terminal.app)

2017-10-05 23 27 43

On the other hand, :terminal window uses ANSI bright white on background (set bg=light).

2017-10-05 23 39 50

@ichizok

This comment has been minimized.

Show comment
Hide comment
@ichizok

ichizok Oct 5, 2017

NOTE: The above Vim is 8.0.1173.

If I can change libvterm sources, I will propose the patch to set the terminal background to no-color attribute.

Example:

When set "Grass" theme of Terminal.app:

2017-10-06 0 12 30

vim --clean (8.0.1172 with patch) and :term bash

2017-10-06 0 12 39

:terminal window has no terminal-color attribute by default. This is same as application background color.

:hi Terminal ctermbg=Black

2017-10-06 0 17 53

ichizok replied Oct 5, 2017

NOTE: The above Vim is 8.0.1173.

If I can change libvterm sources, I will propose the patch to set the terminal background to no-color attribute.

Example:

When set "Grass" theme of Terminal.app:

2017-10-06 0 12 30

vim --clean (8.0.1172 with patch) and :term bash

2017-10-06 0 12 39

:terminal window has no terminal-color attribute by default. This is same as application background color.

:hi Terminal ctermbg=Black

2017-10-06 0 17 53

@mgedmin

This comment has been minimized.

Show comment
Hide comment
@mgedmin

mgedmin Oct 5, 2017

FWIW I don't think this is specific to Terminal.app. gnome-terminal, for example, uses a different background color for ESC [ 48;5;15 m than for ESC [ 0 m or ESC [ 49 m:
ekrano nuotrauka is 2017-10-05 18-29-10

mgedmin replied Oct 5, 2017

FWIW I don't think this is specific to Terminal.app. gnome-terminal, for example, uses a different background color for ESC [ 48;5;15 m than for ESC [ 0 m or ESC [ 49 m:
ekrano nuotrauka is 2017-10-05 18-29-10

@brammool

This comment has been minimized.

Show comment
Hide comment
@brammool

brammool Oct 5, 2017

Contributor
Contributor

brammool replied Oct 5, 2017

@ichizok

This comment has been minimized.

Show comment
Hide comment
@ichizok

ichizok Oct 7, 2017

The terminal window is similaring an xterm, not a Terminal.app. It
either has white or black background, it doesn't follow the color scheme
you set for the Terminal app. You can't have a "no color" color, it
must always be clear what color is actually being used.

Hmm.. I don't quite understand why the terminal window should not pass through the application background color and has to be black or white background. Though the normal Vim window passes though by default.
Or does this aim to distinguish the terminal and normal windows?

BTW, I think it need not limit this color correction (15 → 231) limit to Terminal.app if the terminal window background must be RBG(255,255,255) white (when bg=light).

ichizok replied Oct 7, 2017

The terminal window is similaring an xterm, not a Terminal.app. It
either has white or black background, it doesn't follow the color scheme
you set for the Terminal app. You can't have a "no color" color, it
must always be clear what color is actually being used.

Hmm.. I don't quite understand why the terminal window should not pass through the application background color and has to be black or white background. Though the normal Vim window passes though by default.
Or does this aim to distinguish the terminal and normal windows?

BTW, I think it need not limit this color correction (15 → 231) limit to Terminal.app if the terminal window background must be RBG(255,255,255) white (when bg=light).

@brammool

This comment has been minimized.

Show comment
Hide comment
@brammool

brammool Oct 7, 2017

Contributor
Contributor

brammool replied Oct 7, 2017

Please sign in to comment.