forked from aniani/vim
patch 8.0.1149: libvterm colors differ from xterm
Problem: libvterm colors differ from xterm. Solution: Use the xterm colors for libvterm.
This commit is contained in:
parent
22ab547dc2
commit
a8fc0d3817
1
Filelist
1
Filelist
@ -136,6 +136,7 @@ SRC_ALL = \
|
|||||||
src/testdir/bench*.vim \
|
src/testdir/bench*.vim \
|
||||||
src/testdir/samples/*.txt \
|
src/testdir/samples/*.txt \
|
||||||
src/testdir/if_ver*.vim \
|
src/testdir/if_ver*.vim \
|
||||||
|
src/testdir/xterm_ramp.vim \
|
||||||
src/proto.h \
|
src/proto.h \
|
||||||
src/proto/arabic.pro \
|
src/proto/arabic.pro \
|
||||||
src/proto/blowfish.pro \
|
src/proto/blowfish.pro \
|
||||||
|
@ -25,12 +25,13 @@ static const VTermColor ansi_colors[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int ramp6[] = {
|
static int ramp6[] = {
|
||||||
0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF,
|
0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Use 0x81 instead of 0x80 to be able to distinguish from ansi black */
|
||||||
static int ramp24[] = {
|
static int ramp24[] = {
|
||||||
0x00, 0x0B, 0x16, 0x21, 0x2C, 0x37, 0x42, 0x4D, 0x58, 0x63, 0x6E, 0x79,
|
0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
|
||||||
0x85, 0x90, 0x9B, 0xA6, 0xB1, 0xBC, 0xC7, 0xD2, 0xDD, 0xE8, 0xF3, 0xFF,
|
0x81, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int lookup_colour_ansi(const VTermState *state, long index, VTermColor *col)
|
static int lookup_colour_ansi(const VTermState *state, long index, VTermColor *col)
|
||||||
|
@ -41,10 +41,12 @@
|
|||||||
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
|
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
|
||||||
* Higashi, 2017 Sep 19)
|
* Higashi, 2017 Sep 19)
|
||||||
* - Shift-Tab does not work.
|
* - Shift-Tab does not work.
|
||||||
* - click in Window toolbar of other window: save/restore Insert and Visual
|
* - double click in Window toolbar starts Visual mode.
|
||||||
* - Redirecting output does not work on MS-Windows, Test_terminal_redir_file()
|
* - Redirecting output does not work on MS-Windows, Test_terminal_redir_file()
|
||||||
* is disabled.
|
* is disabled.
|
||||||
|
* - cursor blinks in terminal on widows with a timer. (xtal8, #2142)
|
||||||
* - implement term_setsize()
|
* - implement term_setsize()
|
||||||
|
* - MS-Windows GUI: WinBar has tearoff item
|
||||||
* - MS-Windows GUI: still need to type a key after shell exits? #1924
|
* - MS-Windows GUI: still need to type a key after shell exits? #1924
|
||||||
* - add test for giving error for invalid 'termsize' value.
|
* - add test for giving error for invalid 'termsize' value.
|
||||||
* - support minimal size when 'termsize' is "rows*cols".
|
* - support minimal size when 'termsize' is "rows*cols".
|
||||||
@ -1791,23 +1793,38 @@ color2index(VTermColor *color, int fg, int *boldp)
|
|||||||
{
|
{
|
||||||
if (red == blue && red == green)
|
if (red == blue && red == green)
|
||||||
{
|
{
|
||||||
/* 24-color greyscale */
|
/* 24-color greyscale plus white and black */
|
||||||
static int cutoff[23] = {
|
static int cutoff[23] = {
|
||||||
0x05, 0x10, 0x1B, 0x26, 0x31, 0x3C, 0x47, 0x52,
|
0x0D, 0x17, 0x21, 0x2B, 0x35, 0x3F, 0x49, 0x53, 0x5D, 0x67,
|
||||||
0x5D, 0x68, 0x73, 0x7F, 0x8A, 0x95, 0xA0, 0xAB,
|
0x71, 0x7B, 0x85, 0x8F, 0x99, 0xA3, 0xAD, 0xB7, 0xC1, 0xCB,
|
||||||
0xB6, 0xC1, 0xCC, 0xD7, 0xE2, 0xED, 0xF9};
|
0xD5, 0xDF, 0xE9};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (red < 5)
|
||||||
|
return 17; /* 00/00/00 */
|
||||||
|
if (red > 245) /* ff/ff/ff */
|
||||||
|
return 232;
|
||||||
for (i = 0; i < 23; ++i)
|
for (i = 0; i < 23; ++i)
|
||||||
if (red < cutoff[i])
|
if (red < cutoff[i])
|
||||||
return i + 233;
|
return i + 233;
|
||||||
return 256;
|
return 256;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
static int cutoff[5] = {0x2F, 0x73, 0x9B, 0xC3, 0xEB};
|
||||||
|
int ri, gi, bi;
|
||||||
|
|
||||||
/* 216-color cube */
|
/* 216-color cube */
|
||||||
return 17 + ((red + 25) / 0x33) * 36
|
for (ri = 0; ri < 5; ++ri)
|
||||||
+ ((green + 25) / 0x33) * 6
|
if (red < cutoff[ri])
|
||||||
+ (blue + 25) / 0x33;
|
break;
|
||||||
|
for (gi = 0; gi < 5; ++gi)
|
||||||
|
if (green < cutoff[gi])
|
||||||
|
break;
|
||||||
|
for (bi = 0; bi < 5; ++bi)
|
||||||
|
if (blue < cutoff[bi])
|
||||||
|
break;
|
||||||
|
return 17 + ri * 36 + gi * 6 + bi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2426,16 +2443,17 @@ static VTermColor ansi_table[16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int cube_value[] = {
|
static int cube_value[] = {
|
||||||
0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF,
|
0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
static int grey_ramp[] = {
|
static int grey_ramp[] = {
|
||||||
0x00, 0x0B, 0x16, 0x21, 0x2C, 0x37, 0x42, 0x4D, 0x58, 0x63, 0x6E, 0x79,
|
0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
|
||||||
0x85, 0x90, 0x9B, 0xA6, 0xB1, 0xBC, 0xC7, 0xD2, 0xDD, 0xE8, 0xF3, 0xFF,
|
0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a cterm color number 0 - 255 to RGB.
|
* Convert a cterm color number 0 - 255 to RGB.
|
||||||
|
* This is compatible with xterm.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
cterm_color2rgb(int nr, VTermColor *rgb)
|
cterm_color2rgb(int nr, VTermColor *rgb)
|
||||||
|
40
src/testdir/xterm_ramp.vim
Normal file
40
src/testdir/xterm_ramp.vim
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
" Script to generate a file that shows al 256 xterm colors
|
||||||
|
|
||||||
|
new
|
||||||
|
call setline(1, 'ANSI')
|
||||||
|
|
||||||
|
" ANSI colors
|
||||||
|
let s = ''
|
||||||
|
for nr in range(0, 7)
|
||||||
|
let s .= "\033[4" . nr . "m "
|
||||||
|
endfor
|
||||||
|
for nr in range(8, 15)
|
||||||
|
let s .= "\033[10" . (nr - 8) . "m "
|
||||||
|
endfor
|
||||||
|
let s .= "\033[107m|"
|
||||||
|
call setline(2, s)
|
||||||
|
|
||||||
|
" 6 x 6 x 6 color cube
|
||||||
|
call setline(3, 'color cube')
|
||||||
|
for high in range(0, 5)
|
||||||
|
let s = ''
|
||||||
|
for low in range(0, 35)
|
||||||
|
let nr = low + high * 36
|
||||||
|
let s .= "\033[48;5;" . (nr + 16) . "m "
|
||||||
|
endfor
|
||||||
|
let s .= "\033[107m|"
|
||||||
|
call setline(high + 4, s)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" 24 shades of grey
|
||||||
|
call setline(10, 'grey ramp')
|
||||||
|
let s = ''
|
||||||
|
for nr in range(0, 23)
|
||||||
|
let s .= "\033[48;5;" . (nr + 232) . "m "
|
||||||
|
endfor
|
||||||
|
let s .= "\033[107m|"
|
||||||
|
call setline(11, s)
|
||||||
|
|
||||||
|
set binary
|
||||||
|
write! <sfile>:h/xterm_ramp.txt
|
||||||
|
quit
|
@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1149,
|
||||||
/**/
|
/**/
|
||||||
1148,
|
1148,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user