Dillo v3.1.1-111-gd4f56d0d
Loading...
Searching...
No Matches
colors.c File Reference
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "colors.h"
#include "msg.h"
Include dependency graph for colors.c:

Go to the source code of this file.

Macros

#define EXTENDED_COLOR
 
#define NCOLORS   (sizeof(color_keyword) / sizeof(color_keyword[0]))
 

Functions

static int32_t Color_parse_hex (const char *s, int32_t default_color, int *err)
 Parse a color in hex (RRGGBB) or (RGB).
 
int32_t a_Color_parse (const char *str, int32_t default_color, int *err)
 Parse a color string.
 
static int Color_distance2 (long c1, long c2)
 
static int Color_distance3 (long c1, long c2)
 
int32_t a_Color_vc (int32_t candidate, int32_t C_txt, int32_t C_lnk, int32_t C_bg)
 Return a suitable "visited link" color.
 

Variables

static const struct key color_keyword []
 

Macro Definition Documentation

◆ EXTENDED_COLOR

#define EXTENDED_COLOR

Definition at line 26 of file colors.c.

◆ NCOLORS

#define NCOLORS   (sizeof(color_keyword) / sizeof(color_keyword[0]))

Definition at line 211 of file colors.c.

Function Documentation

◆ a_Color_parse()

int32_t a_Color_parse ( const char *  str,
int32_t  default_color,
int *  err 
)

Parse a color string.

  • If the string begins with # or with 0x, return the color number (with 'RGB' expanded to 'RRGGBB').
  • Else search the set of named colors.
  • As a last resort, treat it as bare hex as in the first case.
Returns
  • Parsed color if successful,
  • default_color on error.

"err" argument:

  • 0 if a color beginning with '#' is successfully parsed or the color is a recognized word.
  • 1 if the color is bare hex or can't be parsed at all.
  • 2 if a color beginning with 0[xX] is successfully parsed.

Definition at line 258 of file colors.c.

References _MSG, color_keyword, Color_parse_hex(), dIsspace, dStrAsciiCasecmp(), and NCOLORS.

Referenced by a_Html_color_parse(), parseOption(), CssParser::parseValue(), and CssParser::tokenMatchesProperty().

◆ a_Color_vc()

int32_t a_Color_vc ( int32_t  candidate,
int32_t  C_txt,
int32_t  C_lnk,
int32_t  C_bg 
)

Return a suitable "visited link" color.

Returns
  • if candidate has good contrast with C_txt, C_lnk and C_bg -> candidate
  • else another color (from the internal list)

Definition at line 344 of file colors.c.

References _MSG, Color_distance2(), and Color_distance3().

Referenced by Html_tag_open_body().

◆ Color_distance2()

static int Color_distance2 ( long  c1,
long  c2 
)
static

Definition at line 321 of file colors.c.

Referenced by a_Color_vc().

◆ Color_distance3()

static int Color_distance3 ( long  c1,
long  c2 
)
static

Definition at line 331 of file colors.c.

Referenced by a_Color_vc().

◆ Color_parse_hex()

static int32_t Color_parse_hex ( const char *  s,
int32_t  default_color,
int *  err 
)
static

Parse a color in hex (RRGGBB) or (RGB).

Returns
  • parsed color if successful (err = 0),
  • default_color on error (err = 1).

Definition at line 220 of file colors.c.

Referenced by a_Color_parse().

Variable Documentation

◆ color_keyword

const struct key color_keyword[]
static

Referenced by a_Color_parse().