1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

Palettes are const.

This does not conflict with querying the palette from xterm (bug 890)
because although those palettes would have to be modifiable, they
would be terminal-specific rather than global.
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-25 10:54:54 +02:00 committed by Kalle Olavi Niemitalo
parent b4359e0445
commit cae9b720bc
2 changed files with 6 additions and 6 deletions

View File

@ -25,7 +25,7 @@ struct rgb_cache_entry {
}; };
static inline int static inline int
color_distance(struct rgb *c1, struct rgb *c2) color_distance(const struct rgb *c1, const struct rgb *c2)
{ {
int r = c1->r - c2->r; int r = c1->r - c2->r;
int g = c1->g - c2->g; int g = c1->g - c2->g;
@ -57,7 +57,7 @@ color_distance(struct rgb *c1, struct rgb *c2)
/* Locates the nearest terminal color. */ /* Locates the nearest terminal color. */
static inline unsigned char static inline unsigned char
get_color(color_T color, struct rgb *palette, int level) get_color(color_T color, const struct rgb *palette, int level)
{ {
static struct rgb_cache_entry cache[RGB_HASH_SIZE]; static struct rgb_cache_entry cache[RGB_HASH_SIZE];
struct rgb_cache_entry *rgb_cache = &cache[HASH_RGB(color, level)]; struct rgb_cache_entry *rgb_cache = &cache[HASH_RGB(color, level)];
@ -120,7 +120,7 @@ enum palette_range {
}; };
struct color_mode_info { struct color_mode_info {
struct rgb *palette; const struct rgb *palette;
struct { struct {
int bg; int bg;

View File

@ -2,7 +2,7 @@
/* TODO: We should probably autogenerate this using xterm's perl script. */ /* TODO: We should probably autogenerate this using xterm's perl script. */
/* The 16 ANSI colors. */ /* The 16 ANSI colors. */
static struct rgb palette16[] = { static const struct rgb palette16[] = {
#if defined(PALA) #if defined(PALA)
{0x00, 0x00, 0x00}, {0x00, 0x00, 0x00},
{0x80, 0x00, 0x00}, {0x80, 0x00, 0x00},
@ -62,7 +62,7 @@ static struct rgb palette16[] = {
/* Colors 0-16 are the ANSI colors (and the same as palette16[]). /* Colors 0-16 are the ANSI colors (and the same as palette16[]).
* Colors 16-79 are 4x4x4 color cubes * Colors 16-79 are 4x4x4 color cubes
* Colors 80-91 are a grayscale ramp (with black and white left out). */ * Colors 80-91 are a grayscale ramp (with black and white left out). */
static struct rgb palette88[] = { static const struct rgb palette88[] = {
{0x00, 0x00, 0x00}, /* 0 */ {0x00, 0x00, 0x00}, /* 0 */
{0x80, 0x00, 0x00}, /* 1 */ {0x80, 0x00, 0x00}, /* 1 */
{0x00, 0x80, 0x00}, /* 2 */ {0x00, 0x80, 0x00}, /* 2 */
@ -164,7 +164,7 @@ static struct rgb palette88[] = {
/* Colors 0- 16 are the ANSI colors (and the same as palette16[]). /* Colors 0- 16 are the ANSI colors (and the same as palette16[]).
* Colors 16-231 are a 6x6x6 color cube * Colors 16-231 are a 6x6x6 color cube
* Colors 231-255 are a grayscale ramp (with black and white left out). */ * Colors 231-255 are a grayscale ramp (with black and white left out). */
static struct rgb palette256[] = { static const struct rgb palette256[] = {
{0x00, 0x00, 0x00}, /* 0 */ {0x00, 0x00, 0x00}, /* 0 */
{0x80, 0x00, 0x00}, /* 1 */ {0x80, 0x00, 0x00}, /* 1 */
{0x00, 0x80, 0x00}, /* 2 */ {0x00, 0x80, 0x00}, /* 2 */