summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-04-27 20:36:31 +0200
committerBram Moolenaar <Bram@vim.org>2016-04-27 20:36:31 +0200
commit283ee8b3a07b9da18f6c73f35cf465b83f96406a (patch)
treecdaff089d245be0e52870ea7cd9cf8dbdf7f4dcc /src/term.c
parent5487544fa5d46af9f8f98aa4f5c59074a6e0639a (diff)
downloadvim-git-283ee8b3a07b9da18f6c73f35cf465b83f96406a.tar.gz
patch 7.4.1796v7.4.1796
Problem: Colors are wrong on MS-Windows. (Christian Robinson) Solution: Use existing RGB macro if it exists. (Ken Takata)
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c112
1 files changed, 58 insertions, 54 deletions
diff --git a/src/term.c b/src/term.c
index fca83333e..61200d2cd 100644
--- a/src/term.c
+++ b/src/term.c
@@ -6068,8 +6068,12 @@ hex_digit(int c)
guicolor_T
gui_get_color_cmn(char_u *name)
{
-#define TORGB(r, g, b) ((r<<16) | (g<<8) | (b))
-#define LINE_LEN 100
+ /* On MS-Windows an RGB macro is available and it's different from ours,
+ * but does what is needed. */
+# ifndef RGB
+# define RGB(r, g, b) ((r<<16) | (g<<8) | (b))
+# endif
+# define LINE_LEN 100
FILE *fd;
char line[LINE_LEN];
char_u *fname;
@@ -6082,63 +6086,63 @@ gui_get_color_cmn(char_u *name)
};
static struct rgbcolor_table_S rgb_table[] = {
- {(char_u *)"black", TORGB(0x00, 0x00, 0x00)},
- {(char_u *)"blue", TORGB(0x00, 0x00, 0xFF)},
- {(char_u *)"brown", TORGB(0xA5, 0x2A, 0x2A)},
- {(char_u *)"cyan", TORGB(0x00, 0xFF, 0xFF)},
- {(char_u *)"darkblue", TORGB(0x00, 0x00, 0x8B)},
- {(char_u *)"darkcyan", TORGB(0x00, 0x8B, 0x8B)},
- {(char_u *)"darkgray", TORGB(0xA9, 0xA9, 0xA9)},
- {(char_u *)"darkgreen", TORGB(0x00, 0x64, 0x00)},
- {(char_u *)"darkgrey", TORGB(0xA9, 0xA9, 0xA9)},
- {(char_u *)"darkmagenta", TORGB(0x8B, 0x00, 0x8B)},
- {(char_u *)"darkred", TORGB(0x8B, 0x00, 0x00)},
- {(char_u *)"darkyellow", TORGB(0x8B, 0x8B, 0x00)}, /* No X11 */
- {(char_u *)"gray", TORGB(0xBE, 0xBE, 0xBE)},
- {(char_u *)"gray10", TORGB(0x1A, 0x1A, 0x1A)},
- {(char_u *)"gray20", TORGB(0x33, 0x33, 0x33)},
- {(char_u *)"gray30", TORGB(0x4D, 0x4D, 0x4D)},
- {(char_u *)"gray40", TORGB(0x66, 0x66, 0x66)},
- {(char_u *)"gray50", TORGB(0x7F, 0x7F, 0x7F)},
- {(char_u *)"gray60", TORGB(0x99, 0x99, 0x99)},
- {(char_u *)"gray70", TORGB(0xB3, 0xB3, 0xB3)},
- {(char_u *)"gray80", TORGB(0xCC, 0xCC, 0xCC)},
- {(char_u *)"gray90", TORGB(0xE5, 0xE5, 0xE5)},
- {(char_u *)"green", TORGB(0x00, 0xFF, 0x00)},
- {(char_u *)"grey", TORGB(0xBE, 0xBE, 0xBE)},
- {(char_u *)"grey10", TORGB(0x1A, 0x1A, 0x1A)},
- {(char_u *)"grey20", TORGB(0x33, 0x33, 0x33)},
- {(char_u *)"grey30", TORGB(0x4D, 0x4D, 0x4D)},
- {(char_u *)"grey40", TORGB(0x66, 0x66, 0x66)},
- {(char_u *)"grey50", TORGB(0x7F, 0x7F, 0x7F)},
- {(char_u *)"grey60", TORGB(0x99, 0x99, 0x99)},
- {(char_u *)"grey70", TORGB(0xB3, 0xB3, 0xB3)},
- {(char_u *)"grey80", TORGB(0xCC, 0xCC, 0xCC)},
- {(char_u *)"grey90", TORGB(0xE5, 0xE5, 0xE5)},
- {(char_u *)"lightblue", TORGB(0xAD, 0xD8, 0xE6)},
- {(char_u *)"lightcyan", TORGB(0xE0, 0xFF, 0xFF)},
- {(char_u *)"lightgray", TORGB(0xD3, 0xD3, 0xD3)},
- {(char_u *)"lightgreen", TORGB(0x90, 0xEE, 0x90)},
- {(char_u *)"lightgrey", TORGB(0xD3, 0xD3, 0xD3)},
- {(char_u *)"lightmagenta", TORGB(0xFF, 0x8B, 0xFF)}, /* No X11 */
- {(char_u *)"lightred", TORGB(0xFF, 0x8B, 0x8B)}, /* No X11 */
- {(char_u *)"lightyellow", TORGB(0xFF, 0xFF, 0xE0)},
- {(char_u *)"magenta", TORGB(0xFF, 0x00, 0xFF)},
- {(char_u *)"orange", TORGB(0xFF, 0xA5, 0x00)},
- {(char_u *)"purple", TORGB(0xA0, 0x20, 0xF0)},
- {(char_u *)"red", TORGB(0xFF, 0x00, 0x00)},
- {(char_u *)"seagreen", TORGB(0x2E, 0x8B, 0x57)},
- {(char_u *)"slateblue", TORGB(0x6A, 0x5A, 0xCD)},
- {(char_u *)"violet", TORGB(0xEE, 0x82, 0xEE)},
- {(char_u *)"white", TORGB(0xFF, 0xFF, 0xFF)},
- {(char_u *)"yellow", TORGB(0xFF, 0xFF, 0x00)},
+ {(char_u *)"black", RGB(0x00, 0x00, 0x00)},
+ {(char_u *)"blue", RGB(0x00, 0x00, 0xFF)},
+ {(char_u *)"brown", RGB(0xA5, 0x2A, 0x2A)},
+ {(char_u *)"cyan", RGB(0x00, 0xFF, 0xFF)},
+ {(char_u *)"darkblue", RGB(0x00, 0x00, 0x8B)},
+ {(char_u *)"darkcyan", RGB(0x00, 0x8B, 0x8B)},
+ {(char_u *)"darkgray", RGB(0xA9, 0xA9, 0xA9)},
+ {(char_u *)"darkgreen", RGB(0x00, 0x64, 0x00)},
+ {(char_u *)"darkgrey", RGB(0xA9, 0xA9, 0xA9)},
+ {(char_u *)"darkmagenta", RGB(0x8B, 0x00, 0x8B)},
+ {(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)},
+ {(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, /* No X11 */
+ {(char_u *)"gray", RGB(0xBE, 0xBE, 0xBE)},
+ {(char_u *)"gray10", RGB(0x1A, 0x1A, 0x1A)},
+ {(char_u *)"gray20", RGB(0x33, 0x33, 0x33)},
+ {(char_u *)"gray30", RGB(0x4D, 0x4D, 0x4D)},
+ {(char_u *)"gray40", RGB(0x66, 0x66, 0x66)},
+ {(char_u *)"gray50", RGB(0x7F, 0x7F, 0x7F)},
+ {(char_u *)"gray60", RGB(0x99, 0x99, 0x99)},
+ {(char_u *)"gray70", RGB(0xB3, 0xB3, 0xB3)},
+ {(char_u *)"gray80", RGB(0xCC, 0xCC, 0xCC)},
+ {(char_u *)"gray90", RGB(0xE5, 0xE5, 0xE5)},
+ {(char_u *)"green", RGB(0x00, 0xFF, 0x00)},
+ {(char_u *)"grey", RGB(0xBE, 0xBE, 0xBE)},
+ {(char_u *)"grey10", RGB(0x1A, 0x1A, 0x1A)},
+ {(char_u *)"grey20", RGB(0x33, 0x33, 0x33)},
+ {(char_u *)"grey30", RGB(0x4D, 0x4D, 0x4D)},
+ {(char_u *)"grey40", RGB(0x66, 0x66, 0x66)},
+ {(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)},
+ {(char_u *)"grey60", RGB(0x99, 0x99, 0x99)},
+ {(char_u *)"grey70", RGB(0xB3, 0xB3, 0xB3)},
+ {(char_u *)"grey80", RGB(0xCC, 0xCC, 0xCC)},
+ {(char_u *)"grey90", RGB(0xE5, 0xE5, 0xE5)},
+ {(char_u *)"lightblue", RGB(0xAD, 0xD8, 0xE6)},
+ {(char_u *)"lightcyan", RGB(0xE0, 0xFF, 0xFF)},
+ {(char_u *)"lightgray", RGB(0xD3, 0xD3, 0xD3)},
+ {(char_u *)"lightgreen", RGB(0x90, 0xEE, 0x90)},
+ {(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)},
+ {(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, /* No X11 */
+ {(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, /* No X11 */
+ {(char_u *)"lightyellow", RGB(0xFF, 0xFF, 0xE0)},
+ {(char_u *)"magenta", RGB(0xFF, 0x00, 0xFF)},
+ {(char_u *)"orange", RGB(0xFF, 0xA5, 0x00)},
+ {(char_u *)"purple", RGB(0xA0, 0x20, 0xF0)},
+ {(char_u *)"red", RGB(0xFF, 0x00, 0x00)},
+ {(char_u *)"seagreen", RGB(0x2E, 0x8B, 0x57)},
+ {(char_u *)"slateblue", RGB(0x6A, 0x5A, 0xCD)},
+ {(char_u *)"violet", RGB(0xEE, 0x82, 0xEE)},
+ {(char_u *)"white", RGB(0xFF, 0xFF, 0xFF)},
+ {(char_u *)"yellow", RGB(0xFF, 0xFF, 0x00)},
};
if (name[0] == '#' && STRLEN(name) == 7)
{
/* Name is in "#rrggbb" format */
- color = TORGB(((hex_digit(name[1]) << 4) + hex_digit(name[2])),
+ color = RGB(((hex_digit(name[1]) << 4) + hex_digit(name[2])),
((hex_digit(name[3]) << 4) + hex_digit(name[4])),
((hex_digit(name[5]) << 4) + hex_digit(name[6])));
if (color > 0xffffff)
@@ -6188,7 +6192,7 @@ gui_get_color_cmn(char_u *name)
if (STRICMP(line + pos, name) == 0)
{
fclose(fd);
- return (guicolor_T) TORGB(r, g, b);
+ return (guicolor_T)RGB(r, g, b);
}
}
fclose(fd);