Skip to content

Commit 938f9ad

Browse files
committed
remove lookup_color function
1 parent f143e3d commit 938f9ad

File tree

3 files changed

+1
-174
lines changed

3 files changed

+1
-174
lines changed

src/proto/syntax.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ void ex_syntime(exarg_T *eap);
2525
char_u *get_syntime_arg(expand_T *xp, int idx);
2626
void init_highlight(int both, int reset);
2727
int load_colors(char_u *name);
28-
int lookup_color(int idx, int foreground, int *boldp);
2928
void do_highlight(char_u *line, int forceit, int init);
3029
void free_highlight(void);
3130
void restore_cterm_colors(void);

src/syntax.c

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -371,95 +371,6 @@ static char *(color_names[28]) = {
371371
* 14, 15, 16, 17,
372372
* 18, 19, 20, 21, 22,
373373
* 23, 24, 25, 26, 27 */
374-
static int color_numbers_16[28] = {0, 1, 2, 3,
375-
4, 5, 6, 6,
376-
7, 7, 7, 7,
377-
8, 8,
378-
9, 9, 10, 10,
379-
11, 11, 12, 12, 13,
380-
13, 14, 14, 15, -1};
381-
/* for xterm with 88 colors... */
382-
static int color_numbers_88[28] = {0, 4, 2, 6,
383-
1, 5, 32, 72,
384-
84, 84, 7, 7,
385-
82, 82,
386-
12, 43, 10, 61,
387-
14, 63, 9, 74, 13,
388-
75, 11, 78, 15, -1};
389-
/* for xterm with 256 colors... */
390-
static int color_numbers_256[28] = {0, 4, 2, 6,
391-
1, 5, 130, 130,
392-
248, 248, 7, 7,
393-
242, 242,
394-
12, 81, 10, 121,
395-
14, 159, 9, 224, 13,
396-
225, 11, 229, 15, -1};
397-
/* for terminals with less than 16 colors... */
398-
static int color_numbers_8[28] = {0, 4, 2, 6,
399-
1, 5, 3, 3,
400-
7, 7, 7, 7,
401-
0 + 8, 0 + 8,
402-
4 + 8, 4 + 8, 2 + 8, 2 + 8,
403-
6 + 8, 6 + 8, 1 + 8, 1 + 8, 5 + 8,
404-
5 + 8, 3 + 8, 3 + 8, 7 + 8, -1};
405-
406-
/*
407-
* Lookup the "cterm" value to be used for color with index "idx" in
408-
* color_names[].
409-
* "boldp" will be set to TRUE or FALSE for a foreground color when using 8
410-
* colors, otherwise it will be unchanged.
411-
*/
412-
int lookup_color(int idx, int foreground, int *boldp)
413-
{
414-
int color = color_numbers_16[idx];
415-
char_u *p;
416-
417-
/* Use the _16 table to check if it's a valid color name. */
418-
if (color < 0)
419-
return -1;
420-
421-
if (t_colors == 8)
422-
{
423-
/* t_Co is 8: use the 8 colors table */
424-
#if defined(__QNXNTO__)
425-
color = color_numbers_8_qansi[idx];
426-
#else
427-
color = color_numbers_8[idx];
428-
#endif
429-
if (foreground)
430-
{
431-
/* set/reset bold attribute to get light foreground
432-
* colors (on some terminals, e.g. "linux") */
433-
if (color & 8)
434-
*boldp = TRUE;
435-
else
436-
*boldp = FALSE;
437-
}
438-
color &= 7; /* truncate to 8 colors */
439-
}
440-
else if (t_colors == 16 || t_colors == 88 || t_colors >= 256)
441-
{
442-
/*
443-
* Guess: if the termcap entry ends in 'm', it is
444-
* probably an xterm-like terminal. Use the changed
445-
* order for colors.
446-
*/
447-
if (*T_CAF != NUL)
448-
p = T_CAF;
449-
else
450-
p = T_CSF;
451-
if (*p != NUL && (t_colors > 256 || *(p + STRLEN(p) - 1) == 'm'))
452-
{
453-
if (t_colors == 88)
454-
color = color_numbers_88[idx];
455-
else if (t_colors >= 256)
456-
color = color_numbers_256[idx];
457-
else
458-
color = color_numbers_8[idx];
459-
}
460-
}
461-
return color;
462-
}
463374

464375
/*
465376
* Handle the ":highlight .." command.
@@ -901,7 +812,7 @@ void do_highlight(
901812
break;
902813
}
903814

904-
color = lookup_color(i, key[5] == 'F', &bold);
815+
color = 0;
905816

906817
/* set/reset bold attribute to get light foreground
907818
* colors (on some terminals, e.g. "linux") */

src/terminal.c

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,89 +2137,6 @@ may_toggle_cursor(term_T *term)
21372137
static int
21382138
color2index(VTermColor *color, int fg, int *boldp)
21392139
{
2140-
int red = color->red;
2141-
int blue = color->blue;
2142-
int green = color->green;
2143-
2144-
if (color->ansi_index != VTERM_ANSI_INDEX_NONE)
2145-
{
2146-
// The first 16 colors and default: use the ANSI index.
2147-
switch (color->ansi_index)
2148-
{
2149-
case 0:
2150-
return 0;
2151-
case 1:
2152-
return lookup_color(0, fg, boldp) + 1; /* black */
2153-
case 2:
2154-
return lookup_color(4, fg, boldp) + 1; /* dark red */
2155-
case 3:
2156-
return lookup_color(2, fg, boldp) + 1; /* dark green */
2157-
case 4:
2158-
return lookup_color(6, fg, boldp) + 1; /* brown */
2159-
case 5:
2160-
return lookup_color(1, fg, boldp) + 1; /* dark blue */
2161-
case 6:
2162-
return lookup_color(5, fg, boldp) + 1; /* dark magenta */
2163-
case 7:
2164-
return lookup_color(3, fg, boldp) + 1; /* dark cyan */
2165-
case 8:
2166-
return lookup_color(8, fg, boldp) + 1; /* light grey */
2167-
case 9:
2168-
return lookup_color(12, fg, boldp) + 1; /* dark grey */
2169-
case 10:
2170-
return lookup_color(20, fg, boldp) + 1; /* red */
2171-
case 11:
2172-
return lookup_color(16, fg, boldp) + 1; /* green */
2173-
case 12:
2174-
return lookup_color(24, fg, boldp) + 1; /* yellow */
2175-
case 13:
2176-
return lookup_color(14, fg, boldp) + 1; /* blue */
2177-
case 14:
2178-
return lookup_color(22, fg, boldp) + 1; /* magenta */
2179-
case 15:
2180-
return lookup_color(18, fg, boldp) + 1; /* cyan */
2181-
case 16:
2182-
return lookup_color(26, fg, boldp) + 1; /* white */
2183-
}
2184-
}
2185-
2186-
if (t_colors >= 256)
2187-
{
2188-
if (red == blue && red == green)
2189-
{
2190-
/* 24-color greyscale plus white and black */
2191-
static int cutoff[23] = {
2192-
0x0D, 0x17, 0x21, 0x2B, 0x35, 0x3F, 0x49, 0x53, 0x5D, 0x67,
2193-
0x71, 0x7B, 0x85, 0x8F, 0x99, 0xA3, 0xAD, 0xB7, 0xC1, 0xCB,
2194-
0xD5, 0xDF, 0xE9};
2195-
int i;
2196-
2197-
if (red < 5)
2198-
return 17; /* 00/00/00 */
2199-
if (red > 245) /* ff/ff/ff */
2200-
return 232;
2201-
for (i = 0; i < 23; ++i)
2202-
if (red < cutoff[i])
2203-
return i + 233;
2204-
return 256;
2205-
}
2206-
{
2207-
static int cutoff[5] = {0x2F, 0x73, 0x9B, 0xC3, 0xEB};
2208-
int ri, gi, bi;
2209-
2210-
/* 216-color cube */
2211-
for (ri = 0; ri < 5; ++ri)
2212-
if (red < cutoff[ri])
2213-
break;
2214-
for (gi = 0; gi < 5; ++gi)
2215-
if (green < cutoff[gi])
2216-
break;
2217-
for (bi = 0; bi < 5; ++bi)
2218-
if (blue < cutoff[bi])
2219-
break;
2220-
return 17 + ri * 36 + gi * 6 + bi;
2221-
}
2222-
}
22232140
return 0;
22242141
}
22252142

0 commit comments

Comments
 (0)