mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-03 15:34:54 -05:00
[ThemeParser] Add CSS color names support
* [ThemeParser] Add css color names * Add CSS color support (WIP) * Parse color names in the lexer. * Add test for css color names * Indent and fix ordering
This commit is contained in:
parent
e397c346da
commit
494550d38d
12 changed files with 291 additions and 64 deletions
10
Makefile.am
10
Makefile.am
|
@ -60,6 +60,7 @@ SOURCES=\
|
||||||
source/widgets/scrollbar.c\
|
source/widgets/scrollbar.c\
|
||||||
source/xrmoptions.c\
|
source/xrmoptions.c\
|
||||||
source/x11-helper.c\
|
source/x11-helper.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/dialogs/run.c\
|
source/dialogs/run.c\
|
||||||
source/dialogs/ssh.c\
|
source/dialogs/ssh.c\
|
||||||
source/dialogs/drun.c\
|
source/dialogs/drun.c\
|
||||||
|
@ -82,6 +83,7 @@ SOURCES=\
|
||||||
include/timings.h\
|
include/timings.h\
|
||||||
include/history.h\
|
include/history.h\
|
||||||
include/theme.h\
|
include/theme.h\
|
||||||
|
include/css-colors.h\
|
||||||
include/default-theme.h\
|
include/default-theme.h\
|
||||||
include/widgets/box.h\
|
include/widgets/box.h\
|
||||||
include/widgets/container.h\
|
include/widgets/container.h\
|
||||||
|
@ -319,6 +321,7 @@ widget_test_SOURCES=\
|
||||||
source/widgets/widget.c\
|
source/widgets/widget.c\
|
||||||
source/widgets/textbox.c\
|
source/widgets/textbox.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/x11-helper.c\
|
source/x11-helper.c\
|
||||||
config/config.c\
|
config/config.c\
|
||||||
|
@ -334,7 +337,9 @@ box_test_SOURCES=\
|
||||||
lexer/theme-parser.y\
|
lexer/theme-parser.y\
|
||||||
lexer/theme-lexer.l\
|
lexer/theme-lexer.l\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
include/theme.h\
|
include/theme.h\
|
||||||
|
include/css-colors.h\
|
||||||
test/box-test.c
|
test/box-test.c
|
||||||
|
|
||||||
scrollbar_test_LDADD=$(textbox_test_LDADD)
|
scrollbar_test_LDADD=$(textbox_test_LDADD)
|
||||||
|
@ -345,7 +350,9 @@ scrollbar_test_SOURCES=\
|
||||||
lexer/theme-parser.y\
|
lexer/theme-parser.y\
|
||||||
lexer/theme-lexer.l\
|
lexer/theme-lexer.l\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
include/theme.h\
|
include/theme.h\
|
||||||
|
include/css-colors.h\
|
||||||
test/scrollbar-test.c
|
test/scrollbar-test.c
|
||||||
|
|
||||||
textbox_test_SOURCES=\
|
textbox_test_SOURCES=\
|
||||||
|
@ -354,6 +361,7 @@ textbox_test_SOURCES=\
|
||||||
lexer/theme-parser.y\
|
lexer/theme-parser.y\
|
||||||
lexer/theme-lexer.l\
|
lexer/theme-lexer.l\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/x11-helper.c\
|
source/x11-helper.c\
|
||||||
config/config.c\
|
config/config.c\
|
||||||
|
@ -382,6 +390,7 @@ theme_parser_test_SOURCES=\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
include/helper-theme.h\
|
include/helper-theme.h\
|
||||||
include/theme.h\
|
include/theme.h\
|
||||||
|
include/css-colors.h\
|
||||||
include/xrmoptions.h\
|
include/xrmoptions.h\
|
||||||
source/xrmoptions.c\
|
source/xrmoptions.c\
|
||||||
source/x11-helper.c\
|
source/x11-helper.c\
|
||||||
|
@ -389,6 +398,7 @@ theme_parser_test_SOURCES=\
|
||||||
lexer/theme-parser.c\
|
lexer/theme-parser.c\
|
||||||
lexer/theme-parser.h\
|
lexer/theme-parser.h\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
test/theme-parser-test.c
|
test/theme-parser-test.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
12
include/css-colors.h
Normal file
12
include/css-colors.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef ROFI_INCLUDE_CSS_COLORS_H
|
||||||
|
#define ROFI_INCLUDE_CSS_COLORS_H
|
||||||
|
|
||||||
|
typedef struct CSSColor
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
uint8_t b, g, r, a;
|
||||||
|
}CSSColor;
|
||||||
|
|
||||||
|
extern const CSSColor CSSColors[];
|
||||||
|
extern const unsigned int num_CSSColors;
|
||||||
|
#endif // ROFI_INCLUDE_CSS_COLORS_H
|
|
@ -41,6 +41,7 @@
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
#include "theme-parser.h"
|
#include "theme-parser.h"
|
||||||
|
#include "css-colors.h"
|
||||||
|
|
||||||
#define LOG_DOMAIN "Parser"
|
#define LOG_DOMAIN "Parser"
|
||||||
int last_state = 0;
|
int last_state = 0;
|
||||||
|
@ -147,6 +148,7 @@ UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
|
||||||
WHITESPACE [[:blank:]]
|
WHITESPACE [[:blank:]]
|
||||||
WSO [[:blank:]]*
|
WSO [[:blank:]]*
|
||||||
WORD [[:alnum:]-]+
|
WORD [[:alnum:]-]+
|
||||||
|
COLOR_NAME [[:alpha:]]+
|
||||||
STRING {UANYN}+
|
STRING {UANYN}+
|
||||||
HEX [[:xdigit:]]
|
HEX [[:xdigit:]]
|
||||||
NUMBER [[:digit:]]
|
NUMBER [[:digit:]]
|
||||||
|
@ -179,12 +181,13 @@ ANGLE_RAD "rad"
|
||||||
ANGLE_TURN "turn"
|
ANGLE_TURN "turn"
|
||||||
|
|
||||||
/* Color schema */
|
/* Color schema */
|
||||||
RGBA "rgba"
|
RGBA rgb[a]?
|
||||||
RGB "rgb"
|
|
||||||
HWB "hwb"
|
HWB "hwb"
|
||||||
CMYK "cmyk"
|
CMYK "cmyk"
|
||||||
HSL hsl[a]?
|
HSL hsl[a]?
|
||||||
|
|
||||||
|
COLOR_TRANSPARENT "transparent"
|
||||||
|
|
||||||
S_T_PARENT_LEFT \(
|
S_T_PARENT_LEFT \(
|
||||||
S_T_PARENT_RIGHT \)
|
S_T_PARENT_RIGHT \)
|
||||||
COMMA ,
|
COMMA ,
|
||||||
|
@ -422,7 +425,6 @@ if ( queue == NULL ){
|
||||||
}
|
}
|
||||||
/* Color schemes */
|
/* Color schemes */
|
||||||
<PROPERTIES>{RGBA} { return T_COL_RGBA; }
|
<PROPERTIES>{RGBA} { return T_COL_RGBA; }
|
||||||
<PROPERTIES>{RGB} { return T_COL_RGB; }
|
|
||||||
<PROPERTIES>{HSL} { return T_COL_HSL; }
|
<PROPERTIES>{HSL} { return T_COL_HSL; }
|
||||||
<PROPERTIES>{HWB} { return T_COL_HWB; }
|
<PROPERTIES>{HWB} { return T_COL_HWB; }
|
||||||
<PROPERTIES>{CMYK} { return T_COL_CMYK; }
|
<PROPERTIES>{CMYK} { return T_COL_CMYK; }
|
||||||
|
@ -448,6 +450,22 @@ if ( queue == NULL ){
|
||||||
<PROPERTIES>{ANGLE_GRAD} { return T_ANGLE_GRAD; }
|
<PROPERTIES>{ANGLE_GRAD} { return T_ANGLE_GRAD; }
|
||||||
<PROPERTIES>{ANGLE_TURN} { return T_ANGLE_TURN; }
|
<PROPERTIES>{ANGLE_TURN} { return T_ANGLE_TURN; }
|
||||||
|
|
||||||
|
<PROPERTIES>{COLOR_TRANSPARENT} {
|
||||||
|
return T_COLOR_TRANSPARENT;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{COLOR_NAME} {
|
||||||
|
for ( unsigned int iter = 0; iter < num_CSSColors; iter++){
|
||||||
|
if ( strcasecmp(yytext, CSSColors[iter].name )== 0 ) {
|
||||||
|
yylval->colorval.alpha = 1.0;
|
||||||
|
yylval->colorval.red = CSSColors[iter].r/255.0;
|
||||||
|
yylval->colorval.green = CSSColors[iter].g/255.0;
|
||||||
|
yylval->colorval.blue = CSSColors[iter].b/255.0;
|
||||||
|
return T_COLOR_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
REJECT;
|
||||||
|
}
|
||||||
|
|
||||||
<INITIAL><<EOF>> {
|
<INITIAL><<EOF>> {
|
||||||
ParseObject *po = g_queue_pop_head ( file_queue );
|
ParseObject *po = g_queue_pop_head ( file_queue );
|
||||||
if ( po ) {
|
if ( po ) {
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
%code requires {
|
%code requires {
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "xrmoptions.h"
|
#include "xrmoptions.h"
|
||||||
|
#include "css-colors.h"
|
||||||
|
|
||||||
typedef struct YYLTYPE {
|
typedef struct YYLTYPE {
|
||||||
int first_line;
|
int first_line;
|
||||||
|
@ -157,6 +158,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
|
||||||
%token <fval> T_DOUBLE "Floating-point number"
|
%token <fval> T_DOUBLE "Floating-point number"
|
||||||
%token <sval> T_STRING "UTF-8 encoded string"
|
%token <sval> T_STRING "UTF-8 encoded string"
|
||||||
%token <sval> T_PROP_NAME "property name"
|
%token <sval> T_PROP_NAME "property name"
|
||||||
|
%token <colorval> T_COLOR_NAME "Color value by name"
|
||||||
%token <sval> T_NAME_ELEMENT "Element name"
|
%token <sval> T_NAME_ELEMENT "Element name"
|
||||||
%token <bval> T_BOOLEAN "Boolean value (true or false)"
|
%token <bval> T_BOOLEAN "Boolean value (true or false)"
|
||||||
%token <colorval> T_COLOR "Hexidecimal color value"
|
%token <colorval> T_COLOR "Hexidecimal color value"
|
||||||
|
@ -183,8 +185,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
|
||||||
%token T_ANGLE_RAD "Radians"
|
%token T_ANGLE_RAD "Radians"
|
||||||
%token T_ANGLE_TURN "Turns"
|
%token T_ANGLE_TURN "Turns"
|
||||||
|
|
||||||
%token T_COL_RGBA "rgba colorscheme"
|
%token T_COL_RGBA "rgb[a] colorscheme"
|
||||||
%token T_COL_RGB "rgb colorscheme"
|
|
||||||
%token T_COL_HSL "hsl colorscheme"
|
%token T_COL_HSL "hsl colorscheme"
|
||||||
%token T_COL_HWB "hwb colorscheme"
|
%token T_COL_HWB "hwb colorscheme"
|
||||||
%token T_COL_CMYK "cmyk colorscheme"
|
%token T_COL_CMYK "cmyk colorscheme"
|
||||||
|
@ -206,6 +207,8 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
|
||||||
%token T_PDEFAULTS "Default settings section ( '* { ... }')"
|
%token T_PDEFAULTS "Default settings section ( '* { ... }')"
|
||||||
%token T_CONFIGURATION "Configuration block"
|
%token T_CONFIGURATION "Configuration block"
|
||||||
|
|
||||||
|
%token T_COLOR_TRANSPARENT "Transparent"
|
||||||
|
|
||||||
%type <sval> t_entry
|
%type <sval> t_entry
|
||||||
%type <theme> t_entry_list
|
%type <theme> t_entry_list
|
||||||
%type <name_path> t_entry_name_path
|
%type <name_path> t_entry_name_path
|
||||||
|
@ -433,41 +436,21 @@ t_property_line_style
|
||||||
*/
|
*/
|
||||||
t_property_color
|
t_property_color
|
||||||
/** rgba ( 0-255 , 0-255, 0-255, 0-1.0 ) */
|
/** rgba ( 0-255 , 0-255, 0-255, 0-1.0 ) */
|
||||||
: T_COL_RGBA T_PARENT_LEFT T_INT T_COMMA T_INT T_COMMA T_INT T_COMMA t_property_color_value_unit T_PARENT_RIGHT {
|
: T_COL_RGBA T_PARENT_LEFT T_INT T_COMMA T_INT T_COMMA T_INT t_property_color_opt_alpha_c T_PARENT_RIGHT {
|
||||||
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
||||||
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
||||||
if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; }
|
||||||
$$.alpha = $9;
|
$$.alpha = $8;
|
||||||
$$.red = $3/255.0;
|
$$.red = $3/255.0;
|
||||||
$$.green = $5/255.0;
|
$$.green = $5/255.0;
|
||||||
$$.blue = $7/255.0;
|
$$.blue = $7/255.0;
|
||||||
}
|
}
|
||||||
/** rgba ( 0-255 0-255 0-255 / 0-1.0 ) */
|
/** rgba ( 0-255 0-255 0-255 / 0-1.0 ) */
|
||||||
| T_COL_RGBA T_PARENT_LEFT T_INT T_INT T_INT T_FORWARD_SLASH t_property_color_value_unit T_PARENT_RIGHT {
|
| T_COL_RGBA T_PARENT_LEFT T_INT T_INT T_INT t_property_color_opt_alpha_ws T_PARENT_RIGHT {
|
||||||
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
||||||
if ( ! check_in_range($4,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($4,0,255, &(@$)) ) { YYABORT; }
|
||||||
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
||||||
$$.alpha = $7;
|
$$.alpha = $6;
|
||||||
$$.red = $3/255.0;
|
|
||||||
$$.green = $4/255.0;
|
|
||||||
$$.blue = $5/255.0;
|
|
||||||
}
|
|
||||||
/** rgb ( 0-255 , 0-255, 0-255 ) */
|
|
||||||
| T_COL_RGB T_PARENT_LEFT T_INT T_COMMA T_INT T_COMMA T_INT T_PARENT_RIGHT {
|
|
||||||
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
$$.alpha = 1.0;
|
|
||||||
$$.red = $3/255.0;
|
|
||||||
$$.green = $5/255.0;
|
|
||||||
$$.blue = $7/255.0;
|
|
||||||
}
|
|
||||||
/** rgb ( 0-255 0-255 0-255 ) */
|
|
||||||
| T_COL_RGB T_PARENT_LEFT T_INT T_INT T_INT T_PARENT_RIGHT {
|
|
||||||
if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
if ( ! check_in_range($4,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; }
|
|
||||||
$$.alpha = 1.0;
|
|
||||||
$$.red = $3/255.0;
|
$$.red = $3/255.0;
|
||||||
$$.green = $4/255.0;
|
$$.green = $4/255.0;
|
||||||
$$.blue = $5/255.0;
|
$$.blue = $5/255.0;
|
||||||
|
@ -516,6 +499,14 @@ t_property_color
|
||||||
| T_COLOR {
|
| T_COLOR {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
| T_COLOR_TRANSPARENT {
|
||||||
|
$$.alpha = 0.0;
|
||||||
|
$$.red = $$.green = $$.blue = 0.0;
|
||||||
|
}
|
||||||
|
| T_COLOR_NAME t_property_color_opt_alpha_ws {
|
||||||
|
$$ = $1;
|
||||||
|
$$.alpha = $2;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
t_property_color_opt_alpha_c
|
t_property_color_opt_alpha_c
|
||||||
: %empty { $$ = 1.0; }
|
: %empty { $$ = 1.0; }
|
||||||
|
|
154
source/css-colors.c
Normal file
154
source/css-colors.c
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "css-colors.h"
|
||||||
|
const CSSColor CSSColors[] = {
|
||||||
|
{ .name = "AliceBlue", .r = 0xF0, .g = 0xF8, .b = 0xFF },
|
||||||
|
{ .name = "AntiqueWhite", .r = 0xFA, .g = 0xEB, .b = 0xD7 },
|
||||||
|
{ .name = "Aqua", .r = 0x00, .g = 0xFF, .b = 0xFF },
|
||||||
|
{ .name = "Aquamarine", .r = 0x7F, .g = 0xFF, .b = 0xD4 },
|
||||||
|
{ .name = "Azure", .r = 0xF0, .g = 0xFF, .b = 0xFF },
|
||||||
|
{ .name = "Beige", .r = 0xF5, .g = 0xF5, .b = 0xDC },
|
||||||
|
{ .name = "Bisque", .r = 0xFF, .g = 0xE4, .b = 0xC4 },
|
||||||
|
{ .name = "Black", .r = 0x00, .g = 0x00, .b = 0x00 },
|
||||||
|
{ .name = "BlanchedAlmond", .r = 0xFF, .g = 0xEB, .b = 0xCD },
|
||||||
|
{ .name = "Blue", .r = 0x00, .g = 0x00, .b = 0xFF },
|
||||||
|
{ .name = "BlueViolet", .r = 0x8A, .g = 0x2B, .b = 0xE2 },
|
||||||
|
{ .name = "Brown", .r = 0xA5, .g = 0x2A, .b = 0x2A },
|
||||||
|
{ .name = "BurlyWood", .r = 0xDE, .g = 0xB8, .b = 0x87 },
|
||||||
|
{ .name = "CadetBlue", .r = 0x5F, .g = 0x9E, .b = 0xA0 },
|
||||||
|
{ .name = "Chartreuse", .r = 0x7F, .g = 0xFF, .b = 0x00 },
|
||||||
|
{ .name = "Chocolate", .r = 0xD2, .g = 0x69, .b = 0x1E },
|
||||||
|
{ .name = "Coral", .r = 0xFF, .g = 0x7F, .b = 0x50 },
|
||||||
|
{ .name = "CornflowerBlue", .r = 0x64, .g = 0x95, .b = 0xED },
|
||||||
|
{ .name = "Cornsilk", .r = 0xFF, .g = 0xF8, .b = 0xDC },
|
||||||
|
{ .name = "Crimson", .r = 0xDC, .g = 0x14, .b = 0x3C },
|
||||||
|
{ .name = "Cyan", .r = 0x00, .g = 0xFF, .b = 0xFF },
|
||||||
|
{ .name = "DarkBlue", .r = 0x00, .g = 0x00, .b = 0x8B },
|
||||||
|
{ .name = "DarkCyan", .r = 0x00, .g = 0x8B, .b = 0x8B },
|
||||||
|
{ .name = "DarkGoldenRod", .r = 0xB8, .g = 0x86, .b = 0x0B },
|
||||||
|
{ .name = "DarkGray", .r = 0xA9, .g = 0xA9, .b = 0xA9 },
|
||||||
|
{ .name = "DarkGrey", .r = 0xA9, .g = 0xA9, .b = 0xA9 },
|
||||||
|
{ .name = "DarkGreen", .r = 0x00, .g = 0x64, .b = 0x00 },
|
||||||
|
{ .name = "DarkKhaki", .r = 0xBD, .g = 0xB7, .b = 0x6B },
|
||||||
|
{ .name = "DarkMagenta", .r = 0x8B, .g = 0x00, .b = 0x8B },
|
||||||
|
{ .name = "DarkOliveGreen", .r = 0x55, .g = 0x6B, .b = 0x2F },
|
||||||
|
{ .name = "DarkOrange", .r = 0xFF, .g = 0x8C, .b = 0x00 },
|
||||||
|
{ .name = "DarkOrchid", .r = 0x99, .g = 0x32, .b = 0xCC },
|
||||||
|
{ .name = "DarkRed", .r = 0x8B, .g = 0x00, .b = 0x00 },
|
||||||
|
{ .name = "DarkSalmon", .r = 0xE9, .g = 0x96, .b = 0x7A },
|
||||||
|
{ .name = "DarkSeaGreen", .r = 0x8F, .g = 0xBC, .b = 0x8F },
|
||||||
|
{ .name = "DarkSlateBlue", .r = 0x48, .g = 0x3D, .b = 0x8B },
|
||||||
|
{ .name = "DarkSlateGray", .r = 0x2F, .g = 0x4F, .b = 0x4F },
|
||||||
|
{ .name = "DarkSlateGrey", .r = 0x2F, .g = 0x4F, .b = 0x4F },
|
||||||
|
{ .name = "DarkTurquoise", .r = 0x00, .g = 0xCE, .b = 0xD1 },
|
||||||
|
{ .name = "DarkViolet", .r = 0x94, .g = 0x00, .b = 0xD3 },
|
||||||
|
{ .name = "DeepPink", .r = 0xFF, .g = 0x14, .b = 0x93 },
|
||||||
|
{ .name = "DeepSkyBlue", .r = 0x00, .g = 0xBF, .b = 0xFF },
|
||||||
|
{ .name = "DimGray", .r = 0x69, .g = 0x69, .b = 0x69 },
|
||||||
|
{ .name = "DimGrey", .r = 0x69, .g = 0x69, .b = 0x69 },
|
||||||
|
{ .name = "DodgerBlue", .r = 0x1E, .g = 0x90, .b = 0xFF },
|
||||||
|
{ .name = "FireBrick", .r = 0xB2, .g = 0x22, .b = 0x22 },
|
||||||
|
{ .name = "FloralWhite", .r = 0xFF, .g = 0xFA, .b = 0xF0 },
|
||||||
|
{ .name = "ForestGreen", .r = 0x22, .g = 0x8B, .b = 0x22 },
|
||||||
|
{ .name = "Fuchsia", .r = 0xFF, .g = 0x00, .b = 0xFF },
|
||||||
|
{ .name = "Gainsboro", .r = 0xDC, .g = 0xDC, .b = 0xDC },
|
||||||
|
{ .name = "GhostWhite", .r = 0xF8, .g = 0xF8, .b = 0xFF },
|
||||||
|
{ .name = "Gold", .r = 0xFF, .g = 0xD7, .b = 0x00 },
|
||||||
|
{ .name = "GoldenRod", .r = 0xDA, .g = 0xA5, .b = 0x20 },
|
||||||
|
{ .name = "Gray", .r = 0x80, .g = 0x80, .b = 0x80 },
|
||||||
|
{ .name = "Grey", .r = 0x80, .g = 0x80, .b = 0x80 },
|
||||||
|
{ .name = "Green", .r = 0x00, .g = 0x80, .b = 0x00 },
|
||||||
|
{ .name = "GreenYellow", .r = 0xAD, .g = 0xFF, .b = 0x2F },
|
||||||
|
{ .name = "HoneyDew", .r = 0xF0, .g = 0xFF, .b = 0xF0 },
|
||||||
|
{ .name = "HotPink", .r = 0xFF, .g = 0x69, .b = 0xB4 },
|
||||||
|
{ .name = "IndianRed", .r = 0xCD, .g = 0x5C, .b = 0x5C },
|
||||||
|
{ .name = "Indigo", .r = 0x4B, .g = 0x00, .b = 0x82 },
|
||||||
|
{ .name = "Ivory", .r = 0xFF, .g = 0xFF, .b = 0xF0 },
|
||||||
|
{ .name = "Khaki", .r = 0xF0, .g = 0xE6, .b = 0x8C },
|
||||||
|
{ .name = "Lavender", .r = 0xE6, .g = 0xE6, .b = 0xFA },
|
||||||
|
{ .name = "LavenderBlush", .r = 0xFF, .g = 0xF0, .b = 0xF5 },
|
||||||
|
{ .name = "LawnGreen", .r = 0x7C, .g = 0xFC, .b = 0x00 },
|
||||||
|
{ .name = "LemonChiffon", .r = 0xFF, .g = 0xFA, .b = 0xCD },
|
||||||
|
{ .name = "LightBlue", .r = 0xAD, .g = 0xD8, .b = 0xE6 },
|
||||||
|
{ .name = "LightCoral", .r = 0xF0, .g = 0x80, .b = 0x80 },
|
||||||
|
{ .name = "LightCyan", .r = 0xE0, .g = 0xFF, .b = 0xFF },
|
||||||
|
{ .name = "LightGoldenRodYellow", .r = 0xFA, .g = 0xFA, .b = 0xD2 },
|
||||||
|
{ .name = "LightGray", .r = 0xD3, .g = 0xD3, .b = 0xD3 },
|
||||||
|
{ .name = "LightGrey", .r = 0xD3, .g = 0xD3, .b = 0xD3 },
|
||||||
|
{ .name = "LightGreen", .r = 0x90, .g = 0xEE, .b = 0x90 },
|
||||||
|
{ .name = "LightPink", .r = 0xFF, .g = 0xB6, .b = 0xC1 },
|
||||||
|
{ .name = "LightSalmon", .r = 0xFF, .g = 0xA0, .b = 0x7A },
|
||||||
|
{ .name = "LightSeaGreen", .r = 0x20, .g = 0xB2, .b = 0xAA },
|
||||||
|
{ .name = "LightSkyBlue", .r = 0x87, .g = 0xCE, .b = 0xFA },
|
||||||
|
{ .name = "LightSlateGray", .r = 0x77, .g = 0x88, .b = 0x99 },
|
||||||
|
{ .name = "LightSlateGrey", .r = 0x77, .g = 0x88, .b = 0x99 },
|
||||||
|
{ .name = "LightSteelBlue", .r = 0xB0, .g = 0xC4, .b = 0xDE },
|
||||||
|
{ .name = "LightYellow", .r = 0xFF, .g = 0xFF, .b = 0xE0 },
|
||||||
|
{ .name = "Lime", .r = 0x00, .g = 0xFF, .b = 0x00 },
|
||||||
|
{ .name = "LimeGreen", .r = 0x32, .g = 0xCD, .b = 0x32 },
|
||||||
|
{ .name = "Linen", .r = 0xFA, .g = 0xF0, .b = 0xE6 },
|
||||||
|
{ .name = "Magenta", .r = 0xFF, .g = 0x00, .b = 0xFF },
|
||||||
|
{ .name = "Maroon", .r = 0x80, .g = 0x00, .b = 0x00 },
|
||||||
|
{ .name = "MediumAquaMarine", .r = 0x66, .g = 0xCD, .b = 0xAA },
|
||||||
|
{ .name = "MediumBlue", .r = 0x00, .g = 0x00, .b = 0xCD },
|
||||||
|
{ .name = "MediumOrchid", .r = 0xBA, .g = 0x55, .b = 0xD3 },
|
||||||
|
{ .name = "MediumPurple", .r = 0x93, .g = 0x70, .b = 0xDB },
|
||||||
|
{ .name = "MediumSeaGreen", .r = 0x3C, .g = 0xB3, .b = 0x71 },
|
||||||
|
{ .name = "MediumSlateBlue", .r = 0x7B, .g = 0x68, .b = 0xEE },
|
||||||
|
{ .name = "MediumSpringGreen", .r = 0x00, .g = 0xFA, .b = 0x9A },
|
||||||
|
{ .name = "MediumTurquoise", .r = 0x48, .g = 0xD1, .b = 0xCC },
|
||||||
|
{ .name = "MediumVioletRed", .r = 0xC7, .g = 0x15, .b = 0x85 },
|
||||||
|
{ .name = "MidnightBlue", .r = 0x19, .g = 0x19, .b = 0x70 },
|
||||||
|
{ .name = "MintCream", .r = 0xF5, .g = 0xFF, .b = 0xFA },
|
||||||
|
{ .name = "MistyRose", .r = 0xFF, .g = 0xE4, .b = 0xE1 },
|
||||||
|
{ .name = "Moccasin", .r = 0xFF, .g = 0xE4, .b = 0xB5 },
|
||||||
|
{ .name = "NavajoWhite", .r = 0xFF, .g = 0xDE, .b = 0xAD },
|
||||||
|
{ .name = "Navy", .r = 0x00, .g = 0x00, .b = 0x80 },
|
||||||
|
{ .name = "OldLace", .r = 0xFD, .g = 0xF5, .b = 0xE6 },
|
||||||
|
{ .name = "Olive", .r = 0x80, .g = 0x80, .b = 0x00 },
|
||||||
|
{ .name = "OliveDrab", .r = 0x6B, .g = 0x8E, .b = 0x23 },
|
||||||
|
{ .name = "Orange", .r = 0xFF, .g = 0xA5, .b = 0x00 },
|
||||||
|
{ .name = "OrangeRed", .r = 0xFF, .g = 0x45, .b = 0x00 },
|
||||||
|
{ .name = "Orchid", .r = 0xDA, .g = 0x70, .b = 0xD6 },
|
||||||
|
{ .name = "PaleGoldenRod", .r = 0xEE, .g = 0xE8, .b = 0xAA },
|
||||||
|
{ .name = "PaleGreen", .r = 0x98, .g = 0xFB, .b = 0x98 },
|
||||||
|
{ .name = "PaleTurquoise", .r = 0xAF, .g = 0xEE, .b = 0xEE },
|
||||||
|
{ .name = "PaleVioletRed", .r = 0xDB, .g = 0x70, .b = 0x93 },
|
||||||
|
{ .name = "PapayaWhip", .r = 0xFF, .g = 0xEF, .b = 0xD5 },
|
||||||
|
{ .name = "PeachPuff", .r = 0xFF, .g = 0xDA, .b = 0xB9 },
|
||||||
|
{ .name = "Peru", .r = 0xCD, .g = 0x85, .b = 0x3F },
|
||||||
|
{ .name = "Pink", .r = 0xFF, .g = 0xC0, .b = 0xCB },
|
||||||
|
{ .name = "Plum", .r = 0xDD, .g = 0xA0, .b = 0xDD },
|
||||||
|
{ .name = "PowderBlue", .r = 0xB0, .g = 0xE0, .b = 0xE6 },
|
||||||
|
{ .name = "Purple", .r = 0x80, .g = 0x00, .b = 0x80 },
|
||||||
|
{ .name = "RebeccaPurple", .r = 0x66, .g = 0x33, .b = 0x99 },
|
||||||
|
{ .name = "Red", .r = 0xFF, .g = 0x00, .b = 0x00 },
|
||||||
|
{ .name = "RosyBrown", .r = 0xBC, .g = 0x8F, .b = 0x8F },
|
||||||
|
{ .name = "RoyalBlue", .r = 0x41, .g = 0x69, .b = 0xE1 },
|
||||||
|
{ .name = "SaddleBrown", .r = 0x8B, .g = 0x45, .b = 0x13 },
|
||||||
|
{ .name = "Salmon", .r = 0xFA, .g = 0x80, .b = 0x72 },
|
||||||
|
{ .name = "SandyBrown", .r = 0xF4, .g = 0xA4, .b = 0x60 },
|
||||||
|
{ .name = "SeaGreen", .r = 0x2E, .g = 0x8B, .b = 0x57 },
|
||||||
|
{ .name = "SeaShell", .r = 0xFF, .g = 0xF5, .b = 0xEE },
|
||||||
|
{ .name = "Sienna", .r = 0xA0, .g = 0x52, .b = 0x2D },
|
||||||
|
{ .name = "Silver", .r = 0xC0, .g = 0xC0, .b = 0xC0 },
|
||||||
|
{ .name = "SkyBlue", .r = 0x87, .g = 0xCE, .b = 0xEB },
|
||||||
|
{ .name = "SlateBlue", .r = 0x6A, .g = 0x5A, .b = 0xCD },
|
||||||
|
{ .name = "SlateGray", .r = 0x70, .g = 0x80, .b = 0x90 },
|
||||||
|
{ .name = "SlateGrey", .r = 0x70, .g = 0x80, .b = 0x90 },
|
||||||
|
{ .name = "Snow", .r = 0xFF, .g = 0xFA, .b = 0xFA },
|
||||||
|
{ .name = "SpringGreen", .r = 0x00, .g = 0xFF, .b = 0x7F },
|
||||||
|
{ .name = "SteelBlue", .r = 0x46, .g = 0x82, .b = 0xB4 },
|
||||||
|
{ .name = "Tan", .r = 0xD2, .g = 0xB4, .b = 0x8C },
|
||||||
|
{ .name = "Teal", .r = 0x00, .g = 0x80, .b = 0x80 },
|
||||||
|
{ .name = "Thistle", .r = 0xD8, .g = 0xBF, .b = 0xD8 },
|
||||||
|
{ .name = "Tomato", .r = 0xFF, .g = 0x63, .b = 0x47 },
|
||||||
|
{ .name = "Turquoise", .r = 0x40, .g = 0xE0, .b = 0xD0 },
|
||||||
|
{ .name = "Violet", .r = 0xEE, .g = 0x82, .b = 0xEE },
|
||||||
|
{ .name = "Wheat", .r = 0xF5, .g = 0xDE, .b = 0xB3 },
|
||||||
|
{ .name = "White", .r = 0xFF, .g = 0xFF, .b = 0xFF },
|
||||||
|
{ .name = "WhiteSmoke", .r = 0xF5, .g = 0xF5, .b = 0xF5 },
|
||||||
|
{ .name = "Yellow", .r = 0xFF, .g = 0xFF, .b = 0x00 },
|
||||||
|
{ .name = "YellowGreen", .r = 0x9A, .g = 0xCD, .b = 0x32 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int num_CSSColors = sizeof ( CSSColors ) / sizeof ( *CSSColors );
|
|
@ -412,7 +412,7 @@ static int textbox_cursor_inc ( textbox *tb )
|
||||||
{
|
{
|
||||||
int old = tb->cursor;
|
int old = tb->cursor;
|
||||||
textbox_cursor ( tb, tb->cursor + 1 );
|
textbox_cursor ( tb, tb->cursor + 1 );
|
||||||
return ( old != tb->cursor );
|
return old != tb->cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,7 +426,7 @@ static int textbox_cursor_dec ( textbox *tb )
|
||||||
{
|
{
|
||||||
int old = tb->cursor;
|
int old = tb->cursor;
|
||||||
textbox_cursor ( tb, tb->cursor - 1 );
|
textbox_cursor ( tb, tb->cursor - 1 );
|
||||||
return ( old != tb->cursor );
|
return old != tb->cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move word right
|
// Move word right
|
||||||
|
|
|
@ -739,7 +739,6 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
||||||
modmask = last_modmask;
|
modmask = last_modmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( error_msg ) {
|
if ( error_msg ) {
|
||||||
char *name = g_markup_escape_text ( combo, -1 );
|
char *name = g_markup_escape_text ( combo, -1 );
|
||||||
g_string_append_printf ( str, "Cannot understand the key combination: <i>%s</i>\n", name );
|
g_string_append_printf ( str, "Cannot understand the key combination: <i>%s</i>\n", name );
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
#include "css-colors.h"
|
||||||
#include "widgets/widget-internal.h"
|
#include "widgets/widget-internal.h"
|
||||||
#include "widgets/textbox.h"
|
#include "widgets/textbox.h"
|
||||||
|
|
||||||
|
@ -738,6 +739,46 @@ START_TEST ( test_properties_color_cmyk_ws )
|
||||||
ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004);
|
ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
START_TEST ( test_properties_color_names )
|
||||||
|
{
|
||||||
|
widget wid;
|
||||||
|
wid.name = "blaat";
|
||||||
|
wid.state = NULL;
|
||||||
|
for ( unsigned int iter = 0; iter < num_CSSColors; iter++ ) {
|
||||||
|
char * str = g_strdup_printf("* { color: %s;}", CSSColors[iter].name);
|
||||||
|
rofi_theme_parse_string(str);
|
||||||
|
ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE );
|
||||||
|
Property *p = rofi_theme_find_property ( twid, P_COLOR, "color", FALSE );
|
||||||
|
ck_assert_ptr_nonnull ( p );
|
||||||
|
ck_assert_double_eq ( p->value.color.alpha , 1.0 );
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.red , CSSColors[iter].r/255.0, 0.004);
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.green, CSSColors[iter].g/255.0, 0.004 );
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.blue , CSSColors[iter].b/255.0, 0.004);
|
||||||
|
|
||||||
|
g_free ( str );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
START_TEST ( test_properties_color_names_alpha )
|
||||||
|
{
|
||||||
|
widget wid;
|
||||||
|
wid.name = "blaat";
|
||||||
|
wid.state = NULL;
|
||||||
|
for ( unsigned int iter = 0; iter < num_CSSColors; iter++ ) {
|
||||||
|
char * str = g_strdup_printf("* { color: %s / %d %%;}", CSSColors[iter].name, iter%101);
|
||||||
|
rofi_theme_parse_string(str);
|
||||||
|
ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE );
|
||||||
|
Property *p = rofi_theme_find_property ( twid, P_COLOR, "color", FALSE );
|
||||||
|
ck_assert_ptr_nonnull ( p );
|
||||||
|
ck_assert_double_eq ( p->value.color.alpha , (iter%101)/100.0);
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.red , CSSColors[iter].r/255.0, 0.004);
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.green, CSSColors[iter].g/255.0, 0.004 );
|
||||||
|
ck_assert_double_eq_tol ( p->value.color.blue , CSSColors[iter].b/255.0, 0.004);
|
||||||
|
|
||||||
|
g_free ( str );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
START_TEST ( test_properties_padding_2 )
|
START_TEST ( test_properties_padding_2 )
|
||||||
{
|
{
|
||||||
widget wid;
|
widget wid;
|
||||||
|
@ -875,7 +916,7 @@ START_TEST ( test_core_properties_error )
|
||||||
rofi_theme_parse_string ( " * { test: cmky(a,e,3); }");
|
rofi_theme_parse_string ( " * { test: cmky(a,e,3); }");
|
||||||
const char *errstr = "<big><b>Error while parsing theme:</b></big> <i> * { test: cmky(a,e,3); }</i>\n"\
|
const char *errstr = "<big><b>Error while parsing theme:</b></big> <i> * { test: cmky(a,e,3); }</i>\n"\
|
||||||
" Parser error: <span size=\"smaller\" style=\"italic\">syntax error, unexpected invalid property value</span>\n"\
|
" Parser error: <span size=\"smaller\" style=\"italic\">syntax error, unexpected invalid property value</span>\n"\
|
||||||
" Location: line 1 column 11 to line 1 column 13\n";
|
" Location: line 1 column 11 to line 1 column 23\n";
|
||||||
ck_assert_int_eq ( error, 1);
|
ck_assert_int_eq ( error, 1);
|
||||||
ck_assert_str_eq ( error_msg->str, errstr );
|
ck_assert_str_eq ( error_msg->str, errstr );
|
||||||
g_string_free ( error_msg, TRUE);
|
g_string_free ( error_msg, TRUE);
|
||||||
|
@ -968,6 +1009,8 @@ static Suite * theme_parser_suite (void)
|
||||||
tcase_add_test ( tc_prop_color, test_properties_color_hwb_ws);
|
tcase_add_test ( tc_prop_color, test_properties_color_hwb_ws);
|
||||||
tcase_add_test ( tc_prop_color, test_properties_color_cmyk);
|
tcase_add_test ( tc_prop_color, test_properties_color_cmyk);
|
||||||
tcase_add_test ( tc_prop_color, test_properties_color_cmyk_ws);
|
tcase_add_test ( tc_prop_color, test_properties_color_cmyk_ws);
|
||||||
|
tcase_add_test ( tc_prop_color, test_properties_color_names);
|
||||||
|
tcase_add_test ( tc_prop_color, test_properties_color_names_alpha);
|
||||||
suite_add_tcase(s, tc_prop_color );
|
suite_add_tcase(s, tc_prop_color );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue