From 6f117c3589a9014e3877fc0341c9bc974afab6b7 Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Thu, 4 May 2017 23:42:01 +0200 Subject: [PATCH 01/36] xkb: Use consumed2 API when available Signed-off-by: Quentin Glidic --- configure.ac | 1 + source/view.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index 21f21161..a77ce00e 100644 --- a/configure.ac +++ b/configure.ac @@ -117,6 +117,7 @@ dnl PKG_CONFIG based dependencies dnl --------------------------------------------------------------------- PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0]) GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama]) +PKG_CHECK_EXISTS([xkbcommon >= 0.7.0], [AC_DEFINE([XkBCOMMON_HAS_CONSUMED2], [1], [If xkbcommon has the consumed2 API])]) PKG_CHECK_MODULES([pango], [pango pangocairo]) PKG_CHECK_MODULES([cairo], [cairo cairo-xcb]) PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ]) diff --git a/source/view.c b/source/view.c index 3186c873..771627da 100644 --- a/source/view.c +++ b/source/view.c @@ -68,6 +68,11 @@ #include "theme.h" #include "xcb.h" + +#ifdef XkBCOMMON_HAS_CONSUMED2 +#define xkb_state_key_get_consumed_mods(s, k) xkb_state_key_get_consumed_mods2(s, k, XKB_CONSUMED_MODE_GTK) +#endif + /** * @param state The handle to the view * @param qr Indicate if queue_redraw should be called on changes. From bb5d839f9c2110a78823a35b25a4ececfa7be7e7 Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Thu, 4 May 2017 23:53:52 +0200 Subject: [PATCH 02/36] xkb: Allow binding modifiers And modified modifiers too. Signed-off-by: Quentin Glidic --- source/x11-helper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/x11-helper.c b/source/x11-helper.c index 0e58d829..4a66ba36 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -662,8 +662,10 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key char *input_key = g_strdup ( combo ); char *mod_key = input_key; char *error_msg = NULL; - unsigned int modmask = 0; - xkb_keysym_t sym = XKB_KEY_NoSymbol; + unsigned int last_modmask = 0; + unsigned int modmask = 0; + xkb_keysym_t last_sym = XKB_KEY_NoSymbol; + xkb_keysym_t sym = XKB_KEY_NoSymbol; // Test if this works on release. if ( g_str_has_prefix ( mod_key, "!" ) ) { ++mod_key; @@ -676,6 +678,8 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key // Remove trailing and leading spaces. entry = g_strstrip ( entry ); // Compare against lowered version. + last_modmask = modmask; + last_sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); char *entry_lowered = g_utf8_strdown ( entry, -1 ); if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) { modmask |= x11_mod_masks[X11MOD_SHIFT]; @@ -720,7 +724,7 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key if ( sym != XKB_KEY_NoSymbol ) { error_msg = g_markup_printf_escaped ( "Only one (non modifier) key can be bound per binding: %s is invalid.\n", entry ); } - sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); + sym = last_sym; if ( sym == XKB_KEY_NoSymbol ) { error_msg = g_markup_printf_escaped ( "∙ Key %s is not understood\n", entry ); } @@ -730,6 +734,11 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key g_strfreev ( entries ); g_free ( input_key ); + if ( ( sym == XKB_KEY_NoSymbol ) && ( last_sym != XKB_KEY_NoSymbol ) ) { + sym = last_sym; + modmask = last_modmask; + } + if ( error_msg ) { char *name = g_markup_escape_text ( combo, -1 ); From a8bf476db3457e699aa6c9b1f3afc002585f8ba8 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 6 May 2017 16:10:20 +0200 Subject: [PATCH 03/36] Add support for hwb,hsl,cmyk (need tests) --- lexer/theme-lexer.l | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 8d7e5718..8e24b315 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -36,6 +36,7 @@ #include #include #include +#include #include "rofi.h" #include "theme.h" @@ -82,6 +83,39 @@ GQueue *queue = NULL; ParseObject *current = NULL; static char * rofi_theme_parse_prepare_file ( const char *file, const char *parent_file ); +#define IN_RANGE(index,low,high) ( ( (index) > (low) )? ( ( (index) < (high) )? (index):(high) ) : ( low ) ) + +static double hue2rgb(double p, double q, double t){ + t += (t<0)?1:0; + t -= (t>1)?1:0; + if( t < (1/6.0) ) { + return p + (q - p) * 6 * t; + } + if( t < (1/2.0) ) { + return q; + } + if( t < (2/3.0) ) { + return p + (q - p) * (2/3.0 - t) * 6; + } + return p; +} +static ThemeColor hsl_to_rgb ( double h, double s, double l ) +{ + ThemeColor colour; + + if(s < 0.001 && s > -0.001){ + colour.red = colour.green = colour.blue = l; // achromatic + }else{ + + double q = l < 0.5 ? l * (1 + s) : l + s - l * s; + double p = 2 * l - q; + colour.red = hue2rgb(p, q, h + 1/3.0); + colour.green = hue2rgb(p, q, h); + colour.blue = hue2rgb(p, q, h - 1/3.0); + } + + return colour; +} %} %{ @@ -448,6 +482,52 @@ if ( queue == NULL ){ yylval->colorval.alpha = 1.0; return T_COLOR; } +hsl\({NUMBER}{1,3},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { + char *endptr = &yytext[4]; + gint64 hi= g_ascii_strtoll ( endptr, &endptr, 10); + gint64 si= g_ascii_strtoll ( endptr+1, &endptr, 10); + gint64 li= g_ascii_strtoll ( endptr+2, &endptr, 10); + gdouble h = IN_RANGE(hi, 0, 359); + gdouble s = IN_RANGE(si, 0, 100); + gdouble l = IN_RANGE(li, 0, 100); + yylval->colorval = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); + yylval->colorval.alpha = 1.0; + return T_COLOR; +} +cmyk\([1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { + char *endptr = &yytext[5]; + gint64 ci = g_ascii_strtoll ( endptr, &endptr, 10); + gint64 mi = g_ascii_strtoll ( endptr+2, &endptr, 10); + gint64 my = g_ascii_strtoll ( endptr+2, &endptr, 10); + gint64 mk = g_ascii_strtoll ( endptr+2, &endptr, 10); + double c= IN_RANGE(ci, 0, 100)/100.0; + double m= IN_RANGE(mi, 0, 100)/100.0; + double y= IN_RANGE(my, 0, 100)/100.0; + double k= IN_RANGE(mk, 0, 100)/100.0; + yylval->colorval.red = (1.0-c)*(1.0-k); + yylval->colorval.green = (1.0-m)*(1.0-k); + yylval->colorval.blue = (1.0-y)*(1.0-k); + yylval->colorval.alpha = 1.0; + return T_COLOR; +} +hwb\({NUMBER}{1,3},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { + char *endptr = &yytext[4]; + gint64 hi = g_ascii_strtoll ( endptr, &endptr, 10); + gint64 hw = g_ascii_strtoll ( endptr+1, &endptr, 10); + gint64 hb = g_ascii_strtoll ( endptr+2, &endptr, 10); + double h= IN_RANGE(hi,0,360)/360.0; + double w= IN_RANGE(hw,0,100)/100.0; + double b= IN_RANGE(hb,0,100)/100.0; + yylval->colorval = hsl_to_rgb ( h, 1.0, 0.5); + yylval->colorval.red *= ( 1. - w - b ); + yylval->colorval.red += w; + yylval->colorval.green *= ( 1. - w - b ); + yylval->colorval.green += w; + yylval->colorval.blue *= ( 1. - w - b ); + yylval->colorval.blue += w; + yylval->colorval.alpha = 1.0; + return T_COLOR; +} argb:{HEX}{1,8} { union { unsigned int val; struct { unsigned char b,g,r,a;};} val; val.val = (unsigned int)strtoull ( &yytext[5], NULL, 16); From 2a381856aa554965d6d1b18bbded6c60c0b41ed4 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 8 May 2017 22:21:01 +0200 Subject: [PATCH 04/36] Allow more whitespace in colortype() structure --- lexer/theme-lexer.l | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 8e24b315..cf0cfdf4 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -178,6 +178,7 @@ UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} // UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} WHITESPACE [[:blank:]] +WSO [[:blank:]]* WORD [[:alnum:]-]+ STRING {UANYN}+ HEX [[:xdigit:]] @@ -466,7 +467,7 @@ if ( queue == NULL ){ yylval->colorval.blue = val.b/15.0; return T_COLOR; } -rgba\({NUMBER}{1,3},{NUMBER}{1,3},{NUMBER}{1,3},[01](\.{NUMBER}+)?\) { +rgba\({WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}[01](\.{NUMBER}+)?\) { char *endptr = &yytext[5]; yylval->colorval.red = g_ascii_strtoull ( endptr, &endptr, 10)/255.0; yylval->colorval.green= g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; @@ -474,7 +475,7 @@ if ( queue == NULL ){ yylval->colorval.alpha= g_ascii_strtod ( endptr+1, NULL); return T_COLOR; } -rgb\({NUMBER}{1,3},{NUMBER}{1,3},{NUMBER}{1,3}\) { +rgb\({WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3}\) { char *endptr = &yytext[4]; yylval->colorval.red = g_ascii_strtoull ( endptr, &endptr, 10)/255.0; yylval->colorval.green = g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; @@ -482,7 +483,7 @@ if ( queue == NULL ){ yylval->colorval.alpha = 1.0; return T_COLOR; } -hsl\({NUMBER}{1,3},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { +hsl\({WSO}{NUMBER}{1,3},{WSO}[1]?{NUMBER}{1,2}{PERCENT},{WSO}[1]?{NUMBER}{1,2}{PERCENT}\) { char *endptr = &yytext[4]; gint64 hi= g_ascii_strtoll ( endptr, &endptr, 10); gint64 si= g_ascii_strtoll ( endptr+1, &endptr, 10); @@ -494,7 +495,7 @@ if ( queue == NULL ){ yylval->colorval.alpha = 1.0; return T_COLOR; } -cmyk\([1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { +cmyk\({WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT}\) { char *endptr = &yytext[5]; gint64 ci = g_ascii_strtoll ( endptr, &endptr, 10); gint64 mi = g_ascii_strtoll ( endptr+2, &endptr, 10); @@ -510,7 +511,7 @@ if ( queue == NULL ){ yylval->colorval.alpha = 1.0; return T_COLOR; } -hwb\({NUMBER}{1,3},[1]?{NUMBER}{1,2}{PERCENT},[1]?{NUMBER}{1,2}{PERCENT}\) { +hwb\({WHITESPACE}{NUMBER}{1,3},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT}\) { char *endptr = &yytext[4]; gint64 hi = g_ascii_strtoll ( endptr, &endptr, 10); gint64 hw = g_ascii_strtoll ( endptr+1, &endptr, 10); From cf8796ccd3cf04b4ab1029f3da32c7784443e1d1 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 9 May 2017 13:53:45 +0200 Subject: [PATCH 05/36] Move position parsing to bison file. --- include/settings.h | 24 +++++++++++------------ lexer/theme-lexer.l | 41 +++++----------------------------------- lexer/theme-parser.y | 37 ++++++++++++++++++++++++++++++++++-- test/theme-parser-test.c | 21 ++++++++++++++++++++ 4 files changed, 73 insertions(+), 50 deletions(-) diff --git a/include/settings.h b/include/settings.h index 572ebd6b..b0506f64 100644 --- a/include/settings.h +++ b/include/settings.h @@ -56,22 +56,22 @@ typedef enum { /** Center */ WL_CENTER = 0, - /** Left top corner. */ - WL_NORTH_WEST = 1, /** Top middle */ - WL_NORTH = 2, - /** Top right */ - WL_NORTH_EAST = 3, + WL_NORTH = 1, /** Middle right */ - WL_EAST = 4, - /** Bottom right */ - WL_SOUTH_EAST = 5, + WL_EAST = 2, /** Bottom middle */ - WL_SOUTH = 6, - /** Bottom left */ - WL_SOUTH_WEST = 7, + WL_SOUTH = 4, /** Middle left */ - WL_WEST = 8 + WL_WEST = 8, + /** Left top corner. */ + WL_NORTH_WEST = WL_NORTH|WL_WEST, + /** Top right */ + WL_NORTH_EAST = WL_NORTH|WL_EAST, + /** Bottom right */ + WL_SOUTH_EAST = WL_SOUTH|WL_EAST, + /** Bottom left */ + WL_SOUTH_WEST = WL_SOUTH|WL_WEST, } WindowLocation; /** diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index cf0cfdf4..0829ef33 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -539,42 +539,11 @@ if ( queue == NULL ){ return T_COLOR; } -{CENTER} { - yylval->ival = WL_CENTER; - return T_POSITION; -} -{EAST} { - yylval->ival = WL_EAST; - return T_POSITION; -} -{WEST} { - yylval->ival = WL_WEST; - return T_POSITION; -} -{SOUTH}{EAST} { - yylval->ival = WL_SOUTH_EAST; - return T_POSITION; -} -{SOUTH}{WEST} { - yylval->ival = WL_SOUTH_WEST; - return T_POSITION; -} -{SOUTH} { - yylval->ival = WL_SOUTH; - return T_POSITION; -} -{NORTH}{EAST} { - yylval->ival = WL_NORTH_EAST; - return T_POSITION; -} -{NORTH}{WEST} { - yylval->ival = WL_NORTH_WEST; - return T_POSITION; -} -{NORTH} { - yylval->ival = WL_NORTH; - return T_POSITION; -} +{CENTER} { return T_POS_CENTER; } +{EAST} { return T_POS_EAST; } +{WEST} { return T_POS_WEST; } +{SOUTH} { return T_POS_SOUTH; } +{NORTH} { return T_POS_NORTH; } {NONE} { yylval->ival = HL_NONE; return T_HIGHLIGHT_STYLE; diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 99f47ccc..6a414f70 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -81,6 +81,7 @@ int yylex (YYSTYPE *, YYLTYPE *); double fval; char *sval; int bval; + WindowLocation wloc; ThemeColor colorval; ThemeWidget *theme; GList *name_path; @@ -100,7 +101,6 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_DOUBLE %token T_STRING %token N_STRING "property name" -%token T_POSITION; %token T_HIGHLIGHT_STYLE %token NAME_ELEMENT "Element name" %token T_BOOLEAN @@ -108,6 +108,12 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_PIXEL %token T_LINK %token FIRST_NAME +%token T_POS_CENTER "Center" +%token T_POS_EAST "East" +%token T_POS_WEST "West" +%token T_POS_NORTH "North" +%token T_POS_SOUTH "South" + %token BOPEN "bracket open ('{')" %token BCLOSE "bracket close ('}')" @@ -120,6 +126,9 @@ int yylex (YYSTYPE *, YYLTYPE *); %token CONFIGURATION "Configuration block" %type highlight_styles +%type t_position +%type t_position_ew +%type t_position_sn %type entry %type pvalue %type entries @@ -242,7 +251,7 @@ property $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $6 }; } -| pvalue PSEP T_POSITION PCLOSE{ +| pvalue PSEP t_position PCLOSE{ $$ = rofi_theme_property_create ( P_POSITION ); $$->name = $1; $$->value.i = $3; @@ -260,6 +269,30 @@ property } ; +/** + * Position can be either center, + * East or West, North Or South + * Or combi of East or West and North or South + */ +t_position +: T_POS_CENTER { $$ =WL_CENTER;} +| t_position_ew +| t_position_sn +| t_position_ew t_position_sn { $$ = $1|$2;} +| t_position_sn t_position_ew { $$ = $1|$2;} +; +t_position_ew +: T_POS_EAST { $$ = WL_EAST;} +| T_POS_WEST { $$ = WL_WEST;} +; +t_position_sn +: T_POS_NORTH { $$ = WL_NORTH;} +| T_POS_SOUTH { $$ = WL_SOUTH;} +; + +/** + * Highlight style, allow mulitple styles to be combined. + */ highlight_styles: T_HIGHLIGHT_STYLE { $$ = $1; } | highlight_styles T_HIGHLIGHT_STYLE { diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 19f1744b..d9eda720 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -332,6 +332,27 @@ START_TEST ( test_properties_position) ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southeast", WL_WEST) , WL_SOUTH_EAST); ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northwest", WL_NORTH) , WL_NORTH_WEST); ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northeast", WL_CENTER) , WL_NORTH_EAST); + rofi_theme_parse_string ( "* { southwest: south west; southeast: south east; northwest: north west; northeast:north east;}" ); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southwest", WL_EAST) , WL_SOUTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southeast", WL_WEST) , WL_SOUTH_EAST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northwest", WL_NORTH) , WL_NORTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northeast", WL_CENTER) , WL_NORTH_EAST); + rofi_theme_parse_string ( "* { westsouth: westsouth; eastsouth: eastsouth; westnorth: westnorth; eastnorth:eastnorth;}" ); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westsouth", WL_EAST) , WL_SOUTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastsouth", WL_WEST) , WL_SOUTH_EAST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westnorth", WL_NORTH) , WL_NORTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastnorth", WL_CENTER) , WL_NORTH_EAST); + rofi_theme_parse_string ( "* { westsouth: west south; eastsouth: east south; westnorth: west north; eastnorth:east north;}" ); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westsouth", WL_EAST) , WL_SOUTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastsouth", WL_WEST) , WL_SOUTH_EAST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westnorth", WL_NORTH) , WL_NORTH_WEST); + ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastnorth", WL_CENTER) , WL_NORTH_EAST); + rofi_theme_parse_string ( "* { westeast: west east;}" ); + // Should return error. + // TODO: check error message. + g_string_free ( error_msg, TRUE); + error_msg = NULL; + error = 0; } END_TEST From 00e297c5caefa21daf896a22ab1092131d60999a Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 9 May 2017 14:12:03 +0200 Subject: [PATCH 06/36] Update highlight style parsing --- lexer/theme-lexer.l | 36 ++++++++++++------------------------ lexer/theme-parser.y | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 0829ef33..e80d57a0 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -377,11 +377,11 @@ if ( queue == NULL ){
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return PSEP; } ";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return PCLOSE;} -(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} +(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} {PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} {PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} -\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;} -@{WORD} { +\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;} +@{WORD} { yylval->sval = g_strdup(yytext); return T_LINK; } @@ -539,27 +539,15 @@ if ( queue == NULL ){ return T_COLOR; } -{CENTER} { return T_POS_CENTER; } -{EAST} { return T_POS_EAST; } -{WEST} { return T_POS_WEST; } -{SOUTH} { return T_POS_SOUTH; } -{NORTH} { return T_POS_NORTH; } -{NONE} { - yylval->ival = HL_NONE; - return T_HIGHLIGHT_STYLE; -} -{BOLD} { - yylval->ival = HL_BOLD; - return T_HIGHLIGHT_STYLE; -} -{ITALIC} { - yylval->ival = HL_ITALIC; - return T_HIGHLIGHT_STYLE; -} -{UNDERLINE} { - yylval->ival = HL_UNDERLINE; - return T_HIGHLIGHT_STYLE; -} +{CENTER} { return T_POS_CENTER; } +{EAST} { return T_POS_EAST; } +{WEST} { return T_POS_WEST; } +{SOUTH} { return T_POS_SOUTH; } +{NORTH} { return T_POS_NORTH; } +{NONE} { return T_NONE; } +{BOLD} { return T_BOLD; } +{ITALIC} { return T_ITALIC; } +{UNDERLINE} { return T_UNDERLINE; } <> { ParseObject *po = g_queue_pop_head ( file_queue ); if ( po ) { diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 6a414f70..d82dc4a5 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -101,7 +101,6 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_DOUBLE %token T_STRING %token N_STRING "property name" -%token T_HIGHLIGHT_STYLE %token NAME_ELEMENT "Element name" %token T_BOOLEAN %token T_COLOR @@ -114,6 +113,11 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_POS_NORTH "North" %token T_POS_SOUTH "South" +%token T_NONE "None" +%token T_BOLD "Bold" +%token T_ITALIC "Italic" +%token T_UNDERLINE "Underline" + %token BOPEN "bracket open ('{')" %token BCLOSE "bracket close ('}')" @@ -126,6 +130,7 @@ int yylex (YYSTYPE *, YYLTYPE *); %token CONFIGURATION "Configuration block" %type highlight_styles +%type highlight_style %type t_position %type t_position_ew %type t_position_sn @@ -292,12 +297,18 @@ t_position_sn /** * Highlight style, allow mulitple styles to be combined. + * Empty not allowed */ -highlight_styles: - T_HIGHLIGHT_STYLE { $$ = $1; } -| highlight_styles T_HIGHLIGHT_STYLE { - $$ = $1 | $2; -} +highlight_styles +: highlight_style { $$ = $1;} +| highlight_styles highlight_style { $$ = $1|$2;} +; +/** Single style. */ +highlight_style +: T_NONE { $$ = HL_NONE; } +| T_BOLD { $$ = HL_BOLD; } +| T_UNDERLINE { $$ = HL_UNDERLINE; } +| T_ITALIC { $$ = HL_ITALIC; } ; pvalue: N_STRING { $$ = $1; } From f5b1e4b3d426acb3fbfb3ba0a0bbc3d63d488680 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 10 May 2017 12:41:06 +0200 Subject: [PATCH 07/36] Move most of the parsing to yacc instead of lexer --- lexer/theme-lexer.l | 219 +++++++++++-------------------------------- lexer/theme-parser.y | 159 ++++++++++++++++++++++++++++--- 2 files changed, 201 insertions(+), 177 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index e80d57a0..2365410d 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -83,39 +83,6 @@ GQueue *queue = NULL; ParseObject *current = NULL; static char * rofi_theme_parse_prepare_file ( const char *file, const char *parent_file ); -#define IN_RANGE(index,low,high) ( ( (index) > (low) )? ( ( (index) < (high) )? (index):(high) ) : ( low ) ) - -static double hue2rgb(double p, double q, double t){ - t += (t<0)?1:0; - t -= (t>1)?1:0; - if( t < (1/6.0) ) { - return p + (q - p) * 6 * t; - } - if( t < (1/2.0) ) { - return q; - } - if( t < (2/3.0) ) { - return p + (q - p) * (2/3.0 - t) * 6; - } - return p; -} -static ThemeColor hsl_to_rgb ( double h, double s, double l ) -{ - ThemeColor colour; - - if(s < 0.001 && s > -0.001){ - colour.red = colour.green = colour.blue = l; // achromatic - }else{ - - double q = l < 0.5 ? l * (1 + s) : l + s - l * s; - double p = 2 * l - q; - colour.red = hue2rgb(p, q, h + 1/3.0); - colour.green = hue2rgb(p, q, h); - colour.blue = hue2rgb(p, q, h - 1/3.0); - } - - return colour; -} %} %{ @@ -191,16 +158,30 @@ PERCENT (\%) ASTERIX \* + /* Position */ CENTER "center" NORTH "north" SOUTH "south" EAST "east" WEST "west" -NONE "none" -BOLD "bold" -UNDERLINE "underline" -ITALIC "italic" + /* Line Style */ +NONE "none" +BOLD "bold" +UNDERLINE "underline" +ITALIC "italic" + + /* Color schema */ +ARGB "argb" +RGBA "rgba" +RGB "rgb" +HWB "hwb" +CMYK "cmyk" +HSL "hsl" + +PARENT_LEFT \( +PARENT_RIGHT \) +COMMA , LS_DASH "dash" LS_SOLID "solid" @@ -375,71 +356,27 @@ if ( queue == NULL ){ {WHITESPACE}+ ; // ignore all whitespace {WHITESPACE}+ ; // ignore all whitespace -
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return PSEP; } -";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return PCLOSE;} +
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return PSEP; } +";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return PCLOSE;} (true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} -{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} {PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} +{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} \"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;} @{WORD} { yylval->sval = g_strdup(yytext); return T_LINK; } -{REAL}{EM} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_EM; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{PNNUMBER}{PX} { - yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10); - yylval->distance.type = PW_PX; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{PNNUMBER}{PX}{WHITESPACE}{LS_DASH} { - yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10); - yylval->distance.type = PW_PX; - yylval->distance.style = DASH; - return T_PIXEL; -} -{REAL}{EM}{WHITESPACE}{LS_DASH} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_EM; - yylval->distance.style = DASH; - return T_PIXEL; -} -{PNNUMBER}{PX}{WHITESPACE}{LS_SOLID} { - yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10); - yylval->distance.type = PW_PX; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{REAL}{EM}{WHITESPACE}{LS_SOLID} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_EM; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{REAL}{PERCENT} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_PERCENT; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{REAL}{PERCENT}{WHITESPACE}{LS_SOLID} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_PERCENT; - yylval->distance.style = SOLID; - return T_PIXEL; -} -{REAL}{PERCENT}{WHITESPACE}{LS_DASH} { - yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL); - yylval->distance.type = PW_PERCENT; - yylval->distance.style = DASH; - return T_PIXEL; -} +{EM} { return T_UNIT_EM; } +{PX} { return T_UNIT_PX; } +{PERCENT} { return PERCENT; } +{LS_SOLID} { return T_SOLID; } +{LS_DASH} { return T_DASH; } + + /** + * Color parsing. It is easier to do this at lexer level. + * Other schemes are done at yacc level. + */ #{HEX}{8} { union { unsigned int val; struct { unsigned char b,g,r,a;};} val; val.val = (unsigned int)strtoull ( &yytext[1], NULL, 16); @@ -467,68 +404,6 @@ if ( queue == NULL ){ yylval->colorval.blue = val.b/15.0; return T_COLOR; } -rgba\({WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}[01](\.{NUMBER}+)?\) { - char *endptr = &yytext[5]; - yylval->colorval.red = g_ascii_strtoull ( endptr, &endptr, 10)/255.0; - yylval->colorval.green= g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; - yylval->colorval.blue= g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; - yylval->colorval.alpha= g_ascii_strtod ( endptr+1, NULL); - return T_COLOR; -} -rgb\({WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3},{WSO}{NUMBER}{1,3}\) { - char *endptr = &yytext[4]; - yylval->colorval.red = g_ascii_strtoull ( endptr, &endptr, 10)/255.0; - yylval->colorval.green = g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; - yylval->colorval.blue = g_ascii_strtoull ( endptr+1, &endptr, 10)/255.0; - yylval->colorval.alpha = 1.0; - return T_COLOR; -} -hsl\({WSO}{NUMBER}{1,3},{WSO}[1]?{NUMBER}{1,2}{PERCENT},{WSO}[1]?{NUMBER}{1,2}{PERCENT}\) { - char *endptr = &yytext[4]; - gint64 hi= g_ascii_strtoll ( endptr, &endptr, 10); - gint64 si= g_ascii_strtoll ( endptr+1, &endptr, 10); - gint64 li= g_ascii_strtoll ( endptr+2, &endptr, 10); - gdouble h = IN_RANGE(hi, 0, 359); - gdouble s = IN_RANGE(si, 0, 100); - gdouble l = IN_RANGE(li, 0, 100); - yylval->colorval = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); - yylval->colorval.alpha = 1.0; - return T_COLOR; -} -cmyk\({WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT}\) { - char *endptr = &yytext[5]; - gint64 ci = g_ascii_strtoll ( endptr, &endptr, 10); - gint64 mi = g_ascii_strtoll ( endptr+2, &endptr, 10); - gint64 my = g_ascii_strtoll ( endptr+2, &endptr, 10); - gint64 mk = g_ascii_strtoll ( endptr+2, &endptr, 10); - double c= IN_RANGE(ci, 0, 100)/100.0; - double m= IN_RANGE(mi, 0, 100)/100.0; - double y= IN_RANGE(my, 0, 100)/100.0; - double k= IN_RANGE(mk, 0, 100)/100.0; - yylval->colorval.red = (1.0-c)*(1.0-k); - yylval->colorval.green = (1.0-m)*(1.0-k); - yylval->colorval.blue = (1.0-y)*(1.0-k); - yylval->colorval.alpha = 1.0; - return T_COLOR; -} -hwb\({WHITESPACE}{NUMBER}{1,3},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT},{WHITESPACE}[1]?{NUMBER}{1,2}{PERCENT}\) { - char *endptr = &yytext[4]; - gint64 hi = g_ascii_strtoll ( endptr, &endptr, 10); - gint64 hw = g_ascii_strtoll ( endptr+1, &endptr, 10); - gint64 hb = g_ascii_strtoll ( endptr+2, &endptr, 10); - double h= IN_RANGE(hi,0,360)/360.0; - double w= IN_RANGE(hw,0,100)/100.0; - double b= IN_RANGE(hb,0,100)/100.0; - yylval->colorval = hsl_to_rgb ( h, 1.0, 0.5); - yylval->colorval.red *= ( 1. - w - b ); - yylval->colorval.red += w; - yylval->colorval.green *= ( 1. - w - b ); - yylval->colorval.green += w; - yylval->colorval.blue *= ( 1. - w - b ); - yylval->colorval.blue += w; - yylval->colorval.alpha = 1.0; - return T_COLOR; -} argb:{HEX}{1,8} { union { unsigned int val; struct { unsigned char b,g,r,a;};} val; val.val = (unsigned int)strtoull ( &yytext[5], NULL, 16); @@ -538,16 +413,30 @@ if ( queue == NULL ){ yylval->colorval.blue = val.b/255.0; return T_COLOR; } + /* Color schemes */ +{ARGB} { return T_COL_ARGB; } +{RGBA} { return T_COL_RGBA; } +{RGB} { return T_COL_RGB; } +{HSL} { return T_COL_HSL; } +{HWB} { return T_COL_HWB; } +{CMYK} { return T_COL_CMYK; } + /* Fluff */ +{PARENT_LEFT} { return PARENT_LEFT; } +{PARENT_RIGHT} { return PARENT_RIGHT;} +{COMMA} { return COMMA; } + /* Position */ +{CENTER} { return T_POS_CENTER; } +{EAST} { return T_POS_EAST; } +{WEST} { return T_POS_WEST; } +{SOUTH} { return T_POS_SOUTH; } +{NORTH} { return T_POS_NORTH; } + /* Highlight style */ +{NONE} { return T_NONE; } +{BOLD} { return T_BOLD; } +{ITALIC} { return T_ITALIC; } +{UNDERLINE} { return T_UNDERLINE; } + -{CENTER} { return T_POS_CENTER; } -{EAST} { return T_POS_EAST; } -{WEST} { return T_POS_WEST; } -{SOUTH} { return T_POS_SOUTH; } -{NORTH} { return T_POS_NORTH; } -{NONE} { return T_NONE; } -{BOLD} { return T_BOLD; } -{ITALIC} { return T_ITALIC; } -{UNDERLINE} { return T_UNDERLINE; } <> { ParseObject *po = g_queue_pop_head ( file_queue ); if ( po ) { diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index d82dc4a5..63999258 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -74,6 +74,40 @@ typedef struct YYLTYPE { ThemeWidget *rofi_theme = NULL; void yyerror(YYLTYPE *yylloc, const char *what, const char* s); int yylex (YYSTYPE *, YYLTYPE *); + +#define IN_RANGE(index,low,high) ( ( (index) > (low) )? ( ( (index) < (high) )? (index):(high) ) : ( low ) ) + +static double hue2rgb(double p, double q, double t){ + t += (t<0)?1:0; + t -= (t>1)?1:0; + if( t < (1/6.0) ) { + return p + (q - p) * 6 * t; + } + if( t < (1/2.0) ) { + return q; + } + if( t < (2/3.0) ) { + return p + (q - p) * (2/3.0 - t) * 6; + } + return p; +} +static ThemeColor hsl_to_rgb ( double h, double s, double l ) +{ + ThemeColor colour; + + if(s < 0.001 && s > -0.001){ + colour.red = colour.green = colour.blue = l; // achromatic + }else{ + + double q = l < 0.5 ? l * (1 + s) : l + s - l * s; + double p = 2 * l - q; + colour.red = hue2rgb(p, q, h + 1/3.0); + colour.green = hue2rgb(p, q, h); + colour.blue = hue2rgb(p, q, h - 1/3.0); + } + + return colour; +} %} %union { @@ -104,7 +138,6 @@ int yylex (YYSTYPE *, YYLTYPE *); %token NAME_ELEMENT "Element name" %token T_BOOLEAN %token T_COLOR -%token T_PIXEL %token T_LINK %token FIRST_NAME %token T_POS_CENTER "Center" @@ -117,7 +150,24 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_BOLD "Bold" %token T_ITALIC "Italic" %token T_UNDERLINE "Underline" +%token T_DASH "Dash" +%token T_SOLID "Solid" +%token T_UNIT_PX "pixels" +%token T_UNIT_EM "em" +%token T_UNIT_PERCENT "%" + +%token T_COL_ARGB +%token T_COL_RGBA +%token T_COL_RGB +%token T_COL_HSL +%token T_COL_HWB +%token T_COL_CMYK + +%token PARENT_LEFT "Parent left '('" +%token PARENT_RIGHT "Parent right ')'" +%token COMMA "comma separator" +%token PERCENT "Percent sign" %token BOPEN "bracket open ('{')" %token BCLOSE "bracket close ('}')" @@ -131,6 +181,8 @@ int yylex (YYSTYPE *, YYLTYPE *); %type highlight_styles %type highlight_style +%type t_line_style +%type t_unit %type t_position %type t_position_ew %type t_position_sn @@ -141,6 +193,8 @@ int yylex (YYSTYPE *, YYLTYPE *); %type property %type property_list %type optional_properties +%type t_distance +%type t_color %start entries %% @@ -216,11 +270,6 @@ property $$->name = $1; $$->value.f = $3; } -| pvalue PSEP T_COLOR PCLOSE { - $$ = rofi_theme_property_create ( P_COLOR ); - $$->name = $1; - $$->value.color = $3; - } | pvalue PSEP T_STRING PCLOSE { $$ = rofi_theme_property_create ( P_STRING ); $$->name = $1; @@ -236,22 +285,22 @@ property $$->name = $1; $$->value.b = $3; } -| pvalue PSEP T_PIXEL PCLOSE { +| pvalue PSEP t_distance PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $3, $3, $3 }; } -| pvalue PSEP T_PIXEL T_PIXEL PCLOSE { +| pvalue PSEP t_distance t_distance PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $3, $4 }; } -| pvalue PSEP T_PIXEL T_PIXEL T_PIXEL PCLOSE { +| pvalue PSEP t_distance t_distance t_distance PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $4 }; } -| pvalue PSEP T_PIXEL T_PIXEL T_PIXEL T_PIXEL PCLOSE { +| pvalue PSEP t_distance t_distance t_distance t_distance PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $6 }; @@ -261,7 +310,7 @@ property $$->name = $1; $$->value.i = $3; } -| pvalue PSEP highlight_styles T_COLOR PCLOSE { +| pvalue PSEP highlight_styles t_color PCLOSE { $$ = rofi_theme_property_create ( P_HIGHLIGHT ); $$->name = $1; $$->value.highlight.style = $3|HL_COLOR; @@ -272,6 +321,11 @@ property $$->name = $1; $$->value.highlight.style = $3; } +| pvalue PSEP t_color PCLOSE { + $$ = rofi_theme_property_create ( P_COLOR ); + $$->name = $1; + $$->value.color = $3; +} ; /** @@ -301,7 +355,7 @@ t_position_sn */ highlight_styles : highlight_style { $$ = $1;} -| highlight_styles highlight_style { $$ = $1|$2;} +| highlight_styles highlight_style { $$ = $1|$2;} ; /** Single style. */ highlight_style @@ -310,6 +364,87 @@ highlight_style | T_UNDERLINE { $$ = HL_UNDERLINE; } | T_ITALIC { $$ = HL_ITALIC; } ; + + +t_distance +: T_INT t_unit t_line_style { + $$.distance = (double)$1; + $$.type = $2; + $$.style = $3; +} +| T_DOUBLE t_unit t_line_style { + $$.distance = (double)$1; + $$.type = $2; + $$.style = $3; +}; + +t_unit +: T_UNIT_PX { $$ = PW_PX; } +| T_UNIT_EM { $$ = PW_EM; } +| PERCENT { $$ = PW_PERCENT; } +; +/****** + * Line style + * If not set, solid. + */ +t_line_style +: %empty { $$ = SOLID; } +| T_SOLID { $$ = SOLID; } +| T_DASH { $$ = DASH; } +; + +/** + * Color formats + */ +t_color +: T_COL_RGBA PARENT_LEFT T_INT COMMA T_INT COMMA T_INT COMMA T_DOUBLE PARENT_RIGHT { + $$.alpha = $9; + $$.red = $3/255.0; + $$.green = $5/255.0; + $$.blue = $7/255.0; +} +| T_COL_RGB PARENT_LEFT T_INT COMMA T_INT COMMA T_INT PARENT_RIGHT { + $$.alpha = 1.0; + $$.red = $3/255.0; + $$.green = $5/255.0; + $$.blue = $7/255.0; +} +| T_COL_HWB PARENT_LEFT T_INT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { + $$.alpha = 1.0; + double h = IN_RANGE($3,0,360)/360.0; + double w = IN_RANGE($5,0,100)/100.0; + double b = IN_RANGE($8,0,100)/100.0; + $$ = hsl_to_rgb ( h, 1.0, 0.5); + $$.red *= ( 1. - w - b ); + $$.red += w; + $$.green *= ( 1. - w - b ); + $$.green += w; + $$.blue *= ( 1. - w - b ); + $$.blue += w; +} +| T_COL_CMYK PARENT_LEFT T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { + $$.alpha = 1.0; + double c= IN_RANGE($3, 0, 100)/100.0; + double m= IN_RANGE($6, 0, 100)/100.0; + double y= IN_RANGE($9, 0, 100)/100.0; + double k= IN_RANGE($12, 0, 100)/100.0; + $$.red = (1.0-c)*(1.0-k); + $$.green = (1.0-m)*(1.0-k); + $$.blue = (1.0-y)*(1.0-k); +} +| T_COL_HSL PARENT_LEFT T_INT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { + gdouble h = IN_RANGE($3, 0, 359); + gdouble s = IN_RANGE($5, 0, 100); + gdouble l = IN_RANGE($8, 0, 100); + $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); + $$.alpha = 1.0; +} +| T_COLOR { + $$ = $1; +} +; + + pvalue: N_STRING { $$ = $1; } name_path: From aaea2b2c8a5eae79f387e7c6b6cbcb72ff91b4ee Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 10 May 2017 20:54:16 +0200 Subject: [PATCH 08/36] Add hsl and cmyk test, add extra error checking --- lexer/theme-lexer.l | 8 ++-- lexer/theme-parser.y | 90 +++++++++++++++++++++++++++++++++------- source/theme.c | 2 +- test/theme-parser-test.c | 78 +++++++++++++++++++++++++++++++++- 4 files changed, 155 insertions(+), 23 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 2365410d..9427bb03 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -179,8 +179,8 @@ HWB "hwb" CMYK "cmyk" HSL "hsl" -PARENT_LEFT \( -PARENT_RIGHT \) +S_PARENT_LEFT \( +S_PARENT_RIGHT \) COMMA , LS_DASH "dash" @@ -421,8 +421,8 @@ if ( queue == NULL ){ {HWB} { return T_COL_HWB; } {CMYK} { return T_COL_CMYK; } /* Fluff */ -{PARENT_LEFT} { return PARENT_LEFT; } -{PARENT_RIGHT} { return PARENT_RIGHT;} +{S_PARENT_LEFT} { return PARENT_LEFT; } +{S_PARENT_RIGHT} { return PARENT_RIGHT;} {COMMA} { return COMMA; } /* Position */ {CENTER} { return T_POS_CENTER; } diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 63999258..54d546e1 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -75,11 +75,22 @@ ThemeWidget *rofi_theme = NULL; void yyerror(YYLTYPE *yylloc, const char *what, const char* s); int yylex (YYSTYPE *, YYLTYPE *); -#define IN_RANGE(index,low,high) ( ( (index) > (low) )? ( ( (index) < (high) )? (index):(high) ) : ( low ) ) + +static int check_in_range ( double index, double low, double high, YYLTYPE *loc ) +{ + if ( index > high || index < low ){ + gchar *str = g_strdup_printf("Value out of range: \n\t\tValue: X = %.2lf;\n\t\tRange: %.2lf <= X <= %.2lf.", index, low, high ); + yyerror ( loc, loc->filename, str); + g_free(str); + return FALSE; + } + + return TRUE; +} static double hue2rgb(double p, double q, double t){ - t += (t<0)?1:0; - t -= (t>1)?1:0; + t += (t<0)?1.0:0.0; + t -= (t>1)?1.0:0.0; if( t < (1/6.0) ) { return p + (q - p) * 6 * t; } @@ -183,6 +194,7 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) %type highlight_style %type t_line_style %type t_unit +%type color_val %type t_position %type t_position_ew %type t_position_sn @@ -398,22 +410,42 @@ t_line_style */ t_color : T_COL_RGBA PARENT_LEFT T_INT COMMA T_INT COMMA T_INT COMMA T_DOUBLE 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; } + if ( ! check_in_range($9,0,1.00, &(@$)) ) { YYABORT; } $$.alpha = $9; $$.red = $3/255.0; $$.green = $5/255.0; $$.blue = $7/255.0; } +| T_COL_RGBA PARENT_LEFT T_INT COMMA T_INT COMMA T_INT COMMA color_val PERCENT 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; } + if ( ! check_in_range($9,0,100, &(@$)) ) { YYABORT; } + $$.alpha = $9/100.0; + $$.red = $3/255.0; + $$.green = $5/255.0; + $$.blue = $7/255.0; +} | T_COL_RGB PARENT_LEFT T_INT COMMA T_INT COMMA T_INT 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; } -| T_COL_HWB PARENT_LEFT T_INT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { +| T_COL_HWB PARENT_LEFT T_INT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { $$.alpha = 1.0; - double h = IN_RANGE($3,0,360)/360.0; - double w = IN_RANGE($5,0,100)/100.0; - double b = IN_RANGE($8,0,100)/100.0; + if ( ! check_in_range($3,0,360, &(@$)) ) { YYABORT; } + if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($8,0,100, &(@$)) ) { YYABORT; } + double h = $3/360.0; + double w = $5/100.0; + double b = $8/100.0; $$ = hsl_to_rgb ( h, 1.0, 0.5); $$.red *= ( 1. - w - b ); $$.red += w; @@ -422,20 +454,41 @@ t_color $$.blue *= ( 1. - w - b ); $$.blue += w; } -| T_COL_CMYK PARENT_LEFT T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { +| T_COL_CMYK PARENT_LEFT color_val PERCENT COMMA color_val PERCENT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { $$.alpha = 1.0; - double c= IN_RANGE($3, 0, 100)/100.0; - double m= IN_RANGE($6, 0, 100)/100.0; - double y= IN_RANGE($9, 0, 100)/100.0; - double k= IN_RANGE($12, 0, 100)/100.0; + if ( ! check_in_range($3, 0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($6, 0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($9, 0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($12,0,100, &(@$)) ) { YYABORT; } + double c= $3/100.0; + double m= $6/100.0; + double y= $9/100.0; + double k= $12/100.0; $$.red = (1.0-c)*(1.0-k); $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } -| T_COL_HSL PARENT_LEFT T_INT COMMA T_DOUBLE PERCENT COMMA T_DOUBLE PERCENT PARENT_RIGHT { - gdouble h = IN_RANGE($3, 0, 359); - gdouble s = IN_RANGE($5, 0, 100); - gdouble l = IN_RANGE($8, 0, 100); +| T_COL_CMYK PARENT_LEFT color_val COMMA color_val COMMA color_val COMMA color_val PARENT_RIGHT { + $$.alpha = 1.0; + if ( ! check_in_range($3, 0,1.00, &(@$)) ) { YYABORT; } + if ( ! check_in_range($5, 0,1.00, &(@$)) ) { YYABORT; } + if ( ! check_in_range($7, 0,1.00, &(@$)) ) { YYABORT; } + if ( ! check_in_range($9, 0,1.00, &(@$)) ) { YYABORT; } + double c= $3; + double m= $5; + double y= $7; + double k= $9; + $$.red = (1.0-c)*(1.0-k); + $$.green = (1.0-m)*(1.0-k); + $$.blue = (1.0-y)*(1.0-k); +} +| T_COL_HSL PARENT_LEFT T_INT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { + if ( ! check_in_range($3, 0,360, &(@$)) ) { YYABORT; } + if ( ! check_in_range($5, 0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($8, 0,100, &(@$)) ) { YYABORT; } + gdouble h = $3; + gdouble s = $5; + gdouble l = $8; $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); $$.alpha = 1.0; } @@ -444,6 +497,11 @@ t_color } ; +color_val +: T_DOUBLE { $$ = $1; } +| T_INT { $$ = $1; } +; + pvalue: N_STRING { $$ = $1; } diff --git a/source/theme.c b/source/theme.c index 2cf1683b..1902970e 100644 --- a/source/theme.c +++ b/source/theme.c @@ -317,7 +317,7 @@ extern FILE* yyin; */ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s ) { - char *what_esc = g_markup_escape_text ( what, -1 ); + char *what_esc = what?g_markup_escape_text ( what, -1 ):g_strdup(""); GString *str = g_string_new ( "" ); g_string_printf ( str, "Error while parsing theme: %s\n", what_esc ); g_free ( what_esc ); diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index d9eda720..f1f63860 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -86,7 +86,7 @@ gboolean error = FALSE; GString *error_msg = NULL; void rofi_add_error_message ( GString *msg ) { - ck_assert_ptr_null ( error_msg ); + ck_assert_ptr_null ( error_msg ); error_msg = msg; error = TRUE; } @@ -534,6 +534,33 @@ START_TEST ( test_properties_color_rgba ) ck_assert_double_eq ( p->value.color.blue , 1 ); } END_TEST +START_TEST ( test_properties_color_rgba_percent ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { red: rgba(255,0,0,30%); green: rgba(0,255,0,20%); blue: rgba(0,0,255,70.0%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq ( p->value.color.red , 1 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "green", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.2 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 1 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "blue", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.7 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 1 ); +} +END_TEST START_TEST ( test_properties_color_argb ) { widget wid; @@ -561,6 +588,50 @@ START_TEST ( test_properties_color_argb ) ck_assert_double_eq ( p->value.color.blue , 1 ); } END_TEST +START_TEST ( test_properties_color_hsl ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hsl(127,40%,66.66666%); test2: hsl(0, 100%, 50%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 0x88/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); +} +END_TEST +START_TEST ( test_properties_color_cmyk ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: cmyk ( 41%, 0%, 100%, 0%); test2: cmyk ( 0, 1.0, 1.0, 0);}"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 0x96/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 1.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); +} +END_TEST START_TEST ( test_properties_padding_2 ) { widget wid; @@ -752,7 +823,10 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_h8); tcase_add_test ( tc_prop_color, test_properties_color_rgb); tcase_add_test ( tc_prop_color, test_properties_color_rgba); + tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent); tcase_add_test ( tc_prop_color, test_properties_color_argb); + tcase_add_test ( tc_prop_color, test_properties_color_hsl); + tcase_add_test ( tc_prop_color, test_properties_color_cmyk); suite_add_tcase(s, tc_prop_color ); } { @@ -813,7 +887,7 @@ int main ( int argc, char ** argv ) return EXIT_FAILURE; } - + Suite *s; SRunner *sr; From ed11c3265d1a581cf15d63b86548991dade03a88 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 11 May 2017 18:23:36 +0200 Subject: [PATCH 09/36] Cleanup parser (document some rules) --- lexer/theme-lexer.l | 36 +++--- lexer/theme-parser.y | 248 ++++++++++++++++++++------------------- test/theme-parser-test.c | 15 +++ 3 files changed, 161 insertions(+), 138 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 9427bb03..f6921027 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -172,15 +172,14 @@ UNDERLINE "underline" ITALIC "italic" /* Color schema */ -ARGB "argb" RGBA "rgba" RGB "rgb" HWB "hwb" CMYK "cmyk" HSL "hsl" -S_PARENT_LEFT \( -S_PARENT_RIGHT \) +S_T_PARENT_LEFT \( +S_T_PARENT_RIGHT \) COMMA , LS_DASH "dash" @@ -314,50 +313,50 @@ if ( queue == NULL ){ {CONFIGURATION} { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(DEFAULTS); - return CONFIGURATION; + return T_CONFIGURATION; } {ASTERIX} { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(DEFAULTS); - return PDEFAULTS; + return T_PDEFAULTS; } /** Skip all whitespace */ {WHITESPACE} {} "\{" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(SECTION); - return BOPEN; + return T_BOPEN; } /** Everythin not yet parsed is an error. */ . { return T_ERROR_DEFAULTS; } -"#" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return NAME_PREFIX;} +"#" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return T_NAME_PREFIX;} /* Go into parsing an section*/ "\{" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(SECTION); - return BOPEN; + return T_BOPEN; } /* Pop out of parsing an section. */
"\}" { g_queue_pop_head ( queue ); BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue ))); - return BCLOSE; + return T_BCLOSE; } -\.|{WHITESPACE} { return NSEP; } -
{WORD} { yylval->sval = g_strdup(yytext); return N_STRING;} -{WORD} { yylval->sval = g_strdup(yytext); return NAME_ELEMENT;} +\.|{WHITESPACE} { return T_NSEP; } +
{WORD} { yylval->sval = g_strdup(yytext); return T_PROP_NAME;} +{WORD} { yylval->sval = g_strdup(yytext); return T_NAME_ELEMENT;} /* After Namestr/Classstr we want to go to state str, then to { */ {WHITESPACE}+ ; // ignore all whitespace {WHITESPACE}+ ; // ignore all whitespace -
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return PSEP; } -";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return PCLOSE;} +
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; } +";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;} (true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} {PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} {PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} @@ -369,7 +368,7 @@ if ( queue == NULL ){ {EM} { return T_UNIT_EM; } {PX} { return T_UNIT_PX; } -{PERCENT} { return PERCENT; } +{PERCENT} { return T_PERCENT; } {LS_SOLID} { return T_SOLID; } {LS_DASH} { return T_DASH; } @@ -414,16 +413,15 @@ if ( queue == NULL ){ return T_COLOR; } /* Color schemes */ -{ARGB} { return T_COL_ARGB; } {RGBA} { return T_COL_RGBA; } {RGB} { return T_COL_RGB; } {HSL} { return T_COL_HSL; } {HWB} { return T_COL_HWB; } {CMYK} { return T_COL_CMYK; } /* Fluff */ -{S_PARENT_LEFT} { return PARENT_LEFT; } -{S_PARENT_RIGHT} { return PARENT_RIGHT;} -{COMMA} { return COMMA; } +{S_T_PARENT_LEFT} { return T_PARENT_LEFT; } +{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT;} +{COMMA} { return T_COMMA; } /* Position */ {CENTER} { return T_POS_CENTER; } {EAST} { return T_POS_EAST; } diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 54d546e1..0d3fc99b 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -142,76 +142,74 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) %token T_ERROR_NAMESTRING 4 "invalid element name" %token T_ERROR_DEFAULTS 5 "invalid defaults name" %token T_ERROR_INCLUDE 6 "invalid import value" -%token T_INT -%token T_DOUBLE -%token T_STRING -%token N_STRING "property name" -%token NAME_ELEMENT "Element name" -%token T_BOOLEAN -%token T_COLOR -%token T_LINK -%token FIRST_NAME -%token T_POS_CENTER "Center" -%token T_POS_EAST "East" -%token T_POS_WEST "West" -%token T_POS_NORTH "North" -%token T_POS_SOUTH "South" +%token T_INT "Integer number" +%token T_DOUBLE "Floating-point number" +%token T_STRING "UTF-8 encoded string" +%token T_PROP_NAME "property name" +%token T_NAME_ELEMENT "Element name" +%token T_BOOLEAN "Boolean value (true or false)" +%token T_COLOR "Hexidecimal color value" +%token T_LINK "Reference" +%token T_POS_CENTER "Center" +%token T_POS_EAST "East" +%token T_POS_WEST "West" +%token T_POS_NORTH "North" +%token T_POS_SOUTH "South" -%token T_NONE "None" -%token T_BOLD "Bold" -%token T_ITALIC "Italic" -%token T_UNDERLINE "Underline" -%token T_DASH "Dash" -%token T_SOLID "Solid" +%token T_NONE "None" +%token T_BOLD "Bold" +%token T_ITALIC "Italic" +%token T_UNDERLINE "Underline" +%token T_DASH "Dash" +%token T_SOLID "Solid" -%token T_UNIT_PX "pixels" -%token T_UNIT_EM "em" -%token T_UNIT_PERCENT "%" +%token T_UNIT_PX "pixels" +%token T_UNIT_EM "em" +%token T_UNIT_PERCENT "%" -%token T_COL_ARGB -%token T_COL_RGBA -%token T_COL_RGB -%token T_COL_HSL -%token T_COL_HWB -%token T_COL_CMYK +%token T_COL_RGBA "rgba colorscheme" +%token T_COL_RGB "rgb colorscheme" +%token T_COL_HSL "hsl colorscheme" +%token T_COL_HWB "hwb colorscheme" +%token T_COL_CMYK "cmyk colorscheme" -%token PARENT_LEFT "Parent left '('" -%token PARENT_RIGHT "Parent right ')'" -%token COMMA "comma separator" -%token PERCENT "Percent sign" +%token T_PARENT_LEFT "Parent left ('(')" +%token T_PARENT_RIGHT "Parent right (')')" +%token T_COMMA "comma separator (',')" +%token T_PERCENT "Percent sign ('%')" -%token BOPEN "bracket open ('{')" -%token BCLOSE "bracket close ('}')" -%token PSEP "property separator (':')" -%token PCLOSE "property close (';')" -%token NSEP "Name separator (' ' or '.')" -%token NAME_PREFIX "Element section ('# {name} { ... }')" -%token WHITESPACE "White space" -%token PDEFAULTS "Default settings section ( '* { ... }')" -%token CONFIGURATION "Configuration block" +%token T_BOPEN "bracket open ('{')" +%token T_BCLOSE "bracket close ('}')" +%token T_PSEP "property separator (':')" +%token T_PCLOSE "property close (';')" +%token T_NSEP "Name separator (' ' or '.')" +%token T_NAME_PREFIX "Element section ('# {name} { ... }')" +%token T_WHITESPACE "White space" +%token T_PDEFAULTS "Default settings section ( '* { ... }')" +%token T_CONFIGURATION "Configuration block" -%type highlight_styles -%type highlight_style -%type t_line_style -%type t_unit -%type color_val -%type t_position -%type t_position_ew -%type t_position_sn -%type entry -%type pvalue -%type entries -%type name_path -%type property -%type property_list -%type optional_properties -%type t_distance -%type t_color -%start entries +%type t_entry +%type t_entry_list +%type t_entry_name_path +%type t_property +%type t_property_list +%type t_property_list_optional +%type t_property_color +%type t_property_color_value +%type t_property_name +%type t_property_distance +%type t_property_unit +%type t_property_position +%type t_property_position_ew +%type t_property_position_sn +%type t_property_highlight_styles +%type t_property_highlight_style +%type t_property_line_style +%start t_entry_list %% -entries: +t_entry_list: %empty { // There is always a base widget. if (rofi_theme == NULL ){ @@ -219,13 +217,13 @@ entries: rofi_theme->name = g_strdup ( "Root" ); } } -| entries - entry { +| t_entry_list + t_entry { } ; -entry: -NAME_PREFIX name_path BOPEN optional_properties BCLOSE +t_entry: +T_NAME_PREFIX t_entry_name_path T_BOPEN t_property_list_optional T_BCLOSE { ThemeWidget *widget = rofi_theme; for ( GList *iter = g_list_first ( $2 ); iter ; iter = g_list_next ( iter ) ) { @@ -237,10 +235,10 @@ NAME_PREFIX name_path BOPEN optional_properties BCLOSE rofi_theme_widget_add_properties ( widget, $4); } | - PDEFAULTS BOPEN optional_properties BCLOSE { + T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE { rofi_theme_widget_add_properties ( rofi_theme, $3); } -| CONFIGURATION BOPEN optional_properties BCLOSE { +| T_CONFIGURATION T_BOPEN t_property_list_optional T_BCLOSE { GHashTableIter iter; g_hash_table_iter_init ( &iter, $3 ); gpointer key,value; @@ -255,85 +253,85 @@ NAME_PREFIX name_path BOPEN optional_properties BCLOSE /** * properties */ -optional_properties +t_property_list_optional : %empty { $$ = NULL; } - | property_list { $$ = $1; } + | t_property_list { $$ = $1; } ; -property_list: - property { +t_property_list: + t_property { $$ = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify)rofi_theme_property_free ); g_hash_table_replace ( $$, $1->name, $1 ); } -| property_list property { +| t_property_list t_property { // Old will be free'ed, and key/value will be replaced. g_hash_table_replace ( $$, $2->name, $2 ); } ; -property -: pvalue PSEP T_INT PCLOSE { +t_property +: t_property_name T_PSEP T_INT T_PCLOSE { $$ = rofi_theme_property_create ( P_INTEGER ); $$->name = $1; $$->value.i = $3; } -| pvalue PSEP T_DOUBLE PCLOSE { +| t_property_name T_PSEP T_DOUBLE T_PCLOSE { $$ = rofi_theme_property_create ( P_DOUBLE ); $$->name = $1; $$->value.f = $3; } -| pvalue PSEP T_STRING PCLOSE { +| t_property_name T_PSEP T_STRING T_PCLOSE { $$ = rofi_theme_property_create ( P_STRING ); $$->name = $1; $$->value.s = $3; } -| pvalue PSEP T_LINK PCLOSE { +| t_property_name T_PSEP T_LINK T_PCLOSE { $$ = rofi_theme_property_create ( P_LINK ); $$->name = $1; $$->value.link.name = $3; } -| pvalue PSEP T_BOOLEAN PCLOSE { +| t_property_name T_PSEP T_BOOLEAN T_PCLOSE { $$ = rofi_theme_property_create ( P_BOOLEAN ); $$->name = $1; $$->value.b = $3; } -| pvalue PSEP t_distance PCLOSE { +| t_property_name T_PSEP t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $3, $3, $3 }; } -| pvalue PSEP t_distance t_distance PCLOSE { +| t_property_name T_PSEP t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $3, $4 }; } -| pvalue PSEP t_distance t_distance t_distance PCLOSE { +| t_property_name T_PSEP t_property_distance t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $4 }; } -| pvalue PSEP t_distance t_distance t_distance t_distance PCLOSE { +| t_property_name T_PSEP t_property_distance t_property_distance t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $6 }; } -| pvalue PSEP t_position PCLOSE{ +| t_property_name T_PSEP t_property_position T_PCLOSE{ $$ = rofi_theme_property_create ( P_POSITION ); $$->name = $1; $$->value.i = $3; } -| pvalue PSEP highlight_styles t_color PCLOSE { +| t_property_name T_PSEP t_property_highlight_styles t_property_color T_PCLOSE { $$ = rofi_theme_property_create ( P_HIGHLIGHT ); $$->name = $1; $$->value.highlight.style = $3|HL_COLOR; $$->value.highlight.color = $4; } -| pvalue PSEP highlight_styles PCLOSE { +| t_property_name T_PSEP t_property_highlight_styles T_PCLOSE { $$ = rofi_theme_property_create ( P_HIGHLIGHT ); $$->name = $1; $$->value.highlight.style = $3; } -| pvalue PSEP t_color PCLOSE { +| t_property_name T_PSEP t_property_color T_PCLOSE { $$ = rofi_theme_property_create ( P_COLOR ); $$->name = $1; $$->value.color = $3; @@ -345,18 +343,18 @@ property * East or West, North Or South * Or combi of East or West and North or South */ -t_position +t_property_position : T_POS_CENTER { $$ =WL_CENTER;} -| t_position_ew -| t_position_sn -| t_position_ew t_position_sn { $$ = $1|$2;} -| t_position_sn t_position_ew { $$ = $1|$2;} +| t_property_position_ew +| t_property_position_sn +| t_property_position_ew t_property_position_sn { $$ = $1|$2;} +| t_property_position_sn t_property_position_ew { $$ = $1|$2;} ; -t_position_ew +t_property_position_ew : T_POS_EAST { $$ = WL_EAST;} | T_POS_WEST { $$ = WL_WEST;} ; -t_position_sn +t_property_position_sn : T_POS_NORTH { $$ = WL_NORTH;} | T_POS_SOUTH { $$ = WL_SOUTH;} ; @@ -365,41 +363,44 @@ t_position_sn * Highlight style, allow mulitple styles to be combined. * Empty not allowed */ -highlight_styles -: highlight_style { $$ = $1;} -| highlight_styles highlight_style { $$ = $1|$2;} +t_property_highlight_styles +: t_property_highlight_style { $$ = $1;} +| t_property_highlight_styles t_property_highlight_style { $$ = $1|$2;} ; /** Single style. */ -highlight_style +t_property_highlight_style : T_NONE { $$ = HL_NONE; } | T_BOLD { $$ = HL_BOLD; } | T_UNDERLINE { $$ = HL_UNDERLINE; } | T_ITALIC { $$ = HL_ITALIC; } ; - -t_distance -: T_INT t_unit t_line_style { +/** Distance. */ +t_property_distance +/** Interger unit and line style */ +: T_INT t_property_unit t_property_line_style { $$.distance = (double)$1; $$.type = $2; $$.style = $3; } -| T_DOUBLE t_unit t_line_style { +/** Double unit and line style */ +| T_DOUBLE t_property_unit t_property_line_style { $$.distance = (double)$1; $$.type = $2; $$.style = $3; }; -t_unit +/** distance unit. px, em, % */ +t_property_unit : T_UNIT_PX { $$ = PW_PX; } | T_UNIT_EM { $$ = PW_EM; } -| PERCENT { $$ = PW_PERCENT; } +| T_PERCENT { $$ = PW_PERCENT; } ; /****** * Line style * If not set, solid. */ -t_line_style +t_property_line_style : %empty { $$ = SOLID; } | T_SOLID { $$ = SOLID; } | T_DASH { $$ = DASH; } @@ -408,8 +409,9 @@ t_line_style /** * Color formats */ -t_color -: T_COL_RGBA PARENT_LEFT T_INT COMMA T_INT COMMA T_INT COMMA T_DOUBLE PARENT_RIGHT { +t_property_color + /** 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_DOUBLE 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; } @@ -419,7 +421,8 @@ t_color $$.green = $5/255.0; $$.blue = $7/255.0; } -| T_COL_RGBA PARENT_LEFT T_INT COMMA T_INT COMMA T_INT COMMA color_val PERCENT PARENT_RIGHT { + /** rgba ( 0-255 , 0-255, 0-255, 0-100% ) */ +| T_COL_RGBA T_PARENT_LEFT T_INT T_COMMA T_INT T_COMMA T_INT T_COMMA t_property_color_value T_PERCENT 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; } @@ -429,7 +432,8 @@ t_color $$.green = $5/255.0; $$.blue = $7/255.0; } -| T_COL_RGB PARENT_LEFT T_INT COMMA T_INT COMMA T_INT PARENT_RIGHT { + /** 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; } @@ -438,7 +442,8 @@ t_color $$.green = $5/255.0; $$.blue = $7/255.0; } -| T_COL_HWB PARENT_LEFT T_INT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { + /** hwb ( 0-360 , 0-100 %, 0 - 100 %) */ +| T_COL_HWB T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { $$.alpha = 1.0; if ( ! check_in_range($3,0,360, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } @@ -454,7 +459,8 @@ t_color $$.blue *= ( 1. - w - b ); $$.blue += w; } -| T_COL_CMYK PARENT_LEFT color_val PERCENT COMMA color_val PERCENT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { + /** cmyk ( 0-100%, 0-100%, 0-100%, 0-100%) */ +| T_COL_CMYK T_PARENT_LEFT t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { $$.alpha = 1.0; if ( ! check_in_range($3, 0,100, &(@$)) ) { YYABORT; } if ( ! check_in_range($6, 0,100, &(@$)) ) { YYABORT; } @@ -468,7 +474,8 @@ t_color $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } -| T_COL_CMYK PARENT_LEFT color_val COMMA color_val COMMA color_val COMMA color_val PARENT_RIGHT { + /** cmyk ( 0-1.0, 0-1.0, 0-1.0, 0-1.0) */ +| T_COL_CMYK T_PARENT_LEFT t_property_color_value T_COMMA t_property_color_value T_COMMA t_property_color_value T_COMMA t_property_color_value T_PARENT_RIGHT { $$.alpha = 1.0; if ( ! check_in_range($3, 0,1.00, &(@$)) ) { YYABORT; } if ( ! check_in_range($5, 0,1.00, &(@$)) ) { YYABORT; } @@ -482,7 +489,8 @@ t_color $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } -| T_COL_HSL PARENT_LEFT T_INT COMMA color_val PERCENT COMMA color_val PERCENT PARENT_RIGHT { + /** hsl ( 0-360 , 0-100 %, 0 - 100 %) */ +| T_COL_HSL T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { if ( ! check_in_range($3, 0,360, &(@$)) ) { YYABORT; } if ( ! check_in_range($5, 0,100, &(@$)) ) { YYABORT; } if ( ! check_in_range($8, 0,100, &(@$)) ) { YYABORT; } @@ -492,23 +500,25 @@ t_color $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); $$.alpha = 1.0; } +/** Hex colors parsed by lexer. */ | T_COLOR { $$ = $1; } ; -color_val +/** Color value to be double or integer. */ +t_property_color_value : T_DOUBLE { $$ = $1; } | T_INT { $$ = $1; } ; +/** Property name */ +t_property_name: T_PROP_NAME { $$ = $1; } -pvalue: N_STRING { $$ = $1; } - -name_path: -NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );} -| name_path NSEP NAME_ELEMENT { $$ = g_list_append ( $1, $3);} -| name_path NSEP { $$ = $1; } +t_entry_name_path: +T_NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );} +| t_entry_name_path T_NSEP T_NAME_ELEMENT { $$ = g_list_append ( $1, $3);} +| t_entry_name_path T_NSEP { $$ = $1; } ; %% diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index f1f63860..e7ba6711 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -764,6 +764,20 @@ START_TEST ( test_import_empty) } END_TEST +START_TEST ( test_core_properties_error ) +{ + rofi_theme_parse_string ( " * { test: cmky(a,e,3); }"); + const char *errstr = "Error while parsing theme: * { test: cmky(a,e,3); }\n"\ + " Parser error: syntax error, unexpected invalid property value\n"\ + " Location: line 1 column 11 to line 1 column 13\n"; + ck_assert_int_eq ( error, 1); + ck_assert_str_eq ( error_msg->str, errstr ); + g_string_free ( error_msg, TRUE); + error_msg = NULL; + error = 0; +} +END_TEST + static Suite * theme_parser_suite (void) { Suite *s; @@ -781,6 +795,7 @@ static Suite * theme_parser_suite (void) tcase_add_test(tc_core, test_core_error_root ); tcase_add_test(tc_core, test_core_comments ); tcase_add_test(tc_core, test_core_newline ); + tcase_add_test(tc_core, test_core_properties_error ); suite_add_tcase(s, tc_core); } { From 76244fedc0b9726626a03ca6528ab3e3e1d49fe4 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 11 May 2017 18:25:38 +0200 Subject: [PATCH 10/36] Make property name rule consistent. --- lexer/theme-parser.y | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 0d3fc99b..41ed3e87 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -513,7 +513,9 @@ t_property_color_value ; /** Property name */ -t_property_name: T_PROP_NAME { $$ = $1; } +t_property_name +: T_PROP_NAME { $$ = $1; } +; t_entry_name_path: T_NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );} From 67e38cde406103df7689441335cd03cc4a68e695 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 11 May 2017 18:30:44 +0200 Subject: [PATCH 11/36] Fix some clang compiler warnings --- source/dialogs/ssh.c | 2 +- source/theme.c | 8 ++++---- source/widgets/textbox.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index a639646c..36392da4 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -298,7 +298,7 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned else { full_path = g_strdup ( path ); } - glob_t globbuf = { 0, }; + glob_t globbuf = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 }; if ( glob ( full_path, 0, NULL, &globbuf ) == 0 ) { for ( size_t iter = 0; iter < globbuf.gl_pathc; iter++ ) { diff --git a/source/theme.c b/source/theme.c index 1902970e..e31d0027 100644 --- a/source/theme.c +++ b/source/theme.c @@ -639,7 +639,7 @@ void rofi_theme_convert_old ( void ) { if ( config.color_window ) { char **retv = g_strsplit ( config.color_window, ",", -1 ); - const char const *conf[] = { + const char * const conf[] = { "* { background: %s; }", "* { bordercolor: %s; }", "* { separatorcolor: %s; }" @@ -653,7 +653,7 @@ void rofi_theme_convert_old ( void ) } if ( config.color_normal ) { char **retv = g_strsplit ( config.color_normal, ",", -1 ); - const char const *conf[] = { + const char * const conf[] = { "* { normal-background: %s; }", "* { foreground: %s; normal-foreground: @foreground; alternate-normal-foreground: @foreground; }", "* { alternate-normal-background: %s; }", @@ -669,7 +669,7 @@ void rofi_theme_convert_old ( void ) } if ( config.color_urgent ) { char **retv = g_strsplit ( config.color_urgent, ",", -1 ); - const char const *conf[] = { + const char * const conf[] = { "* { urgent-background: %s; }", "* { urgent-foreground: %s; alternate-urgent-foreground: @urgent-foreground;}", "* { alternate-urgent-background: %s; }", @@ -685,7 +685,7 @@ void rofi_theme_convert_old ( void ) } if ( config.color_active ) { char **retv = g_strsplit ( config.color_active, ",", -1 ); - const char const *conf[] = { + const char * const conf[] = { "* { active-background: %s; }", "* { active-foreground: %s; alternate-active-foreground: @active-foreground;}", "* { alternate-active-background: %s; }", diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 16e1ed69..e3f3b9be 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -173,7 +173,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType /** * State names used for theming. */ -const char const *const theme_prop_names[][3] = { +const char *const theme_prop_names[][3] = { /** Normal row */ { "normal.normal", "selected.normal", "alternate.normal" }, /** Urgent row */ From fd56e07159835f691a5b010ae5ed99268291c33b Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 12 May 2017 16:08:14 +0200 Subject: [PATCH 12/36] Remove hardcoded #columns from default theme. --- include/default-theme.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/default-theme.h b/include/default-theme.h index 8ae52a6c..516459e1 100644 --- a/include/default-theme.h +++ b/include/default-theme.h @@ -83,7 +83,6 @@ const char *default_theme = "#window.mainbox.listview {" " fixed-height: 0;" " border: 1px dash 0px 0px ;" - " columns: 1;" " padding: 2px 0px 0px ;" "}" "#window.mainbox.listview.element {" From c54a817555ed8ac2a2f02805451e7667cbd42d76 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 12 May 2017 16:08:49 +0200 Subject: [PATCH 13/36] If we hit edge of entry box, make left/right move forward to listview. --- source/view.c | 12 ++++++++++++ source/widgets/textbox.c | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/view.c b/source/view.c index 771627da..9c74a0cc 100644 --- a/source/view.c +++ b/source/view.c @@ -1297,7 +1297,19 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio break; // If you add a binding here, make sure to add it to textbox_keybinding too case MOVE_CHAR_BACK: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_left ( state->list_view ); + } + break; + } case MOVE_CHAR_FORWARD: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_right ( state->list_view ); + } + break; + } case CLEAR_LINE: case MOVE_FRONT: case MOVE_END: diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index e3f3b9be..32f38330 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -405,20 +405,28 @@ void textbox_cursor ( textbox *tb, int pos ) * @param tb Handle to the textbox * * Move cursor one position forward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_inc ( textbox *tb ) +static int textbox_cursor_inc ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor + 1 ); + return ( old != tb->cursor ); } /** * @param tb Handle to the textbox * * Move cursor one position backward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_dec ( textbox *tb ) +static int textbox_cursor_dec ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor - 1 ); + return ( old != tb->cursor ); } // Move word right @@ -625,12 +633,10 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) { // Left or Ctrl-b case MOVE_CHAR_BACK: - textbox_cursor_dec ( tb ); - return 2; + return (textbox_cursor_dec ( tb ) == TRUE)?2:0; // Right or Ctrl-F case MOVE_CHAR_FORWARD: - textbox_cursor_inc ( tb ); - return 2; + return (textbox_cursor_inc ( tb ) == TRUE)?2:0; // Ctrl-U: Kill from the beginning to the end of the line. case CLEAR_LINE: textbox_text ( tb, "" ); From 94ee637102c6d5c6d40edc1e25a70fbfbc3369c3 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 13 May 2017 22:51:10 +0200 Subject: [PATCH 14/36] [Parser] Fix HWB parser alpha channel and add test. --- lexer/theme-parser.y | 2 +- test/theme-parser-test.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 41ed3e87..bf0019e0 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -444,7 +444,6 @@ t_property_color } /** hwb ( 0-360 , 0-100 %, 0 - 100 %) */ | T_COL_HWB T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { - $$.alpha = 1.0; if ( ! check_in_range($3,0,360, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } if ( ! check_in_range($8,0,100, &(@$)) ) { YYABORT; } @@ -452,6 +451,7 @@ t_property_color double w = $5/100.0; double b = $8/100.0; $$ = hsl_to_rgb ( h, 1.0, 0.5); + $$.alpha = 1.0; $$.red *= ( 1. - w - b ); $$.red += w; $$.green *= ( 1. - w - b ); diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index e7ba6711..9e57b175 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -610,6 +610,28 @@ START_TEST ( test_properties_color_hsl ) ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); } END_TEST +START_TEST ( test_properties_color_hwb ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 166/255.0, 0.004); + ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); +} +END_TEST START_TEST ( test_properties_color_cmyk ) { widget wid; @@ -841,6 +863,7 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent); tcase_add_test ( tc_prop_color, test_properties_color_argb); tcase_add_test ( tc_prop_color, test_properties_color_hsl); + tcase_add_test ( tc_prop_color, test_properties_color_hwb); tcase_add_test ( tc_prop_color, test_properties_color_cmyk); suite_add_tcase(s, tc_prop_color ); } From 47c6c8435ae9e6b5b88268f24ee2ae2a57a6eece Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 17:21:34 +0200 Subject: [PATCH 15/36] Add a small test for error message failing to open file. --- test/theme-parser-test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 9e57b175..55a692a1 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -800,6 +800,22 @@ START_TEST ( test_core_properties_error ) } END_TEST +START_TEST ( test_import_error ) +{ + + rofi_theme_parse_string("@import \"non-existing-file.rasi\""); + + const char *errstr = + "Failed to open theme: /home/qball/Programming/GitHub/rofi/build/non-existing-file.rasi\n"\ + "Error: No such file or directory"; + ck_assert_int_eq ( error, 1); + ck_assert_str_eq ( error_msg->str, errstr ); + g_string_free ( error_msg, TRUE); + error_msg = NULL; + error = 0; +} +END_TEST + static Suite * theme_parser_suite (void) { Suite *s; @@ -911,6 +927,7 @@ static Suite * theme_parser_suite (void) TCase *tc_prop_import = tcase_create("Import"); tcase_add_checked_fixture(tc_prop_import, theme_parser_setup, theme_parser_teardown); tcase_add_test ( tc_prop_import, test_import_empty); + tcase_add_test ( tc_prop_import, test_import_error); suite_add_tcase(s, tc_prop_import ); } return s; From f5ba9359a99ae85fc2fb83d7e8feeb908bc9b73d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 17:36:27 +0200 Subject: [PATCH 16/36] See output of test failing only in travis. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 71fcb52b..13ad9b0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,6 +78,7 @@ before_script: script: - make - make check + - ./theme_parser_test - ulimit -c unlimited - make test-x - if [ -f core ]; then echo "bt" | gdb ./rofi core; fi From 4e7aa06333341e5f0c76c909355ff00614c1ae0f Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 17:42:05 +0200 Subject: [PATCH 17/36] Update test to have no user path. --- test/theme-parser-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 55a692a1..68eba616 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -803,10 +803,10 @@ END_TEST START_TEST ( test_import_error ) { - rofi_theme_parse_string("@import \"non-existing-file.rasi\""); + rofi_theme_parse_string("@import \"/non-existing-file.rasi\""); const char *errstr = - "Failed to open theme: /home/qball/Programming/GitHub/rofi/build/non-existing-file.rasi\n"\ + "Failed to open theme: /non-existing-file.rasi\n"\ "Error: No such file or directory"; ck_assert_int_eq ( error, 1); ck_assert_str_eq ( error_msg->str, errstr ); From e4c935c764d1e1d1425c6615d4258a6e9f2a584d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 18:22:27 +0200 Subject: [PATCH 18/36] Add a old theme conversion test and default theme dump test. --- Makefile.am | 8 +- doc/default_theme.rasi | 111 +++++++++++++++++++++ doc/old-theme-convert-input.theme | 154 ++++++++++++++++++++++++++++++ doc/old-theme-convert-output.rasi | 111 +++++++++++++++++++++ test/convert_old_theme_test.sh | 14 +++ test/default_theme_test.sh | 14 +++ 6 files changed, 410 insertions(+), 2 deletions(-) create mode 100644 doc/default_theme.rasi create mode 100644 doc/old-theme-convert-input.theme create mode 100644 doc/old-theme-convert-output.rasi create mode 100755 test/convert_old_theme_test.sh create mode 100755 test/default_theme_test.sh diff --git a/Makefile.am b/Makefile.am index c48a8915..9411806d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -530,9 +530,13 @@ test-x: $(bin_PROGRAMS) echo "Test dmenu glob" $(top_srcdir)/test/run_test.sh 216 $(top_srcdir)/test/run_glob_test.sh $(top_builddir) echo "Test issue 333" - $(top_srcdir)/test/run_test.sh 221 $(top_srcdir)/test/run_issue333_test.sh $(top_builddir) + $(top_srcdir)/test/run_test.sh 217 $(top_srcdir)/test/run_issue333_test.sh $(top_builddir) echo "Test help output" - $(top_srcdir)/test/run_test.sh 212 $(top_srcdir)/test/help_output_test.sh $(top_builddir) $(top_srcdir) + $(top_srcdir)/test/run_test.sh 218 $(top_srcdir)/test/help_output_test.sh $(top_builddir) $(top_srcdir) + echo "Test theme output" + $(top_srcdir)/test/run_test.sh 219 $(top_srcdir)/test/default_theme_test.sh $(top_builddir) $(top_srcdir) + echo "Test theme convert output" + $(top_srcdir)/test/run_test.sh 220 $(top_srcdir)/test/convert_old_theme_test.sh $(top_builddir) $(top_srcdir) test-x1: $(bin_PROGRAMS) echo "Test dmenu-normal-window" diff --git a/doc/default_theme.rasi b/doc/default_theme.rasi new file mode 100644 index 00000000..4f17f684 --- /dev/null +++ b/doc/default_theme.rasi @@ -0,0 +1,111 @@ +* { + foreground: #FF002B36; + selected-normal-foreground: @lightbg; + normal-foreground: @foreground; + red: #FFDC322F; + alternate-normal-background: @lightbg; + blue: #FF268BD2; + selected-urgent-foreground: @background; + urgent-foreground: @red; + alternate-urgent-background: @lightbg; + active-foreground: @blue; + lightbg: #FFEEE8D5; + selected-active-foreground: @background; + alternate-normal-foreground: @foreground; + alternate-active-background: @lightbg; + bordercolor: @foreground; + background: #FFFDF6E3; + normal-background: @background; + lightfg: #FF586875; + selected-normal-background: @lightfg; + separatorcolor: @foreground; + spacing: 2; + urgent-background: @background; + alternate-urgent-foreground: @red; + selected-urgent-background: @red; + alternate-active-foreground: @blue; + selected-active-background: @blue; + active-background: @background; +} +#window { + border: 1; + foreground: @foreground; + background: #00000000; + padding: 5; +} +#window.box { + foreground: @bordercolor; + background: @background; +} +#window.mainbox { + border: 0; + padding: 0; +} +#window.mainbox.message.box { + border: 1px dash 0px 0px ; + foreground: @separatorcolor; + padding: 2px 0px 0px ; +} +#window.mainbox.message.normal { + foreground: @foreground; +} +#window.mainbox.listview { + fixed-height: 0; + border: 1px dash 0px 0px ; + padding: 2px 0px 0px ; +} +#window.mainbox.listview.element { + border: 0; +} +#window.mainbox.listview.element.normal.normal { + foreground: @normal-foreground; + background: @normal-background; +} +#window.mainbox.listview.element.normal.urgent { + foreground: @urgent-foreground; + background: @urgent-background; +} +#window.mainbox.listview.element.normal.active { + foreground: @active-foreground; + background: @active-background; +} +#window.mainbox.listview.element.selected.normal { + foreground: @selected-normal-foreground; + background: @selected-normal-background; +} +#window.mainbox.listview.element.selected.urgent { + foreground: @selected-urgent-foreground; + background: @selected-urgent-background; +} +#window.mainbox.listview.element.selected.active { + foreground: @selected-active-foreground; + background: @selected-active-background; +} +#window.mainbox.listview.element.alternate.normal { + foreground: @alternate-normal-foreground; + background: @alternate-normal-background; +} +#window.mainbox.listview.element.alternate.urgent { + foreground: @alternate-urgent-foreground; + background: @alternate-urgent-background; +} +#window.mainbox.listview.element.alternate.active { + foreground: @alternate-active-foreground; + background: @alternate-active-background; +} +#window.mainbox.listview.scrollbar { + border: 0; + padding: 0; +} +#window.mainbox.sidebar.box { + border: 1px dash 0px 0px ; +} +#window.mainbox.inputbar { + spacing: 0; +} +#window.mainbox.inputbar.box { + border: 0px ; +} +#window.mainbox.inputbar.normal { + foreground: @foreground; +} diff --git a/doc/old-theme-convert-input.theme b/doc/old-theme-convert-input.theme new file mode 100644 index 00000000..a3f19d73 --- /dev/null +++ b/doc/old-theme-convert-input.theme @@ -0,0 +1,154 @@ +background: rgba(0,0,0,0.0); +foreground: rgba(1,1,1,1); +font: "Ubuntu Mono 15"; +padding: 0; +spacing: 0em; + +#window.mainbox.inputbar.box { + padding: 5px 30px 5px 30px; + +} +#window.mainbox.inputbar { + background: #88003300; + foreground: #FFFFFF; + padding: 0px; + end: false; +} +#mainbox.inputbar.entry { + padding: 0px; + border: 0px; +} +#mainbox.inputbar.prompt { + padding: 0px; +} +#mainbox.inputbar.case-indicator +{ + padding: 0px; + border: 0px; + end: true; +} + +#window.mainbox.listview { + fixed-height: true; + border: 1px 1px 1px 1px; + spacing: 0px; + reverse: false; +} +#window.mainbox.listview.element { + border: 1px; + background: #22000000; + padding: 5px; +} +#window.mainbox.inputbar.entry normal.normal { + background: #00000000; + foreground: #FFFFFF; + padding: 0px; +} +#window.mainbox.inputbar.prompt normal.normal { + background: #00000000; + foreground: #FFFFFF; + padding: 0px; +} +#window.mainbox.inputbar.case-indicator normal.normal { + background: #00000000; + foreground: #FFFFFF; + padding: 0px; +} + +#window.mainbox.inputbar.separator { + background: #FF0000; + foreground: #FFFFFF; + padding: 0px; + end: false; +} + +#window.mainbox.box { + foreground: #ffffff; + background: #aaFFFFFF; + border: 2px dash 2px dash 0px 2px dash; +} +#window.mainbox { + background: #00000000; + padding: 0px; + border: 0px; + foreground: #ffffff; +} + +#window.mainbox.listview.element normal.normal { + foreground: #002b36; +} +#window.mainbox.listview.element selected.normal { + foreground: #ffffff; + background: #770000f5; +} +#window.mainbox.listview.element alternate.normal { + foreground: #002b36; +} +#window.mainbox.listview.element normal.urgent { + foreground: #473f00; +} +#window.mainbox.listview.element selected.urgent { + background: #aa673f00; + foreground: #ffffff; +} +#window.mainbox.listview.element alternate.urgent { + foreground: #473f00; +} +#window.mainbox.listview.element normal.active { + foreground: #005f87; +} +#window.mainbox.listview.element selected.active { + background: #aa008fa7; + foreground: #FFFFFF; +} +#window.mainbox.listview.element alternate.active { + foreground: #005f87; +} +/** + * Override the sidebar button + * Change color of text on selected. + */ +#sidebar.button normal { + foreground: #444444; +} +#sidebar.button selected { + foreground: #4271ae; +} + +#window.mainbox.listview { + scrollbar: true; + scrollbar-width: 5px; + padding: 30px 30px 5px 30px; + spacing: 0em; + dynamic: true; + border: 0px; + fixed-height: true; + border: 2px 0px 0px 0px; +} +#window.mainbox.listview.scrollbar { + border: 1px 1px 1px 0px; + foreground: #000000; + background: #88003300; + padding: 2px; +} +#window.mainbox.listview.scrollbar handle { + foreground: #d75f00; + padding: 2px; +} + +#window { + border: 4px 4px 0px 4px; + padding: 5% 5% 0% 5%; + border-width: 2; + transparency: "real"; + background: #aa000000; + foreground: #aaaaaa; +} +#window.message.textbox { + foreground: #000000; + border: 1px; + padding: 10px; +} +#window.message { + end: false; +} diff --git a/doc/old-theme-convert-output.rasi b/doc/old-theme-convert-output.rasi new file mode 100644 index 00000000..4460ae40 --- /dev/null +++ b/doc/old-theme-convert-output.rasi @@ -0,0 +1,111 @@ +* { + foreground: #FFDBDFBC; + selected-normal-foreground: #FF02143F; + normal-foreground: @foreground; + red: #FFDC322F; + alternate-normal-background: #3AFFFFFF; + blue: #FF268BD2; + selected-urgent-foreground: #FF02143F; + urgent-foreground: #FFFF817F; + alternate-urgent-background: #3AFFFFFF; + active-foreground: #FF6AA4FF; + lightbg: #FFEEE8D5; + selected-active-foreground: #FF02143F; + alternate-normal-foreground: @foreground; + alternate-active-background: #3AFFFFFF; + bordercolor: #FFDBDFBC; + background: #EE27201A; + normal-background: #00000000; + lightfg: #FF586875; + selected-normal-background: #FFDBDFBC; + separatorcolor: #FFDBDFBC; + spacing: 2; + urgent-background: #00000000; + alternate-urgent-foreground: @urgent-foreground; + selected-urgent-background: #FFFF817F; + alternate-active-foreground: @active-foreground; + selected-active-background: #FF6AA4FF; + active-background: #00000000; +} +#window { + border: 1; + foreground: @foreground; + background: #00000000; + padding: 5; +} +#window.box { + foreground: @bordercolor; + background: @background; +} +#window.mainbox { + border: 0; + padding: 0; +} +#window.mainbox.message.box { + border: 1px dash 0px 0px ; + foreground: @separatorcolor; + padding: 2px 0px 0px ; +} +#window.mainbox.message.normal { + foreground: @foreground; +} +#window.mainbox.listview { + fixed-height: 0; + border: 1px dash 0px 0px ; + padding: 2px 0px 0px ; +} +#window.mainbox.listview.element { + border: 0; +} +#window.mainbox.listview.element.normal.normal { + foreground: @normal-foreground; + background: @normal-background; +} +#window.mainbox.listview.element.normal.urgent { + foreground: @urgent-foreground; + background: @urgent-background; +} +#window.mainbox.listview.element.normal.active { + foreground: @active-foreground; + background: @active-background; +} +#window.mainbox.listview.element.selected.normal { + foreground: @selected-normal-foreground; + background: @selected-normal-background; +} +#window.mainbox.listview.element.selected.urgent { + foreground: @selected-urgent-foreground; + background: @selected-urgent-background; +} +#window.mainbox.listview.element.selected.active { + foreground: @selected-active-foreground; + background: @selected-active-background; +} +#window.mainbox.listview.element.alternate.normal { + foreground: @alternate-normal-foreground; + background: @alternate-normal-background; +} +#window.mainbox.listview.element.alternate.urgent { + foreground: @alternate-urgent-foreground; + background: @alternate-urgent-background; +} +#window.mainbox.listview.element.alternate.active { + foreground: @alternate-active-foreground; + background: @alternate-active-background; +} +#window.mainbox.listview.scrollbar { + border: 0; + padding: 0; +} +#window.mainbox.sidebar.box { + border: 1px dash 0px 0px ; +} +#window.mainbox.inputbar { + spacing: 0; +} +#window.mainbox.inputbar.box { + border: 0px ; +} +#window.mainbox.inputbar.normal { + foreground: @foreground; +} diff --git a/test/convert_old_theme_test.sh b/test/convert_old_theme_test.sh new file mode 100755 index 00000000..2b362627 --- /dev/null +++ b/test/convert_old_theme_test.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +TOP_DIR=$1 + +rofi -config ${TOP_DIR}/doc/old-theme-convert-input.theme -dump-theme > temp.txt + +if ! diff temp.txt ${TOP_DIR}/doc/old-theme-convert-output.rasi > /dev/null +then + echo "Dump default theme does not match." + diff temp.txt ${TOP_DIR}/doc/old-theme-convert-output.rasi + exit 1; +fi + +exit ${RETV} diff --git a/test/default_theme_test.sh b/test/default_theme_test.sh new file mode 100755 index 00000000..8baa66c9 --- /dev/null +++ b/test/default_theme_test.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +TOP_DIR=$1 + +rofi -no-config -dump-theme > temp.txt + +if ! diff temp.txt ${TOP_DIR}/doc/default_theme.rasi > /dev/null +then + echo "Dump default theme does not match." + diff temp.txt ${TOP_DIR}/doc/default_theme.rasi + exit 1; +fi + +exit ${RETV} From 3fe42c3f79792b3fa07c865766e8128dc1c3d6aa Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 19:43:44 +0200 Subject: [PATCH 19/36] Update old-theme-convert test --- doc/old-theme-convert-output.rasi | 40 +++++++++++++++---------------- test/convert_old_theme_test.sh | 3 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/doc/old-theme-convert-output.rasi b/doc/old-theme-convert-output.rasi index 4460ae40..4f17f684 100644 --- a/doc/old-theme-convert-output.rasi +++ b/doc/old-theme-convert-output.rasi @@ -1,31 +1,31 @@ * { - foreground: #FFDBDFBC; - selected-normal-foreground: #FF02143F; + foreground: #FF002B36; + selected-normal-foreground: @lightbg; normal-foreground: @foreground; red: #FFDC322F; - alternate-normal-background: #3AFFFFFF; + alternate-normal-background: @lightbg; blue: #FF268BD2; - selected-urgent-foreground: #FF02143F; - urgent-foreground: #FFFF817F; - alternate-urgent-background: #3AFFFFFF; - active-foreground: #FF6AA4FF; + selected-urgent-foreground: @background; + urgent-foreground: @red; + alternate-urgent-background: @lightbg; + active-foreground: @blue; lightbg: #FFEEE8D5; - selected-active-foreground: #FF02143F; + selected-active-foreground: @background; alternate-normal-foreground: @foreground; - alternate-active-background: #3AFFFFFF; - bordercolor: #FFDBDFBC; - background: #EE27201A; - normal-background: #00000000; + alternate-active-background: @lightbg; + bordercolor: @foreground; + background: #FFFDF6E3; + normal-background: @background; lightfg: #FF586875; - selected-normal-background: #FFDBDFBC; - separatorcolor: #FFDBDFBC; + selected-normal-background: @lightfg; + separatorcolor: @foreground; spacing: 2; - urgent-background: #00000000; - alternate-urgent-foreground: @urgent-foreground; - selected-urgent-background: #FFFF817F; - alternate-active-foreground: @active-foreground; - selected-active-background: #FF6AA4FF; - active-background: #00000000; + urgent-background: @background; + alternate-urgent-foreground: @red; + selected-urgent-background: @red; + alternate-active-foreground: @blue; + selected-active-background: @blue; + active-background: @background; } #window { border: 1; diff --git a/test/convert_old_theme_test.sh b/test/convert_old_theme_test.sh index 2b362627..75fc392b 100755 --- a/test/convert_old_theme_test.sh +++ b/test/convert_old_theme_test.sh @@ -2,11 +2,12 @@ TOP_DIR=$1 +xrdb -retain -load ${TOP_DIR}/doc/old-theme-convert-input.theme rofi -config ${TOP_DIR}/doc/old-theme-convert-input.theme -dump-theme > temp.txt if ! diff temp.txt ${TOP_DIR}/doc/old-theme-convert-output.rasi > /dev/null then - echo "Dump default theme does not match." + echo "Convert default theme failed" diff temp.txt ${TOP_DIR}/doc/old-theme-convert-output.rasi exit 1; fi From 9d068151fdbad2710b1fe9294c21c4c9d28ca15b Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 14 May 2017 21:06:34 +0200 Subject: [PATCH 20/36] Update contributing --- .github/CONTRIBUTING.md | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 85fadd14..adf51bc6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,9 +1,11 @@ # Creating an issue -When reporting bugs keep in mind that the people working on it do this unpaid, in their free time and as a hobby. So be -polite and helpful. Bug reports that demand, contain insults to this or other projects, or have a general unfriendly -tone will be closed without discussion. Everybody has it own way of working; What might be the norm for you, might not -be for others. Therefore be verbose in your description. +When reporting bugs keep in mind that the people working on it do this unpaid, +in their free time and as a hobby. So be polite and helpful. Bug reports that +demand, contain insults to this or other projects, or have a general unfriendly +tone will be closed without discussion. Everybody has it own way of working; +What might be the norm for you, might not be for others. Therefore be verbose in +your description. Before creating an issue: @@ -21,17 +23,30 @@ When reporting bugs include the following information: * A proper title for others to search for. * Be exact. +When adding comments to an issue make sure: + +* It is relevant to the issue. +* It contributes to solving the issue. +* Use :+1: :-1: emojis instead of replying 'me too' or 'I also have this.' + + +Issue high-jacking, e.g. adding a request/issue to an existing issue, is very +disruptive. +Please create a new issue, if it is similar it will be marked duplicate. + The issue tracker is not for: * Questions. * Writing complaints. -These topics belong on [FORUM](https://reddit.com/r/qtools//), [IRC](https://webchat.freenode.net/?channels=#rofi), -frequently asked questions will be added to the [F.A.Q](https://github.com/DaveDavenport/rofi/wiki#faq) on the -[wiki](https://github.com/DaveDavenport/rofi/wiki). +These topics belong on [FORUM](https://reddit.com/r/qtools//), +[IRC](https://webchat.freenode.net/?channels=#rofi), frequently asked questions +will be added to the [F.A.Q](https://github.com/DaveDavenport/rofi/wiki#faq) on +the [wiki](https://github.com/DaveDavenport/rofi/wiki). -Questions filled in on the bug tracker will be marked `question`, locked and closed. If the question is clear, I -normally try to provide an answer. +Questions filled in on the bug tracker will be marked `question`, locked and +closed. If the question is clear, I normally try to provide an answer. -**Please do not submit reports related to wayland, see [here](https://github.com/DaveDavenport/rofi/wiki/Wayland) for -more information.** +**Please do not submit reports related to wayland, see +[here](https://github.com/DaveDavenport/rofi/wiki/Wayland) for more +information.** From f0ceeb86d8f11526fc2fd52c3ef8e3c9e340a20f Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 15 May 2017 09:10:02 +0200 Subject: [PATCH 21/36] [Lexer] Support hsla --- lexer/theme-lexer.l | 2 +- lexer/theme-parser.y | 11 +++++++++++ test/theme-parser-test.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index f6921027..a43323f5 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -176,7 +176,7 @@ RGBA "rgba" RGB "rgb" HWB "hwb" CMYK "cmyk" -HSL "hsl" +HSL hsl[a]? S_T_PARENT_LEFT \( S_T_PARENT_RIGHT \) diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index bf0019e0..1ccc551e 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -499,6 +499,17 @@ t_property_color gdouble l = $8; $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); $$.alpha = 1.0; +} + /** hsl ( 0-360 , 0-100 %, 0 - 100 %) */ +| T_COL_HSL T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { + if ( ! check_in_range($3, 0,360, &(@$)) ) { YYABORT; } + if ( ! check_in_range($5, 0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($8, 0,100, &(@$)) ) { YYABORT; } + gdouble h = $3; + gdouble s = $5; + gdouble l = $8; + $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); + $$.alpha = $11/100.0; } /** Hex colors parsed by lexer. */ | T_COLOR { diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 68eba616..5aa0b298 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -593,7 +593,35 @@ START_TEST ( test_properties_color_hsl ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { test1: hsl(127,40%,66.66666%); test2: hsl(0, 100%, 50%); }"); + rofi_theme_parse_string ( "* { test1: hsl(127,40%,66.66666%); test2: hsl(0, 100%, 50%); testa: hsl(127,40%, 66.66666%, 30%);}"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 0x88/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green, 0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x88/255.0 ,0.004); + ck_assert_double_eq_tol ( p->value.color.green ,0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 ,0.004); +} +END_TEST +START_TEST ( test_properties_color_hsla ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hsla(127,40%,66.66666%); test2: hsla(0, 100%, 50%); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); @@ -879,6 +907,7 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent); tcase_add_test ( tc_prop_color, test_properties_color_argb); tcase_add_test ( tc_prop_color, test_properties_color_hsl); + tcase_add_test ( tc_prop_color, test_properties_color_hsla); tcase_add_test ( tc_prop_color, test_properties_color_hwb); tcase_add_test ( tc_prop_color, test_properties_color_cmyk); suite_add_tcase(s, tc_prop_color ); From e397c346da38f71c8b8f6e5e4cf57f7ee01b2404 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 15 May 2017 15:05:40 +0200 Subject: [PATCH 22/36] [ThemeParser] Extend color formats. - Support whitespace format. - Support deg,rad, grad, turn angle. - Add alpha channel support to hwb --- lexer/theme-lexer.l | 15 +++- lexer/theme-parser.y | 146 ++++++++++++++++++++++----------------- libgwater | 2 +- test/theme-parser-test.c | 60 +++++++++++++++- 4 files changed, 157 insertions(+), 66 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index a43323f5..a35a5044 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -171,6 +171,13 @@ BOLD "bold" UNDERLINE "underline" ITALIC "italic" +/* ANGLES */ + +ANGLE_DEG "deg" +ANGLE_GRAD "grad" +ANGLE_RAD "rad" +ANGLE_TURN "turn" + /* Color schema */ RGBA "rgba" RGB "rgb" @@ -180,7 +187,8 @@ HSL hsl[a]? S_T_PARENT_LEFT \( S_T_PARENT_RIGHT \) -COMMA , +COMMA , +FORWARD_SLASH \/ LS_DASH "dash" LS_SOLID "solid" @@ -422,6 +430,7 @@ if ( queue == NULL ){ {S_T_PARENT_LEFT} { return T_PARENT_LEFT; } {S_T_PARENT_RIGHT} { return T_PARENT_RIGHT;} {COMMA} { return T_COMMA; } +{FORWARD_SLASH} { return T_FORWARD_SLASH; } /* Position */ {CENTER} { return T_POS_CENTER; } {EAST} { return T_POS_EAST; } @@ -434,6 +443,10 @@ if ( queue == NULL ){ {ITALIC} { return T_ITALIC; } {UNDERLINE} { return T_UNDERLINE; } +{ANGLE_DEG} { return T_ANGLE_DEG; } +{ANGLE_RAD} { return T_ANGLE_RAD; } +{ANGLE_GRAD} { return T_ANGLE_GRAD; } +{ANGLE_TURN} { return T_ANGLE_TURN; } <> { ParseObject *po = g_queue_pop_head ( file_queue ); diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 1ccc551e..7ba81ae6 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -119,6 +119,17 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) return colour; } +static ThemeColor hwb_to_rgb ( double h, double w, double b) +{ + ThemeColor retv = hsl_to_rgb ( h, 1.0, 0.5); + retv.red *= ( 1. - w - b ); + retv.red += w; + retv.green *= ( 1. - w - b ); + retv.green += w; + retv.blue *= ( 1. - w - b ); + retv.blue += w; + return retv; +} %} %union { @@ -167,6 +178,11 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) %token T_UNIT_EM "em" %token T_UNIT_PERCENT "%" +%token T_ANGLE_DEG "Degrees" +%token T_ANGLE_GRAD "Gradians" +%token T_ANGLE_RAD "Radians" +%token T_ANGLE_TURN "Turns" + %token T_COL_RGBA "rgba colorscheme" %token T_COL_RGB "rgb colorscheme" %token T_COL_HSL "hsl colorscheme" @@ -176,6 +192,8 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) %token T_PARENT_LEFT "Parent left ('(')" %token T_PARENT_RIGHT "Parent right (')')" %token T_COMMA "comma separator (',')" +%token T_OPTIONAL_COMMA "Optional comma separator (',')" +%token T_FORWARD_SLASH "forward slash ('/')" %token T_PERCENT "Percent sign ('%')" %token T_BOPEN "bracket open ('{')" @@ -196,6 +214,10 @@ static ThemeColor hsl_to_rgb ( double h, double s, double l ) %type t_property_list_optional %type t_property_color %type t_property_color_value +%type t_property_color_opt_alpha_c +%type t_property_color_opt_alpha_ws +%type t_property_color_value_unit +%type t_property_color_value_angle %type t_property_name %type t_property_distance %type t_property_unit @@ -411,26 +433,24 @@ t_property_line_style */ t_property_color /** 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_DOUBLE T_PARENT_RIGHT { +: 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 { if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; } if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; } - if ( ! check_in_range($9,0,1.00, &(@$)) ) { YYABORT; } $$.alpha = $9; $$.red = $3/255.0; $$.green = $5/255.0; $$.blue = $7/255.0; } - /** rgba ( 0-255 , 0-255, 0-255, 0-100% ) */ -| T_COL_RGBA T_PARENT_LEFT T_INT T_COMMA T_INT T_COMMA T_INT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { + /** 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 { if ( ! check_in_range($3,0,255, &(@$)) ) { YYABORT; } + if ( ! check_in_range($4,0,255, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; } - if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; } - if ( ! check_in_range($9,0,100, &(@$)) ) { YYABORT; } - $$.alpha = $9/100.0; + $$.alpha = $7; $$.red = $3/255.0; - $$.green = $5/255.0; - $$.blue = $7/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 { @@ -442,81 +462,81 @@ t_property_color $$.green = $5/255.0; $$.blue = $7/255.0; } - /** hwb ( 0-360 , 0-100 %, 0 - 100 %) */ -| T_COL_HWB T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { - if ( ! check_in_range($3,0,360, &(@$)) ) { YYABORT; } - if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($8,0,100, &(@$)) ) { YYABORT; } - double h = $3/360.0; - double w = $5/100.0; - double b = $8/100.0; - $$ = hsl_to_rgb ( h, 1.0, 0.5); + /** 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 *= ( 1. - w - b ); - $$.red += w; - $$.green *= ( 1. - w - b ); - $$.green += w; - $$.blue *= ( 1. - w - b ); - $$.blue += w; + $$.red = $3/255.0; + $$.green = $4/255.0; + $$.blue = $5/255.0; } - /** cmyk ( 0-100%, 0-100%, 0-100%, 0-100%) */ -| T_COL_CMYK T_PARENT_LEFT t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { + /** hwb with comma */ +| T_COL_HWB T_PARENT_LEFT t_property_color_value_angle T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit t_property_color_opt_alpha_c T_PARENT_RIGHT { + double h = $3, w = $5, b = $7; + $$ = hwb_to_rgb ( h, w, b ); + $$.alpha = $8; +} + /** hwb whitespace */ +| T_COL_HWB T_PARENT_LEFT t_property_color_value_angle t_property_color_value_unit t_property_color_value_unit t_property_color_opt_alpha_ws T_PARENT_RIGHT { + double h = $3, w = $4, b = $5; + $$ = hwb_to_rgb ( h, w, b ); + $$.alpha = $6; +} + /** cmyk with comma */ +| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit T_PARENT_RIGHT { $$.alpha = 1.0; - if ( ! check_in_range($3, 0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($6, 0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($9, 0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($12,0,100, &(@$)) ) { YYABORT; } - double c= $3/100.0; - double m= $6/100.0; - double y= $9/100.0; - double k= $12/100.0; + double c= $3, m= $5, y= $7, k= $9; $$.red = (1.0-c)*(1.0-k); $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } - /** cmyk ( 0-1.0, 0-1.0, 0-1.0, 0-1.0) */ -| T_COL_CMYK T_PARENT_LEFT t_property_color_value T_COMMA t_property_color_value T_COMMA t_property_color_value T_COMMA t_property_color_value T_PARENT_RIGHT { + /** cmyk whitespace edition. */ +| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit T_PARENT_RIGHT { $$.alpha = 1.0; - if ( ! check_in_range($3, 0,1.00, &(@$)) ) { YYABORT; } - if ( ! check_in_range($5, 0,1.00, &(@$)) ) { YYABORT; } - if ( ! check_in_range($7, 0,1.00, &(@$)) ) { YYABORT; } - if ( ! check_in_range($9, 0,1.00, &(@$)) ) { YYABORT; } - double c= $3; - double m= $5; - double y= $7; - double k= $9; + double c= $3, m= $4, y= $5, k= $6; $$.red = (1.0-c)*(1.0-k); $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } - /** hsl ( 0-360 , 0-100 %, 0 - 100 %) */ -| T_COL_HSL T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { - if ( ! check_in_range($3, 0,360, &(@$)) ) { YYABORT; } - if ( ! check_in_range($5, 0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($8, 0,100, &(@$)) ) { YYABORT; } - gdouble h = $3; - gdouble s = $5; - gdouble l = $8; - $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); - $$.alpha = 1.0; + /** hsl ( 0-360 0-100 % 0 - 100 % / alpha) */ +| T_COL_HSL T_PARENT_LEFT t_property_color_value_angle t_property_color_value_unit t_property_color_value_unit t_property_color_opt_alpha_ws T_PARENT_RIGHT { + double h = $3, s = $4, l = $5; + $$ = hsl_to_rgb ( h, s, l ); + $$.alpha = $6; } /** hsl ( 0-360 , 0-100 %, 0 - 100 %) */ -| T_COL_HSL T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { - if ( ! check_in_range($3, 0,360, &(@$)) ) { YYABORT; } - if ( ! check_in_range($5, 0,100, &(@$)) ) { YYABORT; } - if ( ! check_in_range($8, 0,100, &(@$)) ) { YYABORT; } - gdouble h = $3; - gdouble s = $5; - gdouble l = $8; - $$ = hsl_to_rgb ( h/360.0, s/100.0, l/100.0 ); - $$.alpha = $11/100.0; +| T_COL_HSL T_PARENT_LEFT t_property_color_value_angle T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit t_property_color_opt_alpha_c T_PARENT_RIGHT { + double h = $3, s = $5, l = $7; + $$ = hsl_to_rgb ( h, s, l ); + $$.alpha = $8; } /** Hex colors parsed by lexer. */ | T_COLOR { $$ = $1; } ; +t_property_color_opt_alpha_c +: %empty { $$ = 1.0; } +| T_COMMA t_property_color_value_unit { $$ = $2;} +; +t_property_color_opt_alpha_ws +: %empty { $$ = 1.0; } +| T_FORWARD_SLASH t_property_color_value_unit { $$ = $2;} +; + t_property_color_value_angle +: t_property_color_value { $$ = $1/360.0; if ( ! check_in_range ( $1, 0, 360, &(@$))){YYABORT;}} +| t_property_color_value T_ANGLE_DEG { $$ = $1/360.0; if ( ! check_in_range ( $1, 0, 360, &(@$))){YYABORT;}} +| t_property_color_value T_ANGLE_RAD { $$ = $1/(2*G_PI); if ( ! check_in_range ( $1, 0.0, (2*G_PI), &(@$))){YYABORT;}} +| t_property_color_value T_ANGLE_GRAD { $$ = $1/400.0; if ( ! check_in_range ( $1, 0, 400, &(@$))){YYABORT;}} +| t_property_color_value T_ANGLE_TURN { $$ = $1; if ( ! check_in_range ( $1, 0.0, 1.0, &(@$))){YYABORT;}} +; +t_property_color_value_unit +: t_property_color_value T_PERCENT { $$ = $1/100.0; if ( !check_in_range ( $1, 0, 100, &(@$))){YYABORT;}} +| t_property_color_value { $$ = $1; if ( !check_in_range ( $1, 0.0, 1.0, &(@$))){YYABORT;}} +; /** Color value to be double or integer. */ t_property_color_value : T_DOUBLE { $$ = $1; } diff --git a/libgwater b/libgwater index 60e5e71e..173f2f55 160000 --- a/libgwater +++ b/libgwater @@ -1 +1 @@ -Subproject commit 60e5e71e09e573bd5c7839ce4a892747ea232526 +Subproject commit 173f2f5566636a1de559cc57f3154db70c3f2e9f diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 5aa0b298..488aa203 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -643,7 +643,7 @@ START_TEST ( test_properties_color_hwb ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); }"); + rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); testa: hwb(265, 31%, 29%, 40%); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); @@ -658,6 +658,40 @@ START_TEST ( test_properties_color_hwb ) ck_assert_double_eq_tol ( p->value.color.red , 166/255.0, 0.004); ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); +} +END_TEST +START_TEST ( test_properties_color_hwb_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hwb(190 deg 65 %0%); test2: hwb(295 grad 31% 29%);testa: hwb(0.736 turn 31% 29% / 40%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 166/255.0, 0.004); + ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); } END_TEST START_TEST ( test_properties_color_cmyk ) @@ -682,6 +716,28 @@ START_TEST ( test_properties_color_cmyk ) ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); } END_TEST +START_TEST ( test_properties_color_cmyk_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: cmyk ( 41% 0% 100% 0%); test2: cmyk ( 0 1.0 1.0 0);}"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 0x96/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 1.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", 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 , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); +} +END_TEST START_TEST ( test_properties_padding_2 ) { widget wid; @@ -909,7 +965,9 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_hsl); tcase_add_test ( tc_prop_color, test_properties_color_hsla); tcase_add_test ( tc_prop_color, test_properties_color_hwb); + 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_ws); suite_add_tcase(s, tc_prop_color ); } { From 494550d38d572801ba3924611b09c7ca2b20610a Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 15 May 2017 22:46:33 +0200 Subject: [PATCH 23/36] [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 --- Makefile.am | 10 +++ include/css-colors.h | 12 +++ include/helper.h | 2 +- include/settings.h | 8 +- lexer/theme-lexer.l | 24 +++++- lexer/theme-parser.y | 43 +++++------ source/css-colors.c | 154 +++++++++++++++++++++++++++++++++++++++ source/theme.c | 10 +-- source/view.c | 26 +++---- source/widgets/textbox.c | 10 +-- source/x11-helper.c | 11 ++- test/theme-parser-test.c | 45 +++++++++++- 12 files changed, 291 insertions(+), 64 deletions(-) create mode 100644 include/css-colors.h create mode 100644 source/css-colors.c diff --git a/Makefile.am b/Makefile.am index 9411806d..e76fc934 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,6 +60,7 @@ SOURCES=\ source/widgets/scrollbar.c\ source/xrmoptions.c\ source/x11-helper.c\ + source/css-colors.c\ source/dialogs/run.c\ source/dialogs/ssh.c\ source/dialogs/drun.c\ @@ -82,6 +83,7 @@ SOURCES=\ include/timings.h\ include/history.h\ include/theme.h\ + include/css-colors.h\ include/default-theme.h\ include/widgets/box.h\ include/widgets/container.h\ @@ -319,6 +321,7 @@ widget_test_SOURCES=\ source/widgets/widget.c\ source/widgets/textbox.c\ source/theme.c\ + source/css-colors.c\ source/helper.c\ source/x11-helper.c\ config/config.c\ @@ -334,7 +337,9 @@ box_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/css-colors.c\ include/theme.h\ + include/css-colors.h\ test/box-test.c scrollbar_test_LDADD=$(textbox_test_LDADD) @@ -345,7 +350,9 @@ scrollbar_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/css-colors.c\ include/theme.h\ + include/css-colors.h\ test/scrollbar-test.c textbox_test_SOURCES=\ @@ -354,6 +361,7 @@ textbox_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/css-colors.c\ source/helper.c\ source/x11-helper.c\ config/config.c\ @@ -382,6 +390,7 @@ theme_parser_test_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/theme.h\ + include/css-colors.h\ include/xrmoptions.h\ source/xrmoptions.c\ source/x11-helper.c\ @@ -389,6 +398,7 @@ theme_parser_test_SOURCES=\ lexer/theme-parser.c\ lexer/theme-parser.h\ source/theme.c\ + source/css-colors.c\ test/theme-parser-test.c endif diff --git a/include/css-colors.h b/include/css-colors.h new file mode 100644 index 00000000..0c47b393 --- /dev/null +++ b/include/css-colors.h @@ -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 diff --git a/include/helper.h b/include/helper.h index e3648b6b..03d4515f 100644 --- a/include/helper.h +++ b/include/helper.h @@ -244,7 +244,7 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st * are found, respectively, to be less than, to match, or be greater than the first `n` * characters (not bytes) of `b`. */ -int utf8_strncmp ( const char *a, const char* b, size_t n ) __attribute__((nonnull(1,2))); +int utf8_strncmp ( const char *a, const char* b, size_t n ) __attribute__( ( nonnull ( 1, 2 ) ) ); /** * @param wd The work directory (optional) diff --git a/include/settings.h b/include/settings.h index b0506f64..f18be7a9 100644 --- a/include/settings.h +++ b/include/settings.h @@ -65,13 +65,13 @@ typedef enum /** Middle left */ WL_WEST = 8, /** Left top corner. */ - WL_NORTH_WEST = WL_NORTH|WL_WEST, + WL_NORTH_WEST = WL_NORTH | WL_WEST, /** Top right */ - WL_NORTH_EAST = WL_NORTH|WL_EAST, + WL_NORTH_EAST = WL_NORTH | WL_EAST, /** Bottom right */ - WL_SOUTH_EAST = WL_SOUTH|WL_EAST, + WL_SOUTH_EAST = WL_SOUTH | WL_EAST, /** Bottom left */ - WL_SOUTH_WEST = WL_SOUTH|WL_WEST, + WL_SOUTH_WEST = WL_SOUTH | WL_WEST, } WindowLocation; /** diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index a35a5044..72d569c7 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -41,6 +41,7 @@ #include "theme.h" #include "theme-parser.h" +#include "css-colors.h" #define LOG_DOMAIN "Parser" int last_state = 0; @@ -147,6 +148,7 @@ UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} WHITESPACE [[:blank:]] WSO [[:blank:]]* WORD [[:alnum:]-]+ +COLOR_NAME [[:alpha:]]+ STRING {UANYN}+ HEX [[:xdigit:]] NUMBER [[:digit:]] @@ -179,12 +181,13 @@ ANGLE_RAD "rad" ANGLE_TURN "turn" /* Color schema */ -RGBA "rgba" -RGB "rgb" +RGBA rgb[a]? HWB "hwb" CMYK "cmyk" HSL hsl[a]? +COLOR_TRANSPARENT "transparent" + S_T_PARENT_LEFT \( S_T_PARENT_RIGHT \) COMMA , @@ -422,7 +425,6 @@ if ( queue == NULL ){ } /* Color schemes */ {RGBA} { return T_COL_RGBA; } -{RGB} { return T_COL_RGB; } {HSL} { return T_COL_HSL; } {HWB} { return T_COL_HWB; } {CMYK} { return T_COL_CMYK; } @@ -448,6 +450,22 @@ if ( queue == NULL ){ {ANGLE_GRAD} { return T_ANGLE_GRAD; } {ANGLE_TURN} { return T_ANGLE_TURN; } +{COLOR_TRANSPARENT} { + return T_COLOR_TRANSPARENT; +} +{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; +} + <> { ParseObject *po = g_queue_pop_head ( file_queue ); if ( po ) { diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 7ba81ae6..7e9c1da2 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -35,6 +35,7 @@ %code requires { #include "theme.h" #include "xrmoptions.h" +#include "css-colors.h" typedef struct YYLTYPE { int first_line; @@ -157,6 +158,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_DOUBLE "Floating-point number" %token T_STRING "UTF-8 encoded string" %token T_PROP_NAME "property name" +%token T_COLOR_NAME "Color value by name" %token T_NAME_ELEMENT "Element name" %token T_BOOLEAN "Boolean value (true or false)" %token 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_TURN "Turns" -%token T_COL_RGBA "rgba colorscheme" -%token T_COL_RGB "rgb colorscheme" +%token T_COL_RGBA "rgb[a] colorscheme" %token T_COL_HSL "hsl colorscheme" %token T_COL_HWB "hwb 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_CONFIGURATION "Configuration block" +%token T_COLOR_TRANSPARENT "Transparent" + %type t_entry %type t_entry_list %type t_entry_name_path @@ -433,41 +436,21 @@ t_property_line_style */ t_property_color /** 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($5,0,255, &(@$)) ) { YYABORT; } if ( ! check_in_range($7,0,255, &(@$)) ) { YYABORT; } - $$.alpha = $9; + $$.alpha = $8; $$.red = $3/255.0; $$.green = $5/255.0; $$.blue = $7/255.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($4,0,255, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,255, &(@$)) ) { YYABORT; } - $$.alpha = $7; - $$.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; + $$.alpha = $6; $$.red = $3/255.0; $$.green = $4/255.0; $$.blue = $5/255.0; @@ -516,6 +499,14 @@ t_property_color | T_COLOR { $$ = $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 : %empty { $$ = 1.0; } diff --git a/source/css-colors.c b/source/css-colors.c new file mode 100644 index 00000000..cc2a6b35 --- /dev/null +++ b/source/css-colors.c @@ -0,0 +1,154 @@ +#include +#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 ); diff --git a/source/theme.c b/source/theme.c index e31d0027..985d62c2 100644 --- a/source/theme.c +++ b/source/theme.c @@ -317,7 +317,7 @@ extern FILE* yyin; */ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s ) { - char *what_esc = what?g_markup_escape_text ( what, -1 ):g_strdup(""); + char *what_esc = what ? g_markup_escape_text ( what, -1 ) : g_strdup ( "" ); GString *str = g_string_new ( "" ); g_string_printf ( str, "Error while parsing theme: %s\n", what_esc ); g_free ( what_esc ); @@ -638,7 +638,7 @@ gboolean rofi_theme_is_empty ( void ) void rofi_theme_convert_old ( void ) { if ( config.color_window ) { - char **retv = g_strsplit ( config.color_window, ",", -1 ); + char **retv = g_strsplit ( config.color_window, ",", -1 ); const char * const conf[] = { "* { background: %s; }", "* { bordercolor: %s; }", @@ -652,7 +652,7 @@ void rofi_theme_convert_old ( void ) g_strfreev ( retv ); } if ( config.color_normal ) { - char **retv = g_strsplit ( config.color_normal, ",", -1 ); + char **retv = g_strsplit ( config.color_normal, ",", -1 ); const char * const conf[] = { "* { normal-background: %s; }", "* { foreground: %s; normal-foreground: @foreground; alternate-normal-foreground: @foreground; }", @@ -668,7 +668,7 @@ void rofi_theme_convert_old ( void ) g_strfreev ( retv ); } if ( config.color_urgent ) { - char **retv = g_strsplit ( config.color_urgent, ",", -1 ); + char **retv = g_strsplit ( config.color_urgent, ",", -1 ); const char * const conf[] = { "* { urgent-background: %s; }", "* { urgent-foreground: %s; alternate-urgent-foreground: @urgent-foreground;}", @@ -684,7 +684,7 @@ void rofi_theme_convert_old ( void ) g_strfreev ( retv ); } if ( config.color_active ) { - char **retv = g_strsplit ( config.color_active, ",", -1 ); + char **retv = g_strsplit ( config.color_active, ",", -1 ); const char * const conf[] = { "* { active-background: %s; }", "* { active-foreground: %s; alternate-active-foreground: @active-foreground;}", diff --git a/source/view.c b/source/view.c index 9c74a0cc..416bad7d 100644 --- a/source/view.c +++ b/source/view.c @@ -70,7 +70,7 @@ #include "xcb.h" #ifdef XkBCOMMON_HAS_CONSUMED2 -#define xkb_state_key_get_consumed_mods(s, k) xkb_state_key_get_consumed_mods2(s, k, XKB_CONSUMED_MODE_GTK) +#define xkb_state_key_get_consumed_mods( s, k ) xkb_state_key_get_consumed_mods2 ( s, k, XKB_CONSUMED_MODE_GTK ) #endif /** @@ -714,8 +714,8 @@ void __create_window ( MenuFlags menu_flags ) } // Setup font. // Dummy widget. - container *win = container_create ( "window.box" ); - const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font ); + container *win = container_create ( "window.box" ); + const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font ); if ( font ) { PangoFontDescription *pfd = pango_font_description_from_string ( font ); if ( helper_validate_font ( pfd, font ) ) { @@ -1297,19 +1297,19 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio break; // If you add a binding here, make sure to add it to textbox_keybinding too case MOVE_CHAR_BACK: - { - if ( textbox_keybinding ( state->text, action ) == 0 ) { - listview_nav_left ( state->list_view ); - } - break; + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_left ( state->list_view ); } + break; + } case MOVE_CHAR_FORWARD: - { - if ( textbox_keybinding ( state->text, action ) == 0 ) { - listview_nav_right ( state->list_view ); - } - break; + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_right ( state->list_view ); } + break; + } case CLEAR_LINE: case MOVE_FRONT: case MOVE_END: diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 32f38330..48c03084 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -135,7 +135,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType if ( helper_validate_font ( tbfc->pfd, font ) ) { tbfc->metrics = pango_context_get_metrics ( p_context, tbfc->pfd, NULL ); // Cast away consts. (*yuck*) because table_insert does not know it is const. - g_hash_table_insert ( tbfc_cache, (char *)font, tbfc ); + g_hash_table_insert ( tbfc_cache, (char *) font, tbfc ); } else { pango_font_description_free ( tbfc->pfd ); @@ -412,7 +412,7 @@ static int textbox_cursor_inc ( textbox *tb ) { int old = tb->cursor; 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; textbox_cursor ( tb, tb->cursor - 1 ); - return ( old != tb->cursor ); + return old != tb->cursor; } // Move word right @@ -633,10 +633,10 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) { // Left or Ctrl-b case MOVE_CHAR_BACK: - return (textbox_cursor_dec ( tb ) == TRUE)?2:0; + return ( textbox_cursor_dec ( tb ) == TRUE ) ? 2 : 0; // Right or Ctrl-F case MOVE_CHAR_FORWARD: - return (textbox_cursor_inc ( tb ) == TRUE)?2:0; + return ( textbox_cursor_inc ( tb ) == TRUE ) ? 2 : 0; // Ctrl-U: Kill from the beginning to the end of the line. case CLEAR_LINE: textbox_text ( tb, "" ); diff --git a/source/x11-helper.c b/source/x11-helper.c index 4a66ba36..5e1dce04 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -659,9 +659,9 @@ unsigned int x11_get_current_mask ( xkb_stuff *xkb ) // convert a Mod+key arg to mod mask and keysym gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release, GString *str ) { - char *input_key = g_strdup ( combo ); - char *mod_key = input_key; - char *error_msg = NULL; + char *input_key = g_strdup ( combo ); + char *mod_key = input_key; + char *error_msg = NULL; unsigned int last_modmask = 0; unsigned int modmask = 0; xkb_keysym_t last_sym = XKB_KEY_NoSymbol; @@ -679,7 +679,7 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key entry = g_strstrip ( entry ); // Compare against lowered version. last_modmask = modmask; - last_sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); + last_sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); char *entry_lowered = g_utf8_strdown ( entry, -1 ); if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) { modmask |= x11_mod_masks[X11MOD_SHIFT]; @@ -735,11 +735,10 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key g_free ( input_key ); if ( ( sym == XKB_KEY_NoSymbol ) && ( last_sym != XKB_KEY_NoSymbol ) ) { - sym = last_sym; + sym = last_sym; modmask = last_modmask; } - if ( error_msg ) { char *name = g_markup_escape_text ( combo, -1 ); g_string_append_printf ( str, "Cannot understand the key combination: %s\n", name ); diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 488aa203..ba9538db 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -36,6 +36,7 @@ #include "rofi.h" #include "settings.h" #include "theme.h" +#include "css-colors.h" #include "widgets/widget-internal.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); } 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 ) { widget wid; @@ -875,7 +916,7 @@ START_TEST ( test_core_properties_error ) rofi_theme_parse_string ( " * { test: cmky(a,e,3); }"); const char *errstr = "Error while parsing theme: * { test: cmky(a,e,3); }\n"\ " Parser error: syntax error, unexpected invalid property value\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_str_eq ( error_msg->str, errstr ); 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_cmyk); 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 ); } { From 30fb8c514ed6eaf223ab6c79929a5745d7280b99 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 16 May 2017 21:55:52 +0200 Subject: [PATCH 24/36] Change ARGB to RGBA, fix in theme converter --- doc/default_theme.rasi | 14 +-- doc/old-theme-convert-input.theme | 169 +++--------------------------- doc/old-theme-convert-output.rasi | 50 ++++----- include/default-theme.h | 12 +-- lexer/theme-lexer.l | 61 +++++++---- source/rofi.c | 19 ++-- source/theme.c | 42 +++++--- test/theme-parser-test.c | 30 +++++- themes/Adapta-Nokto.rasi | 48 ++++----- themes/Arc.rasi | 34 +++--- themes/DarkBlue.rasi | 36 +++---- themes/Indego.rasi | 48 ++++----- themes/Monokai.rasi | 48 ++++----- themes/Paper.rasi | 48 ++++----- themes/android_notification.rasi | 46 ++++---- themes/arthur.rasi | 2 +- themes/blue.rasi | 32 +++--- themes/c64.rasi | 46 ++++---- themes/glue_pro_blue.rasi | 38 +++---- themes/gruvbox-dark-hard.rasi | 48 ++++----- themes/gruvbox-dark-soft.rasi | 48 ++++----- themes/gruvbox-dark.rasi | 48 ++++----- themes/gruvbox-light-hard.rasi | 48 ++++----- themes/gruvbox-light-soft.rasi | 48 ++++----- themes/gruvbox-light.rasi | 48 ++++----- themes/lb.rasi | 38 +++---- themes/paper-float.rasi | 46 ++++---- themes/purple.rasi | 46 ++++---- themes/sidebar.rasi | 2 +- themes/solarized.rasi | 48 ++++----- themes/solarized_alternate.rasi | 46 ++++---- 31 files changed, 627 insertions(+), 710 deletions(-) diff --git a/doc/default_theme.rasi b/doc/default_theme.rasi index 4f17f684..31ebf297 100644 --- a/doc/default_theme.rasi +++ b/doc/default_theme.rasi @@ -1,22 +1,22 @@ * { - foreground: #FF002B36; + foreground: rgba ( 0, 43, 54, 255 ); selected-normal-foreground: @lightbg; normal-foreground: @foreground; - red: #FFDC322F; + red: rgba ( 220, 50, 47, 255 ); alternate-normal-background: @lightbg; - blue: #FF268BD2; + blue: rgba ( 38, 139, 210, 255 ); selected-urgent-foreground: @background; urgent-foreground: @red; alternate-urgent-background: @lightbg; active-foreground: @blue; - lightbg: #FFEEE8D5; + lightbg: rgba ( 238, 232, 213, 255 ); selected-active-foreground: @background; alternate-normal-foreground: @foreground; alternate-active-background: @lightbg; bordercolor: @foreground; - background: #FFFDF6E3; + background: rgba ( 253, 246, 227, 255 ); normal-background: @background; - lightfg: #FF586875; + lightfg: rgba ( 88, 104, 117, 255 ); selected-normal-background: @lightfg; separatorcolor: @foreground; spacing: 2; @@ -30,7 +30,7 @@ #window { border: 1; foreground: @foreground; - background: #00000000; + background: rgba ( 0, 0, 0, 0 ); padding: 5; } #window.box { diff --git a/doc/old-theme-convert-input.theme b/doc/old-theme-convert-input.theme index a3f19d73..eb4d2d4d 100644 --- a/doc/old-theme-convert-input.theme +++ b/doc/old-theme-convert-input.theme @@ -1,154 +1,15 @@ -background: rgba(0,0,0,0.0); -foreground: rgba(1,1,1,1); -font: "Ubuntu Mono 15"; -padding: 0; -spacing: 0em; - -#window.mainbox.inputbar.box { - padding: 5px 30px 5px 30px; - -} -#window.mainbox.inputbar { - background: #88003300; - foreground: #FFFFFF; - padding: 0px; - end: false; -} -#mainbox.inputbar.entry { - padding: 0px; - border: 0px; -} -#mainbox.inputbar.prompt { - padding: 0px; -} -#mainbox.inputbar.case-indicator -{ - padding: 0px; - border: 0px; - end: true; -} - -#window.mainbox.listview { - fixed-height: true; - border: 1px 1px 1px 1px; - spacing: 0px; - reverse: false; -} -#window.mainbox.listview.element { - border: 1px; - background: #22000000; - padding: 5px; -} -#window.mainbox.inputbar.entry normal.normal { - background: #00000000; - foreground: #FFFFFF; - padding: 0px; -} -#window.mainbox.inputbar.prompt normal.normal { - background: #00000000; - foreground: #FFFFFF; - padding: 0px; -} -#window.mainbox.inputbar.case-indicator normal.normal { - background: #00000000; - foreground: #FFFFFF; - padding: 0px; -} - -#window.mainbox.inputbar.separator { - background: #FF0000; - foreground: #FFFFFF; - padding: 0px; - end: false; -} - -#window.mainbox.box { - foreground: #ffffff; - background: #aaFFFFFF; - border: 2px dash 2px dash 0px 2px dash; -} -#window.mainbox { - background: #00000000; - padding: 0px; - border: 0px; - foreground: #ffffff; -} - -#window.mainbox.listview.element normal.normal { - foreground: #002b36; -} -#window.mainbox.listview.element selected.normal { - foreground: #ffffff; - background: #770000f5; -} -#window.mainbox.listview.element alternate.normal { - foreground: #002b36; -} -#window.mainbox.listview.element normal.urgent { - foreground: #473f00; -} -#window.mainbox.listview.element selected.urgent { - background: #aa673f00; - foreground: #ffffff; -} -#window.mainbox.listview.element alternate.urgent { - foreground: #473f00; -} -#window.mainbox.listview.element normal.active { - foreground: #005f87; -} -#window.mainbox.listview.element selected.active { - background: #aa008fa7; - foreground: #FFFFFF; -} -#window.mainbox.listview.element alternate.active { - foreground: #005f87; -} -/** - * Override the sidebar button - * Change color of text on selected. - */ -#sidebar.button normal { - foreground: #444444; -} -#sidebar.button selected { - foreground: #4271ae; -} - -#window.mainbox.listview { - scrollbar: true; - scrollbar-width: 5px; - padding: 30px 30px 5px 30px; - spacing: 0em; - dynamic: true; - border: 0px; - fixed-height: true; - border: 2px 0px 0px 0px; -} -#window.mainbox.listview.scrollbar { - border: 1px 1px 1px 0px; - foreground: #000000; - background: #88003300; - padding: 2px; -} -#window.mainbox.listview.scrollbar handle { - foreground: #d75f00; - padding: 2px; -} - -#window { - border: 4px 4px 0px 4px; - padding: 5% 5% 0% 5%; - border-width: 2; - transparency: "real"; - background: #aa000000; - foreground: #aaaaaa; -} -#window.message.textbox { - foreground: #000000; - border: 1px; - padding: 10px; -} -#window.message { - end: false; -} +! ------------------------------------------------------------------------------ +! ROFI Color theme +! User: qball +! Copyright: Dave Davenport +! ------------------------------------------------------------------------------ +! "Color scheme for normal row" Set from: File +rofi.color-normal: argb:00000000, #dbdfbc, argb:00000000, #dbdfbc, #02143f +! "Color scheme for urgent row" Set from: File +rofi.color-urgent: argb:00000000, #ff81ff, argb:00000000, #ff817f, #02143f +! "Color scheme for active row" Set from: File +rofi.color-active: argb:00000000, #8ac4ff, argb:00000000, #8ac4ff, #02143f +! "Color scheme window" Set from: File +rofi.color-window: argb:dd000021, #dbdfbc, #dbdfbc +! "Separator style (none, dash, solid)" Set from: XResources +rofi.separator-style: solid diff --git a/doc/old-theme-convert-output.rasi b/doc/old-theme-convert-output.rasi index 4f17f684..d65afc01 100644 --- a/doc/old-theme-convert-output.rasi +++ b/doc/old-theme-convert-output.rasi @@ -1,36 +1,36 @@ * { - foreground: #FF002B36; - selected-normal-foreground: @lightbg; + foreground: rgba ( 219, 223, 188, 100 % ); + selected-normal-foreground: rgba ( 2, 20, 63, 100 % ); normal-foreground: @foreground; - red: #FFDC322F; - alternate-normal-background: @lightbg; - blue: #FF268BD2; - selected-urgent-foreground: @background; - urgent-foreground: @red; - alternate-urgent-background: @lightbg; - active-foreground: @blue; - lightbg: #FFEEE8D5; - selected-active-foreground: @background; + red: rgba ( 220, 50, 47, 100 % ); + alternate-normal-background: rgba ( 0, 0, 0, 0 % ); + blue: rgba ( 38, 139, 210, 100 % ); + selected-urgent-foreground: rgba ( 2, 20, 63, 100 % ); + urgent-foreground: rgba ( 255, 129, 255, 100 % ); + alternate-urgent-background: rgba ( 0, 0, 0, 0 % ); + active-foreground: rgba ( 138, 196, 255, 100 % ); + lightbg: rgba ( 238, 232, 213, 100 % ); + selected-active-foreground: rgba ( 2, 20, 63, 100 % ); alternate-normal-foreground: @foreground; - alternate-active-background: @lightbg; - bordercolor: @foreground; - background: #FFFDF6E3; - normal-background: @background; - lightfg: #FF586875; - selected-normal-background: @lightfg; - separatorcolor: @foreground; + alternate-active-background: rgba ( 0, 0, 0, 0 % ); + bordercolor: rgba ( 219, 223, 188, 100 % ); + background: rgba ( 0, 0, 33, 87 % ); + normal-background: rgba ( 0, 0, 0, 0 % ); + lightfg: rgba ( 88, 104, 117, 100 % ); + selected-normal-background: rgba ( 219, 223, 188, 100 % ); + separatorcolor: rgba ( 219, 223, 188, 100 % ); spacing: 2; - urgent-background: @background; - alternate-urgent-foreground: @red; - selected-urgent-background: @red; - alternate-active-foreground: @blue; - selected-active-background: @blue; - active-background: @background; + urgent-background: rgba ( 0, 0, 0, 0 % ); + alternate-urgent-foreground: @urgent-foreground; + selected-urgent-background: rgba ( 255, 129, 127, 100 % ); + alternate-active-foreground: @active-foreground; + selected-active-background: rgba ( 138, 196, 255, 100 % ); + active-background: rgba ( 0, 0, 0, 0 % ); } #window { border: 1; foreground: @foreground; - background: #00000000; + background: rgba ( 0, 0, 0, 0 % ); padding: 5; } #window.box { diff --git a/include/default-theme.h b/include/default-theme.h index 516459e1..3ad0dcbd 100644 --- a/include/default-theme.h +++ b/include/default-theme.h @@ -31,14 +31,14 @@ const char *default_theme = "* {" " spacing: 2;" - " background: #FFFDF6E3;" - " foreground: #FF002B36;" + " background: #FDF6E3FF;" + " foreground: #002B36FF;" " bordercolor: @foreground;" " separatorcolor: @foreground;" - " red: #FFDC322F;" - " blue: #FF268BD2;" - " lightbg: #FFEEE8D5;" - " lightfg: #FF586875;" + " red: #DC322FFF;" + " blue: #268BD2FF;" + " lightbg: #EEE8D5FF;" + " lightfg: #586875FF;" " normal-foreground: @foreground;" " normal-background: @background;" " urgent-foreground: @red;" diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 72d569c7..36fbccab 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -37,6 +37,7 @@ #include #include #include +#include #include "rofi.h" #include "theme.h" @@ -84,6 +85,21 @@ GQueue *queue = NULL; ParseObject *current = NULL; static char * rofi_theme_parse_prepare_file ( const char *file, const char *parent_file ); + + +static double rofi_theme_parse_convert_hex ( char high, char low) +{ + uint8_t retv = 0; + + int t = toupper(high); + t = ( t > '9')? (t-'A'+10):(t-'0'); + retv = t<<4; + t = toupper ( low ); + t = ( t > '9')? (t-'A'+10):(t-'0'); + retv +=t; + return retv/255.0; +} + %} %{ @@ -388,39 +404,38 @@ if ( queue == NULL ){ * Other schemes are done at yacc level. */ #{HEX}{8} { - union { unsigned int val; struct { unsigned char b,g,r,a;};} val; - val.val = (unsigned int)strtoull ( &yytext[1], NULL, 16); - yylval->colorval.alpha = val.a/255.0; - yylval->colorval.red = val.r/255.0; - yylval->colorval.green = val.g/255.0; - yylval->colorval.blue = val.b/255.0; + yylval->colorval.red = rofi_theme_parse_convert_hex(yytext[1],yytext[2]); + yylval->colorval.green = rofi_theme_parse_convert_hex(yytext[3],yytext[4]); + yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[5],yytext[6]); + yylval->colorval.alpha = rofi_theme_parse_convert_hex(yytext[7],yytext[8]); return T_COLOR; } #{HEX}{6} { - union { unsigned int val; struct { unsigned char b,g,r,a;};} val; - val.val = (unsigned int)g_ascii_strtoull ( &yytext[1], NULL, 16); yylval->colorval.alpha = 1.0; - yylval->colorval.red = val.r/255.0; - yylval->colorval.green = val.g/255.0; - yylval->colorval.blue = val.b/255.0; + yylval->colorval.red = rofi_theme_parse_convert_hex(yytext[1],yytext[2]); + yylval->colorval.green = rofi_theme_parse_convert_hex(yytext[3],yytext[4]); + yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[5],yytext[6]); return T_COLOR; } #{HEX}{3} { - union { uint16_t val; struct { unsigned char b:4,g:4,r:4,a :4;};} val; - val.val = (uint16_t )g_ascii_strtoull ( &yytext[1], NULL, 16); yylval->colorval.alpha = 1.0; - yylval->colorval.red = val.r/15.0; - yylval->colorval.green = val.g/15.0; - yylval->colorval.blue = val.b/15.0; + yylval->colorval.red = rofi_theme_parse_convert_hex(yytext[1],yytext[1]); + yylval->colorval.green = rofi_theme_parse_convert_hex(yytext[2],yytext[2]); + yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[3],yytext[3]); return T_COLOR; } -argb:{HEX}{1,8} { - union { unsigned int val; struct { unsigned char b,g,r,a;};} val; - val.val = (unsigned int)strtoull ( &yytext[5], NULL, 16); - yylval->colorval.alpha = val.a/255.0; - yylval->colorval.red = val.r/255.0; - yylval->colorval.green = val.g/255.0; - yylval->colorval.blue = val.b/255.0; +#{HEX}{4} { + yylval->colorval.alpha = rofi_theme_parse_convert_hex(yytext[4],yytext[4]); + yylval->colorval.red = rofi_theme_parse_convert_hex(yytext[1],yytext[1]); + yylval->colorval.green = rofi_theme_parse_convert_hex(yytext[2],yytext[2]); + yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[3],yytext[3]); + return T_COLOR; +} +argb:{HEX}{8} { + yylval->colorval.alpha = rofi_theme_parse_convert_hex(yytext[5],yytext[6]); + yylval->colorval.red = rofi_theme_parse_convert_hex(yytext[7],yytext[8]); + yylval->colorval.green = rofi_theme_parse_convert_hex(yytext[9],yytext[10]); + yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[11],yytext[12]); return T_COLOR; } /* Color schemes */ diff --git a/source/rofi.c b/source/rofi.c index 4ca2460e..e802f0ed 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1148,17 +1148,16 @@ int main ( int argc, char *argv[] ) // Load in config from X resources. config_parse_xresource_options ( xcb ); config_parse_xresource_options_file ( config_path ); - - find_arg_str ( "-theme", &( config.theme ) ); - if ( config.theme ) { - TICK_N ( "Parse theme" ); - if ( rofi_theme_parse_file ( config.theme ) ) { - // TODO: instantiate fallback theme.? - rofi_theme_free ( rofi_theme ); - rofi_theme = NULL; - } - TICK_N ( "Parsed theme" ); + } + find_arg_str ( "-theme", &( config.theme ) ); + if ( config.theme ) { + TICK_N ( "Parse theme" ); + if ( rofi_theme_parse_file ( config.theme ) ) { + // TODO: instantiate fallback theme.? + rofi_theme_free ( rofi_theme ); + rofi_theme = NULL; } + TICK_N ( "Parsed theme" ); } // Parse command line for settings, independent of other -no-config. config_parse_cmd_options ( ); diff --git a/source/theme.c b/source/theme.c index 985d62c2..03f3e859 100644 --- a/source/theme.c +++ b/source/theme.c @@ -173,11 +173,11 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p printf ( "italic " ); } if ( p->value.highlight.style & HL_COLOR ) { - printf ( "#%02X%02X%02X%02X", - (unsigned char) ( p->value.highlight.color.alpha * 255.0 ), - (unsigned char) ( p->value.highlight.color.red * 255.0 ), - (unsigned char) ( p->value.highlight.color.green * 255.0 ), - (unsigned char) ( p->value.highlight.color.blue * 255.0 ) ); + printf ( "rgba ( %.0f, %.0f, %.0f, %.0f %% )", + ( p->value.highlight.color.red * 255.0 ), + ( p->value.highlight.color.green * 255.0 ), + ( p->value.highlight.color.blue * 255.0 ), + ( p->value.highlight.color.alpha * 100.0 ) ); } printf ( ";" ); break; @@ -197,11 +197,11 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p printf ( "%s;", p->value.b ? "true" : "false" ); break; case P_COLOR: - printf ( "#%02X%02X%02X%02X;", - (unsigned char) ( p->value.color.alpha * 255.0 ), - (unsigned char) ( p->value.color.red * 255.0 ), - (unsigned char) ( p->value.color.green * 255.0 ), - (unsigned char) ( p->value.color.blue * 255.0 ) ); + printf ( "rgba ( %.0f, %.0f, %.0f, %.0f %% );", + ( p->value.color.red * 255.0 ), + ( p->value.color.green * 255.0 ), + ( p->value.color.blue * 255.0 ), + ( p->value.color.alpha * 100.0 ) ); break; case P_PADDING: if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) && @@ -635,6 +635,20 @@ gboolean rofi_theme_is_empty ( void ) #ifdef THEME_CONVERTER +static char * rofi_theme_convert_color ( char *col ) +{ + char *r = g_strstrip ( col ); + if ( *r == '#' && strlen ( r ) == 9 ) { + char t1 = r[7]; + char t2 = r[8]; + r[7] = r[1]; + r[8] = r[2]; + r[1] = t1; + r[2] = t2; + } + + return r; +} void rofi_theme_convert_old ( void ) { if ( config.color_window ) { @@ -645,7 +659,7 @@ void rofi_theme_convert_old ( void ) "* { separatorcolor: %s; }" }; for ( int i = 0; retv && retv[i] && i < 3; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } @@ -661,7 +675,7 @@ void rofi_theme_convert_old ( void ) "* { selected-normal-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } @@ -677,7 +691,7 @@ void rofi_theme_convert_old ( void ) "* { selected-urgent-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } @@ -693,7 +707,7 @@ void rofi_theme_convert_old ( void ) "* { selected-active-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index ba9538db..fc95f5f0 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -457,12 +457,39 @@ START_TEST ( test_properties_color_h6 ) } END_TEST +START_TEST ( test_properties_color_h4 ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { red: #F003; green: #0F02; blue: #00F1; }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.2 ); + ck_assert_double_eq ( p->value.color.red , 1 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "green", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1/7.5 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 1 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "blue", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1/15.0 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 1 ); +} +END_TEST START_TEST ( test_properties_color_h8 ) { widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { red: #33FF0000; green: #2200FF00; blue: #110000FF; }"); + rofi_theme_parse_string ( "* { red: #FF000033; green: #00FF0022; blue: #0000FF11; }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); ck_assert_ptr_nonnull ( p ); @@ -997,6 +1024,7 @@ static Suite * theme_parser_suite (void) TCase *tc_prop_color = tcase_create("PropertiesColor"); tcase_add_checked_fixture(tc_prop_color, theme_parser_setup, theme_parser_teardown); tcase_add_test ( tc_prop_color, test_properties_color_h3); + tcase_add_test ( tc_prop_color, test_properties_color_h4); tcase_add_test ( tc_prop_color, test_properties_color_h6); tcase_add_test ( tc_prop_color, test_properties_color_h8); tcase_add_test ( tc_prop_color, test_properties_color_rgb); diff --git a/themes/Adapta-Nokto.rasi b/themes/Adapta-Nokto.rasi index 8dd4bc38..0738fb5d 100644 --- a/themes/Adapta-Nokto.rasi +++ b/themes/Adapta-Nokto.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FFC3C6C8; + foreground: #C3C6C8FF; padding: 5; - background: #FF3A4C54; + background: #3A4C54FF; } #window.mainbox { border: 0; @@ -23,8 +23,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFFAFBFC; - background: #FF455A64; + foreground: #FAFBFCFF; + background: #455A64FF; } #window.mainbox.listview { fixed-height: 1; @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFFAFBFC; - background: #FF455A64; + foreground: #FAFBFCFF; + background: #455A64FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFF5252; - background: #FF455A64; + foreground: #FF5252FF; + background: #455A64FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF00BCD4; - background: #FF455A64; + foreground: #00BCD4FF; + background: #455A64FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFFAFBFC; - background: #FF00BCD4; + foreground: #FAFBFCFF; + background: #00BCD4FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFDF6E3; - background: #FFFF5252; + foreground: #FDF6E3FF; + background: #FF5252FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFFDF6E3; - background: #FF009688; + foreground: #FDF6E3FF; + background: #009688FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFFAFBFC; - background: #FF455A64; + foreground: #FAFBFCFF; + background: #455A64FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFF5252; - background: #FF455A64; + foreground: #FF5252FF; + background: #455A64FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF00BCD4; - background: #FF455A64; + foreground: #00BCD4FF; + background: #455A64FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFFAFBFC; - background: #FF455A64; + foreground: #FAFBFCFF; + background: #455A64FF; } diff --git a/themes/Arc.rasi b/themes/Arc.rasi index b58be36b..dfdbd476 100644 --- a/themes/Arc.rasi +++ b/themes/Arc.rasi @@ -10,7 +10,7 @@ } #window { border: 2; - foreground: #FFF5F5F5; + foreground: #F5F5F5FF; padding: 5; background: #FFFFFFFF; } @@ -23,7 +23,7 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF525D76; + foreground: #525D76FF; background: #FFFFFFFF; } #window.mainbox.listview { @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF525D76; + foreground: #525D76FF; background: #FFFFFFFF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFDC322F; + foreground: #DC322FFF; background: #FFFFFFFF; } #window.mainbox.listview.element.normal.active { - foreground: #FFC2CAD0; + foreground: #C2CAD0FF; background: #FFFFFFFF; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #FF5294E2; + background: #5294E2FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFDC322F; - background: #FF5294E2; + foreground: #DC322FFF; + background: #5294E2FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFC2CAD0; - background: #FF5294E2; + foreground: #C2CAD0FF; + background: #5294E2FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF525D76; - background: #FFF5F5F5; + foreground: #525D76FF; + background: #F5F5F5FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFDC322F; - background: #FFF5F5F5; + foreground: #DC322FFF; + background: #F5F5F5FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FFC2CAD0; - background: #FFF5F5F5; + foreground: #C2CAD0FF; + background: #F5F5F5FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF525D76; + foreground: #525D76FF; background: #FFFFFFFF; } diff --git a/themes/DarkBlue.rasi b/themes/DarkBlue.rasi index 5f6bdd3d..f7f0357b 100644 --- a/themes/DarkBlue.rasi +++ b/themes/DarkBlue.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FFDBDFBC; + foreground: #DBDFBCFF; padding: 5; - background: #DD000021; + background: #000021DD; } #window.mainbox { border: 0; @@ -23,7 +23,7 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFDBDFBC; + foreground: #DBDFBCFF; background: #00000000; } #window.mainbox.listview { @@ -36,39 +36,39 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFDBDFBC; + foreground: #DBDFBCFF; background: #00000000; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFF81FF; + foreground: #FF81FFFF; background: #00000000; } #window.mainbox.listview.element.normal.active { - foreground: #FF8AC4FF; + foreground: #8AC4FFFF; background: #00000000; } #window.mainbox.listview.element.selected.normal { - foreground: #FF02143F; - background: #FFDBDFBC; + foreground: #02143FFF; + background: #DBDFBCFF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF02143F; - background: #FFFF817F; + foreground: #02143FFF; + background: #FF817FFF; } #window.mainbox.listview.element.selected.active { - foreground: #FF02143F; - background: #FF8AC4FF; + foreground: #02143FFF; + background: #8AC4FFFF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFDBDFBC; + foreground: #DBDFBCFF; background: #00000000; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFF81FF; + foreground: #FF81FFFF; background: #00000000; } #window.mainbox.listview.element.alternate.active { - foreground: #FF8AC4FF; + foreground: #8AC4FFFF; background: #00000000; } #window.mainbox.listview.scrollbar { @@ -80,8 +80,8 @@ } #window.mainbox.sidebar.button selected{ border: 2px 0px 0px ; - foreground: #FF02143F; - background: #FFDBDFBC; + foreground: #02143FFF; + background: #DBDFBCFF; } #window.mainbox.inputbar { spacing: 0; @@ -89,6 +89,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFDBDFBC; + foreground: #DBDFBCFF; background: #00000000; } diff --git a/themes/Indego.rasi b/themes/Indego.rasi index ea74ed68..04cec9c5 100644 --- a/themes/Indego.rasi +++ b/themes/Indego.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FFE8EAF6; + foreground: #E8EAF6FF; padding: 5; - background: #FF1A237E; + background: #1A237EFF; } #window.mainbox { border: 0; @@ -23,8 +23,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFE8EAF6; - background: #007986CB; + foreground: #E8EAF6FF; + background: #7986CB00; } #window.mainbox.listview { fixed-height: 1; @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFE8EAF6; - background: #007986CB; + foreground: #E8EAF6FF; + background: #7986CB00; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFFCDD2; - background: #00FDF6E3; + foreground: #FFCDD2FF; + background: #FDF6E300; } #window.mainbox.listview.element.normal.active { - foreground: #FFB2EBF2; - background: #00FDF6E3; + foreground: #B2EBF2FF; + background: #FDF6E300; } #window.mainbox.listview.element.selected.normal { - foreground: #FFE8EAF6; - background: #FF3F51B5; + foreground: #E8EAF6FF; + background: #3F51B5FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFB71C1C; - background: #FFFFCDD2; + foreground: #B71C1CFF; + background: #FFCDD2FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF006064; - background: #FFB2EBF2; + foreground: #006064FF; + background: #B2EBF2FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFE8EAF6; - background: #FF283593; + foreground: #E8EAF6FF; + background: #283593FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFFCDD2; - background: #FFB71C1C; + foreground: #FFCDD2FF; + background: #B71C1CFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FFB2EBF2; - background: #FF006064; + foreground: #B2EBF2FF; + background: #006064FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFE8EAF6; - background: #007986CB; + foreground: #E8EAF6FF; + background: #7986CB00; } diff --git a/themes/Monokai.rasi b/themes/Monokai.rasi index b1b0072e..98349dab 100644 --- a/themes/Monokai.rasi +++ b/themes/Monokai.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FFE6DB74; + foreground: #E6DB74FF; padding: 5; - background: #EE272822; + background: #272822EE; } #window.mainbox { border: 0; @@ -23,8 +23,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFF8F8F2; - background: #00272822; + foreground: #F8F8F2FF; + background: #27282200; } #window.mainbox.listview { fixed-height: 1; @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFF8F8F2; - background: #00272822; + foreground: #F8F8F2FF; + background: #27282200; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFF92672; - background: #00272822; + foreground: #F92672FF; + background: #27282200; } #window.mainbox.listview.element.normal.active { - foreground: #FFA6E22A; - background: #00272822; + foreground: #A6E22AFF; + background: #27282200; } #window.mainbox.listview.element.selected.normal { - foreground: #FFF8F8F2; - background: #FF141411; + foreground: #F8F8F2FF; + background: #141411FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFF8F8F2; - background: #FFF92672; + foreground: #F8F8F2FF; + background: #F92672FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFA6E22A; - background: #FF141411; + foreground: #A6E22AFF; + background: #141411FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFF8F8F2; - background: #00272822; + foreground: #F8F8F2FF; + background: #27282200; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFF92672; - background: #00272822; + foreground: #F92672FF; + background: #27282200; } #window.mainbox.listview.element.alternate.active { - foreground: #FFA6E22A; - background: #00272822; + foreground: #A6E22AFF; + background: #27282200; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFF8F8F2; - background: #00272822; + foreground: #F8F8F2FF; + background: #27282200; } diff --git a/themes/Paper.rasi b/themes/Paper.rasi index 2622d809..005cb88a 100644 --- a/themes/Paper.rasi +++ b/themes/Paper.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FF444444; + foreground: #444444FF; padding: 5; - background: #FFF5F5F5; + background: #F5F5F5FF; } #window.mainbox { border: 0; @@ -23,8 +23,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF002B36; - background: #00F5F5F5; + foreground: #002B36FF; + background: #F5F5F500; } #window.mainbox.listview { fixed-height: 1; @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF002B36; - background: #00F5F5F5; + foreground: #002B36FF; + background: #F5F5F500; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFD75F00; - background: #FFF5F5F5; + foreground: #D75F00FF; + background: #F5F5F5FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF005F87; - background: #FFF5F5F5; + foreground: #005F87FF; + background: #F5F5F5FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFF5F5F5; - background: #FF4271AE; + foreground: #F5F5F5FF; + background: #4271AEFF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFF5F5F5; - background: #FFD75F00; + foreground: #F5F5F5FF; + background: #D75F00FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFF5F5F5; - background: #FF005F87; + foreground: #F5F5F5FF; + background: #005F87FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF002B36; - background: #FFD0D0D0; + foreground: #002B36FF; + background: #D0D0D0FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFD75F00; - background: #FFD0D0D0; + foreground: #D75F00FF; + background: #D0D0D0FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF005F87; - background: #FFD0D0D0; + foreground: #005F87FF; + background: #D0D0D0FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF002B36; - background: #00F5F5F5; + foreground: #002B36FF; + background: #F5F5F500; } diff --git a/themes/android_notification.rasi b/themes/android_notification.rasi index 3cda7abf..6a5eeca5 100644 --- a/themes/android_notification.rasi +++ b/themes/android_notification.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF1E2529; + foreground: #1E2529FF; padding: 5; - background: #FF273238; + background: #273238FF; } #window.mainbox { border: 0; @@ -22,8 +22,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFC1C1C1; - background: #FF273238; + foreground: #C1C1C1FF; + background: #273238FF; } #window.mainbox.listview { fixed-height: 1; @@ -35,40 +35,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFC1C1C1; - background: #FF273238; + foreground: #C1C1C1FF; + background: #273238FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFF1844; - background: #FF273238; + foreground: #FF1844FF; + background: #273238FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF80CBC4; - background: #FF273238; + foreground: #80CBC4FF; + background: #273238FF; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #FF394249; + background: #394249FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFF1844; - background: #FF394249; + foreground: #FF1844FF; + background: #394249FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF80CBC4; - background: #FF394249; + foreground: #80CBC4FF; + background: #394249FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFC1C1C1; - background: #FF273238; + foreground: #C1C1C1FF; + background: #273238FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFF1844; - background: #FF273238; + foreground: #FF1844FF; + background: #273238FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF80CBC4; - background: #FF273238; + foreground: #80CBC4FF; + background: #273238FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -83,6 +83,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFC1C1C1; - background: #FF273238; + foreground: #C1C1C1FF; + background: #273238FF; } diff --git a/themes/arthur.rasi b/themes/arthur.rasi index 3d9dc112..e678df6c 100644 --- a/themes/arthur.rasi +++ b/themes/arthur.rasi @@ -50,7 +50,7 @@ border: 1px; border-radius: 15px; foreground: @magenta; - background: #cc1c1c1c; + background: #1c1c1ccc; } diff --git a/themes/blue.rasi b/themes/blue.rasi index 91601228..df4e6374 100644 --- a/themes/blue.rasi +++ b/themes/blue.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #FF00B0EF; + foreground: #00B0EFFF; padding: 5; - background: #EE0060A0; + background: #0060A0EE; } #window.mainbox { border: 0; @@ -23,7 +23,7 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF00B0EF; + foreground: #00B0EFFF; background: #00000000; } #window.mainbox.listview { @@ -36,39 +36,39 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF00B0EF; + foreground: #00B0EFFF; background: #00000000; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFFA0A0; + foreground: #FFA0A0FF; background: #00000000; } #window.mainbox.listview.element.normal.active { - foreground: #FFA0FFA0; + foreground: #A0FFA0FF; background: #00000000; } #window.mainbox.listview.element.selected.normal { - foreground: #FF0060A0; - background: #FF00B0EF; + foreground: #0060A0FF; + background: #00B0EFFF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF0060A0; - background: #FFFFA0A0; + foreground: #0060A0FF; + background: #FFA0A0FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF0060A0; - background: #FFA0FFA0; + foreground: #0060A0FF; + background: #A0FFA0FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF00B0EF; + foreground: #00B0EFFF; background: #00000000; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFFA0A0; + foreground: #FFA0A0FF; background: #00000000; } #window.mainbox.listview.element.alternate.active { - foreground: #FFA0FFA0; + foreground: #A0FFA0FF; background: #00000000; } #window.mainbox.listview.scrollbar { @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF00B0EF; + foreground: #00B0EFFF; background: #00000000; } diff --git a/themes/c64.rasi b/themes/c64.rasi index d6d34b13..61f6bf52 100644 --- a/themes/c64.rasi +++ b/themes/c64.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF4F80FF; + foreground: #4F80FFFF; padding: 5; - background: #FF0039FF; + background: #0039FFFF; } #window.mainbox { border: 0; @@ -22,8 +22,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF4F80FF; - background: #FF0039FF; + foreground: #4F80FFFF; + background: #0039FFFF; } #window.mainbox.listview { fixed-height: 1; @@ -35,40 +35,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF4F80FF; - background: #FF0039FF; + foreground: #4F80FFFF; + background: #0039FFFF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFF7047; - background: #FF0039FF; + foreground: #FF7047FF; + background: #0039FFFF; } #window.mainbox.listview.element.normal.active { - foreground: #FF68BA50; - background: #FF0039FF; + foreground: #68BA50FF; + background: #0039FFFF; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #FF4F80FF; + background: #4F80FFFF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFF7047; - background: #FF4F80FF; + foreground: #FF7047FF; + background: #4F80FFFF; } #window.mainbox.listview.element.selected.active { - foreground: #FF68BA50; - background: #FF4F80FF; + foreground: #68BA50FF; + background: #4F80FFFF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF4F80FF; - background: #FF0039FF; + foreground: #4F80FFFF; + background: #0039FFFF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFF7047; - background: #FF0039FF; + foreground: #FF7047FF; + background: #0039FFFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF68BA50; - background: #FF0039FF; + foreground: #68BA50FF; + background: #0039FFFF; } #window.mainbox.listview.scrollbar { border: 0; @@ -83,6 +83,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF4F80FF; - background: #FF0039FF; + foreground: #4F80FFFF; + background: #0039FFFF; } diff --git a/themes/glue_pro_blue.rasi b/themes/glue_pro_blue.rasi index 1ed613fa..883d4fa1 100644 --- a/themes/glue_pro_blue.rasi +++ b/themes/glue_pro_blue.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF268BD2; + foreground: #268BD2FF; padding: 5; - background: #FF393939; + background: #393939FF; } #window.mainbox { border: 0; @@ -23,7 +23,7 @@ } #window.mainbox.message.normal { foreground: #FFFFFFFF; - background: #FF393939; + background: #393939FF; } #window.mainbox.listview { fixed-height: 1; @@ -36,39 +36,39 @@ } #window.mainbox.listview.element.normal.normal { foreground: #FFFFFFFF; - background: #FF393939; + background: #393939FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFF3843D; - background: #FF393939; + foreground: #F3843DFF; + background: #393939FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF268BD2; - background: #FF393939; + foreground: #268BD2FF; + background: #393939FF; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #FF268BD2; + background: #268BD2FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFFC39C; - background: #FF268BD2; + foreground: #FFC39CFF; + background: #268BD2FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF205171; - background: #FF268BD2; + foreground: #205171FF; + background: #268BD2FF; } #window.mainbox.listview.element.alternate.normal { foreground: #FFFFFFFF; - background: #FF393939; + background: #393939FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFF3843D; - background: #FF393939; + foreground: #F3843DFF; + background: #393939FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF268BD2; - background: #FF393939; + foreground: #268BD2FF; + background: #393939FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,5 +84,5 @@ } #window.mainbox.inputbar.normal { foreground: #FFFFFFFF; - background: #FF393939; + background: #393939FF; } diff --git a/themes/gruvbox-dark-hard.rasi b/themes/gruvbox-dark-hard.rasi index eed3eb8b..b06c6ad1 100644 --- a/themes/gruvbox-dark-hard.rasi +++ b/themes/gruvbox-dark-hard.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FFA89984; + foreground: #A89984FF; padding: 5; - background: #FF1D2021; + background: #1D2021FF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFEBDBB2; - background: #FF1D2021; + foreground: #EBDBB2FF; + background: #1D2021FF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFEBDBB2; - background: #FF1D2021; + foreground: #EBDBB2FF; + background: #1D2021FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FF1D2021; - background: #FFCC241D; + foreground: #1D2021FF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FF1D2021; - background: #FFD79921; + foreground: #1D2021FF; + background: #D79921FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFFBF1C7; - background: #FF504945; + foreground: #FBF1C7FF; + background: #504945FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF1D2021; - background: #FFFB4934; + foreground: #1D2021FF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF1D2021; - background: #FFFABD2F; + foreground: #1D2021FF; + background: #FABD2FFF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFEBDBB2; - background: #FF282828; + foreground: #EBDBB2FF; + background: #282828FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FF1D2021; - background: #FFCC241D; + foreground: #1D2021FF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF1D2021; - background: #FFD79921; + foreground: #1D2021FF; + background: #D79921FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFEBDBB2; - background: #FF1D2021; + foreground: #EBDBB2FF; + background: #1D2021FF; } diff --git a/themes/gruvbox-dark-soft.rasi b/themes/gruvbox-dark-soft.rasi index 58cb59e8..9b150a3f 100644 --- a/themes/gruvbox-dark-soft.rasi +++ b/themes/gruvbox-dark-soft.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FFA89984; + foreground: #A89984FF; padding: 5; - background: #FF32302F; + background: #32302FFF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFEBDBB2; - background: #FF32302F; + foreground: #EBDBB2FF; + background: #32302FFF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFEBDBB2; - background: #FF32302F; + foreground: #EBDBB2FF; + background: #32302FFF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FF32302F; - background: #FFCC241D; + foreground: #32302FFF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FF32302F; - background: #FFD79921; + foreground: #32302FFF; + background: #D79921FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFFBF1C7; - background: #FF665C54; + foreground: #FBF1C7FF; + background: #665C54FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF32302F; - background: #FFFB4934; + foreground: #32302FFF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF32302F; - background: #FFFABD2F; + foreground: #32302FFF; + background: #FABD2FFF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFEBDBB2; - background: #FF3C3836; + foreground: #EBDBB2FF; + background: #3C3836FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FF32302F; - background: #FFCC241D; + foreground: #32302FFF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF32302F; - background: #FFD79921; + foreground: #32302FFF; + background: #D79921FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFEBDBB2; - background: #FF32302F; + foreground: #EBDBB2FF; + background: #32302FFF; } diff --git a/themes/gruvbox-dark.rasi b/themes/gruvbox-dark.rasi index 0689d9f2..c02f5ecf 100644 --- a/themes/gruvbox-dark.rasi +++ b/themes/gruvbox-dark.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FFA89984; + foreground: #A89984FF; padding: 5; - background: #FF282828; + background: #282828FF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFEBDBB2; - background: #FF282828; + foreground: #EBDBB2FF; + background: #282828FF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFEBDBB2; - background: #FF282828; + foreground: #EBDBB2FF; + background: #282828FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FF282828; - background: #FFCC241D; + foreground: #282828FF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FF282828; - background: #FFD79921; + foreground: #282828FF; + background: #D79921FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFFBF1C7; - background: #FF665C54; + foreground: #FBF1C7FF; + background: #665C54FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF282828; - background: #FFFB4934; + foreground: #282828FF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF282828; - background: #FFFABD2F; + foreground: #282828FF; + background: #FABD2FFF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFEBDBB2; - background: #FF32302F; + foreground: #EBDBB2FF; + background: #32302FFF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FF282828; - background: #FFCC241D; + foreground: #282828FF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF282828; - background: #FFD79921; + foreground: #282828FF; + background: #D79921FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFEBDBB2; - background: #FF282828; + foreground: #EBDBB2FF; + background: #282828FF; } diff --git a/themes/gruvbox-light-hard.rasi b/themes/gruvbox-light-hard.rasi index 6e76fdc4..bc9acafd 100644 --- a/themes/gruvbox-light-hard.rasi +++ b/themes/gruvbox-light-hard.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FF7C6F64; + foreground: #7C6F64FF; padding: 5; - background: #FFF9F5D7; + background: #F9F5D7FF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF3C3836; - background: #FFF9F5D7; + foreground: #3C3836FF; + background: #F9F5D7FF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF3C3836; - background: #FFF9F5D7; + foreground: #3C3836FF; + background: #F9F5D7FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFDF4C1; - background: #FFCC241D; + foreground: #FDF4C1FF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FFFDF4C1; - background: #FFB57614; + foreground: #FDF4C1FF; + background: #B57614FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FF282828; - background: #FFEBDBB2; + foreground: #282828FF; + background: #EBDBB2FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFDF4C1; - background: #FFFB4934; + foreground: #FDF4C1FF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFFDF4C1; - background: #FFD79921; + foreground: #FDF4C1FF; + background: #D79921FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF3C3836; - background: #FFFBF1C7; + foreground: #3C3836FF; + background: #FBF1C7FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFDF4C1; - background: #FFCC241D; + foreground: #FDF4C1FF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FFFDF4C1; - background: #FFB57614; + foreground: #FDF4C1FF; + background: #B57614FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF3C3836; - background: #FFF9F5D7; + foreground: #3C3836FF; + background: #F9F5D7FF; } diff --git a/themes/gruvbox-light-soft.rasi b/themes/gruvbox-light-soft.rasi index 2ca5b332..25487697 100644 --- a/themes/gruvbox-light-soft.rasi +++ b/themes/gruvbox-light-soft.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FF7C6F64; + foreground: #7C6F64FF; padding: 5; - background: #FFF2E5BC; + background: #F2E5BCFF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF3C3836; - background: #FFF2E5BC; + foreground: #3C3836FF; + background: #F2E5BCFF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF3C3836; - background: #FFF2E5BC; + foreground: #3C3836FF; + background: #F2E5BCFF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFF2E5BC; - background: #FFCC241D; + foreground: #F2E5BCFF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FFF2E5BC; - background: #FFB57614; + foreground: #F2E5BCFF; + background: #B57614FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FF282828; - background: #FFD5C4A1; + foreground: #282828FF; + background: #D5C4A1FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFF2E5BC; - background: #FFFB4934; + foreground: #F2E5BCFF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFF2E5BC; - background: #FFD79921; + foreground: #F2E5BCFF; + background: #D79921FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF3C3836; - background: #FFEBDBB2; + foreground: #3C3836FF; + background: #EBDBB2FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFF2E5BC; - background: #FFCC241D; + foreground: #F2E5BCFF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FFF2E5BC; - background: #FFB57614; + foreground: #F2E5BCFF; + background: #B57614FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF3C3836; - background: #FFF2E5BC; + foreground: #3C3836FF; + background: #F2E5BCFF; } diff --git a/themes/gruvbox-light.rasi b/themes/gruvbox-light.rasi index f2b18009..b575d0ce 100644 --- a/themes/gruvbox-light.rasi +++ b/themes/gruvbox-light.rasi @@ -16,9 +16,9 @@ } #window { border: 2; - foreground: #FF7C6F64; + foreground: #7C6F64FF; padding: 5; - background: #FFFBF1C7; + background: #FBF1C7FF; } #window.mainbox { border: 0; @@ -29,8 +29,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF3C3836; - background: #FFFBF1C7; + foreground: #3C3836FF; + background: #FBF1C7FF; } #window.mainbox.listview { fixed-height: 1; @@ -42,40 +42,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF3C3836; - background: #FFFBF1C7; + foreground: #3C3836FF; + background: #FBF1C7FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFFBF1C7; - background: #FFCC241D; + foreground: #FBF1C7FF; + background: #CC241DFF; } #window.mainbox.listview.element.normal.active { - foreground: #FFFBF1C7; - background: #FFB57614; + foreground: #FBF1C7FF; + background: #B57614FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FF282828; - background: #FFD5C4A1; + foreground: #282828FF; + background: #D5C4A1FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFFBF1C7; - background: #FFFB4934; + foreground: #FBF1C7FF; + background: #FB4934FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFFBF1C7; - background: #FFD79921; + foreground: #FBF1C7FF; + background: #D79921FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF3C3836; - background: #FFF2E5BC; + foreground: #3C3836FF; + background: #F2E5BCFF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFFBF1C7; - background: #FFCC241D; + foreground: #FBF1C7FF; + background: #CC241DFF; } #window.mainbox.listview.element.alternate.active { - foreground: #FFFBF1C7; - background: #FFB57614; + foreground: #FBF1C7FF; + background: #B57614FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -90,6 +90,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF3C3836; - background: #FFFBF1C7; + foreground: #3C3836FF; + background: #FBF1C7FF; } diff --git a/themes/lb.rasi b/themes/lb.rasi index 54626dde..accc14a2 100644 --- a/themes/lb.rasi +++ b/themes/lb.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF10A0A0; + foreground: #10A0A0FF; padding: 5; - background: #EE333333; + background: #333333EE; } #window.mainbox { border: 0; @@ -22,7 +22,7 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF10A0A0; + foreground: #10A0A0FF; background: #00000000; } #window.mainbox.listview { @@ -35,40 +35,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF10A0A0; + foreground: #10A0A0FF; background: #00000000; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFF09090; + foreground: #F09090FF; background: #00000000; } #window.mainbox.listview.element.normal.active { - foreground: #FFA0A010; + foreground: #A0A010FF; background: #00000000; } #window.mainbox.listview.element.selected.normal { - foreground: #FF303030; - background: #FF10A0A0; + foreground: #303030FF; + background: #10A0A0FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF303030; - background: #FFF09090; + foreground: #303030FF; + background: #F09090FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF303030; - background: #FFA0A010; + foreground: #303030FF; + background: #A0A010FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF10A0A0; - background: #11FFFFFF; + foreground: #10A0A0FF; + background: #FFFFFF11; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFF09090; - background: #11FFFFFF; + foreground: #F09090FF; + background: #FFFFFF11; } #window.mainbox.listview.element.alternate.active { - foreground: #FFA0A010; - background: #11FFFFFF; + foreground: #A0A010FF; + background: #FFFFFF11; } #window.mainbox.listview.scrollbar { border: 0; @@ -83,6 +83,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF10A0A0; + foreground: #10A0A0FF; background: #00000000; } diff --git a/themes/paper-float.rasi b/themes/paper-float.rasi index 1a2e2a02..971dc068 100644 --- a/themes/paper-float.rasi +++ b/themes/paper-float.rasi @@ -20,7 +20,7 @@ background: #00000000; border: 0; padding: 0% 0% 1em 0%; - foreground: #FF444444; + foreground: #444444FF; x-offset: 0; y-offset: -10%; } @@ -38,7 +38,7 @@ foreground: @back; } #window.mainbox.message.normal { - foreground: #FF002B36; + foreground: #002B36FF; padding: 0; border: 0; } @@ -57,40 +57,40 @@ highlight: bold ; } #window.mainbox.listview.element.normal.normal { - foreground: #FF002B36; - background: #00F5F5F5; + foreground: #002B36FF; + background: #F5F5F500; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFD75F00; - background: #FFF5F5F5; + foreground: #D75F00FF; + background: #F5F5F5FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF005F87; - background: #FFF5F5F5; + foreground: #005F87FF; + background: #F5F5F5FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FFF5F5F5; - background: #FF4271AE; + foreground: #F5F5F5FF; + background: #4271AEFF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFF5F5F5; - background: #FFD75F00; + foreground: #F5F5F5FF; + background: #D75F00FF; } #window.mainbox.listview.element.selected.active { - foreground: #FFF5F5F5; - background: #FF005F87; + foreground: #F5F5F5FF; + background: #005F87FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF002B36; - background: #FFD0D0D0; + foreground: #002B36FF; + background: #D0D0D0FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFD75F00; - background: #FFD0D0D0; + foreground: #D75F00FF; + background: #D0D0D0FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF005F87; - background: #FFD0D0D0; + foreground: #005F87FF; + background: #D0D0D0FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -106,8 +106,8 @@ index: 0; } #window.mainbox.inputbar.normal { - foreground: #FF002B36; - background: #00F5F5F5; + foreground: #002B36FF; + background: #F5F5F500; } #window.mainbox.sidebar.box { @@ -117,5 +117,5 @@ index: 10; } #window.mainbox.sidebar.button selected { - text: #FF4271AE; + text: #4271AEFF; } diff --git a/themes/purple.rasi b/themes/purple.rasi index 20b490af..06ffcc60 100644 --- a/themes/purple.rasi +++ b/themes/purple.rasi @@ -10,9 +10,9 @@ } #window { border: 2; - foreground: #2FEF6155; + foreground: #EF61552F; padding: 5; - background: #FF2F1E2E; + background: #2F1E2EFF; } #window.mainbox { border: 0; @@ -23,8 +23,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FFB4B4B4; - background: #A02F1E2E; + foreground: #B4B4B4FF; + background: #2F1E2EA0; } #window.mainbox.listview { fixed-height: 1; @@ -36,40 +36,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FFB4B4B4; - background: #A02F1E2E; + foreground: #B4B4B4FF; + background: #2F1E2EA0; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFEF6155; - background: #272F1E2E; + foreground: #EF6155FF; + background: #2F1E2E27; } #window.mainbox.listview.element.normal.active { - foreground: #FF815BA4; - background: #272F1E2E; + foreground: #815BA4FF; + background: #2F1E2E27; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #54815BA4; + background: #815BA454; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFEF6155; - background: #54815BA4; + foreground: #EF6155FF; + background: #815BA454; } #window.mainbox.listview.element.selected.active { - foreground: #FF815BA4; - background: #54815BA4; + foreground: #815BA4FF; + background: #815BA454; } #window.mainbox.listview.element.alternate.normal { - foreground: #FFB4B4B4; - background: #A02F1E2E; + foreground: #B4B4B4FF; + background: #2F1E2EA0; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFEF6155; - background: #2F2F1E2E; + foreground: #EF6155FF; + background: #2F1E2E2F; } #window.mainbox.listview.element.alternate.active { - foreground: #FF815BA4; - background: #2F2F1E2E; + foreground: #815BA4FF; + background: #2F1E2E2F; } #window.mainbox.listview.scrollbar { border: 0; @@ -84,6 +84,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FFB4B4B4; - background: #A02F1E2E; + foreground: #B4B4B4FF; + background: #2F1E2EA0; } diff --git a/themes/sidebar.rasi b/themes/sidebar.rasi index b2bdacaa..5287ffd8 100644 --- a/themes/sidebar.rasi +++ b/themes/sidebar.rasi @@ -49,7 +49,7 @@ #window box { border: 0px 2px 0px 0px; foreground: @lightwhite; - background: #ee1c1c1c; + background: #1c1c1cee; } #window mainbox sidebar box { diff --git a/themes/solarized.rasi b/themes/solarized.rasi index 882b4e8a..4624bcf5 100644 --- a/themes/solarized.rasi +++ b/themes/solarized.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF003642; + foreground: #003642FF; padding: 5; - background: #FF002B37; + background: #002B37FF; } #window.mainbox { border: 0; @@ -22,8 +22,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } #window.mainbox.listview { fixed-height: 1; @@ -35,40 +35,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFDA4281; - background: #FF002B37; + foreground: #DA4281FF; + background: #002B37FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF008ED4; - background: #FF002B37; + foreground: #008ED4FF; + background: #002B37FF; } #window.mainbox.listview.element.selected.normal { - foreground: #FF819396; - background: #FF003642; + foreground: #819396FF; + background: #003642FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FFDA4281; - background: #FF003642; + foreground: #DA4281FF; + background: #003642FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF008ED4; - background: #FF003642; + foreground: #008ED4FF; + background: #003642FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFDA4281; - background: #FF002B37; + foreground: #DA4281FF; + background: #002B37FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF008ED4; - background: #FF002B37; + foreground: #008ED4FF; + background: #002B37FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -83,6 +83,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } diff --git a/themes/solarized_alternate.rasi b/themes/solarized_alternate.rasi index d3ed35a7..86af4a7a 100644 --- a/themes/solarized_alternate.rasi +++ b/themes/solarized_alternate.rasi @@ -9,9 +9,9 @@ } #window { border: 2; - foreground: #FF003642; + foreground: #003642FF; padding: 5; - background: #FF002B37; + background: #002B37FF; } #window.mainbox { border: 0; @@ -22,8 +22,8 @@ padding: 2px 0px 0px ; } #window.mainbox.message.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } #window.mainbox.listview { fixed-height: 1; @@ -35,40 +35,40 @@ border: 0; } #window.mainbox.listview.element.normal.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } #window.mainbox.listview.element.normal.urgent { - foreground: #FFDA4281; - background: #FF002B37; + foreground: #DA4281FF; + background: #002B37FF; } #window.mainbox.listview.element.normal.active { - foreground: #FF008ED4; - background: #FF002B37; + foreground: #008ED4FF; + background: #002B37FF; } #window.mainbox.listview.element.selected.normal { foreground: #FFFFFFFF; - background: #FF008ED4; + background: #008ED4FF; } #window.mainbox.listview.element.selected.urgent { - foreground: #FF890661; - background: #FF008ED4; + foreground: #890661FF; + background: #008ED4FF; } #window.mainbox.listview.element.selected.active { - foreground: #FF66C6FF; - background: #FF008ED4; + foreground: #66C6FFFF; + background: #008ED4FF; } #window.mainbox.listview.element.alternate.normal { - foreground: #FF819396; - background: #FF003643; + foreground: #819396FF; + background: #003643FF; } #window.mainbox.listview.element.alternate.urgent { - foreground: #FFDA4281; - background: #FF003643; + foreground: #DA4281FF; + background: #003643FF; } #window.mainbox.listview.element.alternate.active { - foreground: #FF008ED4; - background: #FF003643; + foreground: #008ED4FF; + background: #003643FF; } #window.mainbox.listview.scrollbar { border: 0; @@ -83,6 +83,6 @@ #window.mainbox.inputbar.box { } #window.mainbox.inputbar.normal { - foreground: #FF819396; - background: #FF002B37; + foreground: #819396FF; + background: #002B37FF; } From bca8ca33d825b94c07d2d771fca450a6cd50c055 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 16 May 2017 22:33:55 +0200 Subject: [PATCH 25/36] Update test --- doc/default_theme.rasi | 14 +++++++------- libgwater | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/default_theme.rasi b/doc/default_theme.rasi index 31ebf297..99db388f 100644 --- a/doc/default_theme.rasi +++ b/doc/default_theme.rasi @@ -1,22 +1,22 @@ * { - foreground: rgba ( 0, 43, 54, 255 ); + foreground: rgba ( 0, 43, 54, 100 % ); selected-normal-foreground: @lightbg; normal-foreground: @foreground; - red: rgba ( 220, 50, 47, 255 ); + red: rgba ( 220, 50, 47, 100 % ); alternate-normal-background: @lightbg; - blue: rgba ( 38, 139, 210, 255 ); + blue: rgba ( 38, 139, 210, 100 % ); selected-urgent-foreground: @background; urgent-foreground: @red; alternate-urgent-background: @lightbg; active-foreground: @blue; - lightbg: rgba ( 238, 232, 213, 255 ); + lightbg: rgba ( 238, 232, 213, 100 % ); selected-active-foreground: @background; alternate-normal-foreground: @foreground; alternate-active-background: @lightbg; bordercolor: @foreground; - background: rgba ( 253, 246, 227, 255 ); + background: rgba ( 253, 246, 227, 100 % ); normal-background: @background; - lightfg: rgba ( 88, 104, 117, 255 ); + lightfg: rgba ( 88, 104, 117, 100 % ); selected-normal-background: @lightfg; separatorcolor: @foreground; spacing: 2; @@ -30,7 +30,7 @@ #window { border: 1; foreground: @foreground; - background: rgba ( 0, 0, 0, 0 ); + background: rgba ( 0, 0, 0, 0 % ); padding: 5; } #window.box { diff --git a/libgwater b/libgwater index 173f2f55..60e5e71e 160000 --- a/libgwater +++ b/libgwater @@ -1 +1 @@ -Subproject commit 173f2f5566636a1de559cc57f3154db70c3f2e9f +Subproject commit 60e5e71e09e573bd5c7839ce4a892747ea232526 From 41a7e069196d4890226bdf418cc7d9944ce4f852 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 17 May 2017 08:24:28 +0200 Subject: [PATCH 26/36] [Theme] Update theme-manpage --- doc/rofi-theme-manpage.markdown | 28 ++++++++---- doc/rofi-theme.5 | 47 ++++++++++++++++--- lexer/theme-parser.y | 22 +++++++-- libgwater | 2 +- test/theme-parser-test.c | 81 +++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+), 20 deletions(-) diff --git a/doc/rofi-theme-manpage.markdown b/doc/rofi-theme-manpage.markdown index 5a32f46e..61bd7b47 100644 --- a/doc/rofi-theme-manpage.markdown +++ b/doc/rofi-theme-manpage.markdown @@ -238,16 +238,28 @@ dynamic: false; ## Color -* Format: `#{HEX}{6}` -* Format: `#{HEX}{8}` -* Format: `rgb({INTEGER},{INTEGER},{INTEGER})` -* Format: `rgba({INTEGER},{INTEGER},{INTEGER}, {REAL})` +**rofi** supports the color formats as specified in the CSS standard (1,2,3 and some of CSS 4) -Where '{HEX}' is a hexidecimal number ('0-9a-f'). The '{INTEGER}' value can be between 0 and 255, the '{Real}' value -between 0.0 and 1.0. +* Format: `#{HEX}{3}` (rgb) +* Format: `#{HEX}{4}` (rgba) +* Format: `#{HEX}{6}` (rrggbb) +* Format: `#{HEX}{8}` (rrggbbaa) +* Format: `rgb[a]({INTEGER},{INTEGER},{INTEGER}[, {PERCENTAGE}])` +* Format: `rgb[a]({INTEGER}%,{INTEGER}%,{INTEGER}%[, {PERCENTAGE}])` +* Format: `hsl[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])` +* Format: `hwb[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])` +* Format: `cmyk( {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE} [, {PERCENTAGE} ])` +* Format: `` + +The in CSS proposed white-space format is also supported. + +The different values are: + + * `{HEX}` is a hexidecimal number ('0-9a-f' case insensitive). + * `{INTEGER}` value can be between 0 and 255 or 0-100 when representing percentage. + * `{ANGLE}` Angle on the color wheel, can be in deg, rad, grad or turns. When no unit is specified, degrees is assumed. + * `{PERCENTAGE}` Can be between 0-1.0, or 0%-100% -The first formats specify the color as RRGGBB (R = red, G = green, B = Blue), the second adds an alpha (A) channel: -AARRGGBB. For example: diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index bbbe7241..b5a01be9 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-THEME\-MANPAGE" "" "April 2017" "" "" +.TH "ROFI\-THEME\-MANPAGE" "" "May 2017" "" "" . .SH "NAME" \fBrofi\-theme\fR \- Rofi theme format files @@ -360,26 +360,59 @@ dynamic: false; .IP "" 0 . .SH "Color" +\fBrofi\fR supports the color formats as specified in the CSS standard (1,2,3 and some of CSS 4) . .IP "\(bu" 4 -Format: \fB#{HEX}{6}\fR +Format: \fB#{HEX}{3}\fR (rgb) . .IP "\(bu" 4 -Format: \fB#{HEX}{8}\fR +Format: \fB#{HEX}{4}\fR (rgba) . .IP "\(bu" 4 -Format: \fBrgb({INTEGER},{INTEGER},{INTEGER})\fR +Format: \fB#{HEX}{6}\fR (rrggbb) . .IP "\(bu" 4 -Format: \fBrgba({INTEGER},{INTEGER},{INTEGER}, {REAL})\fR +Format: \fB#{HEX}{8}\fR (rrggbbaa) +. +.IP "\(bu" 4 +Format: \fBrgb[a]({INTEGER},{INTEGER},{INTEGER}[, {PERCENTAGE}])\fR +. +.IP "\(bu" 4 +Format: \fBrgb[a]({INTEGER}%,{INTEGER}%,{INTEGER}%[, {PERCENTAGE}])\fR +. +.IP "\(bu" 4 +Format: \fBhsl[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])\fR +. +.IP "\(bu" 4 +Format: \fBhwb[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])\fR +. +.IP "\(bu" 4 +Format: \fBcmyk( {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE} [, {PERCENTAGE} ])\fR +. +.IP "\(bu" 4 +Format: \fB\fR . .IP "" 0 . .P -Where \'{HEX}\' is a hexidecimal number (\'0\-9a\-f\')\. The \'{INTEGER}\' value can be between 0 and 255, the \'{Real}\' value between 0\.0 and 1\.0\. +The in CSS proposed white\-space format is also supported\. . .P -The first formats specify the color as RRGGBB (R = red, G = green, B = Blue), the second adds an alpha (A) channel: AARRGGBB\. +The different values are: +. +.IP "\(bu" 4 +\fB{HEX}\fR is a hexidecimal number (\'0\-9a\-f\' case insensitive)\. +. +.IP "\(bu" 4 +\fB{INTEGER}\fR value can be between 0 and 255 or 0\-100 when representing percentage\. +. +.IP "\(bu" 4 +\fB{ANGLE}\fR Angle on the color wheel, can be in deg, rad, grad or turns\. When no unit is specified, degrees is assumed\. +. +.IP "\(bu" 4 +\fB{PERCENTAGE}\fR Can be between 0\-1\.0, or 0%\-100% +. +.IP "" 0 . .P For example: diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 7e9c1da2..816bbd7c 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -454,6 +454,20 @@ t_property_color $$.red = $3/255.0; $$.green = $4/255.0; $$.blue = $5/255.0; +} + /** rgba ( 0-100% , 0-100%, 0-100%, 0-1.0 ) */ +| T_COL_RGBA T_PARENT_LEFT t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT t_property_color_opt_alpha_c T_PARENT_RIGHT { + if ( ! check_in_range($3,0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($6,0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($9,0,100, &(@$)) ) { YYABORT; } + $$.alpha = $11; $$.red = $3/100.0; $$.green = $6/100.0; $$.blue = $9/100.0; +} + /** rgba ( 0-100% 0-100% 0-100% / 0-1.0 ) */ +| T_COL_RGBA T_PARENT_LEFT t_property_color_value T_PERCENT t_property_color_value T_PERCENT t_property_color_value T_PERCENT t_property_color_opt_alpha_ws T_PARENT_RIGHT { + if ( ! check_in_range($3,0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } + if ( ! check_in_range($7,0,100, &(@$)) ) { YYABORT; } + $$.alpha = $9; $$.red = $3/100.0; $$.green = $5/100.0; $$.blue = $7/100.0; } /** hwb with comma */ | T_COL_HWB T_PARENT_LEFT t_property_color_value_angle T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit t_property_color_opt_alpha_c T_PARENT_RIGHT { @@ -468,16 +482,16 @@ t_property_color $$.alpha = $6; } /** cmyk with comma */ -| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit T_PARENT_RIGHT { - $$.alpha = 1.0; +| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit T_COMMA t_property_color_value_unit t_property_color_opt_alpha_c T_PARENT_RIGHT { + $$.alpha = $10; double c= $3, m= $5, y= $7, k= $9; $$.red = (1.0-c)*(1.0-k); $$.green = (1.0-m)*(1.0-k); $$.blue = (1.0-y)*(1.0-k); } /** cmyk whitespace edition. */ -| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit T_PARENT_RIGHT { - $$.alpha = 1.0; +| T_COL_CMYK T_PARENT_LEFT t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit t_property_color_value_unit t_property_color_opt_alpha_ws T_PARENT_RIGHT { + $$.alpha = $7; double c= $3, m= $4, y= $5, k= $6; $$.red = (1.0-c)*(1.0-k); $$.green = (1.0-m)*(1.0-k); diff --git a/libgwater b/libgwater index 60e5e71e..173f2f55 160000 --- a/libgwater +++ b/libgwater @@ -1 +1 @@ -Subproject commit 60e5e71e09e573bd5c7839ce4a892747ea232526 +Subproject commit 173f2f5566636a1de559cc57f3154db70c3f2e9f diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index fc95f5f0..2166758b 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -512,6 +512,84 @@ START_TEST ( test_properties_color_h8 ) } END_TEST START_TEST ( test_properties_color_rgb ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { red: rgb(100%,0%,0%); green: rgb(0%,100%,0%); blue: rgb(0%,0%,100%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.red , 1 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "green", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 1 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "blue", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 1 ); +} +END_TEST +START_TEST ( test_properties_color_rgba_p ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { red: rgba(100%,0%,0%,0.3); green: rgba(0%,100%,0%,0.2); blue: rgba(0%,0%,100%,0.7); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq ( p->value.color.red , 1 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "green", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.2 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 1 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "blue", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.7 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 1 ); +} +END_TEST +START_TEST ( test_properties_color_rgba_percent_p ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { red: rgba(100%,0%,0%,30%); green: rgba(0%,100%,0%,20%); blue: rgba(0%,0%,100%,70.0%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq ( p->value.color.red , 1 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "green", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.2 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 1 ); + ck_assert_double_eq ( p->value.color.blue , 0 ); + p = rofi_theme_find_property ( twid, P_COLOR, "blue", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.7 ); + ck_assert_double_eq ( p->value.color.red , 0 ); + ck_assert_double_eq ( p->value.color.green , 0 ); + ck_assert_double_eq ( p->value.color.blue , 1 ); +} +END_TEST +START_TEST ( test_properties_color_rgb_p ) { widget wid; wid.name = "blaat"; @@ -1030,6 +1108,9 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_rgb); tcase_add_test ( tc_prop_color, test_properties_color_rgba); tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent); + tcase_add_test ( tc_prop_color, test_properties_color_rgb_p); + tcase_add_test ( tc_prop_color, test_properties_color_rgba_p); + tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent_p); tcase_add_test ( tc_prop_color, test_properties_color_argb); tcase_add_test ( tc_prop_color, test_properties_color_hsl); tcase_add_test ( tc_prop_color, test_properties_color_hsla); From bcea55c398c9f9a77aeb045d264c67fee3bfba09 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 17 May 2017 22:02:59 +0200 Subject: [PATCH 27/36] Small updates to theme manpage. - Add named colors. - Add named colors alpha. --- doc/rofi-theme-manpage.markdown | 22 +++++++++++++++++++--- doc/rofi-theme.5 | 12 +++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/rofi-theme-manpage.markdown b/doc/rofi-theme-manpage.markdown index 61bd7b47..313978db 100644 --- a/doc/rofi-theme-manpage.markdown +++ b/doc/rofi-theme-manpage.markdown @@ -249,16 +249,32 @@ dynamic: false; * Format: `hsl[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])` * Format: `hwb[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])` * Format: `cmyk( {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE} [, {PERCENTAGE} ])` -* Format: `` +* Format: `{named-color} [ / {PERCENTAGE} ]` -The in CSS proposed white-space format is also supported. +The in CSS 4 proposed white-space format is also supported. The different values are: * `{HEX}` is a hexidecimal number ('0-9a-f' case insensitive). * `{INTEGER}` value can be between 0 and 255 or 0-100 when representing percentage. - * `{ANGLE}` Angle on the color wheel, can be in deg, rad, grad or turns. When no unit is specified, degrees is assumed. + * `{ANGLE}` Angle on the color wheel, can be in `deg`, `rad`, `grad` or `turn`. When no unit is specified, degrees is assumed. * `{PERCENTAGE}` Can be between 0-1.0, or 0%-100% + * `{named-color}` Is one of the following colors: + + AliceBlue, AntiqueWhite, Aqua, Aquamarine, Azure, Beige, Bisque, Black, BlanchedAlmond, Blue, BlueViolet, Brown, + BurlyWood, CadetBlue, Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk, Crimson, Cyan, DarkBlue, DarkCyan, + DarkGoldenRod, DarkGray, DarkGrey, DarkGreen, DarkKhaki, DarkMagenta, DarkOliveGreen, DarkOrange, DarkOrchid, DarkRed, + DarkSalmon, DarkSeaGreen, DarkSlateBlue, DarkSlateGray, DarkSlateGrey, DarkTurquoise, DarkViolet, DeepPink, DeepSkyBlue, + DimGray, DimGrey, DodgerBlue, FireBrick, FloralWhite, ForestGreen, Fuchsia, Gainsboro, GhostWhite, Gold, GoldenRod, + Gray, Grey, Green, GreenYellow, HoneyDew, HotPink, IndianRed, Indigo, Ivory, Khaki, Lavender, LavenderBlush, LawnGreen, + LemonChiffon, LightBlue, LightCoral, LightCyan, LightGoldenRodYellow, LightGray, LightGrey, LightGreen, LightPink, + LightSalmon, LightSeaGreen, LightSkyBlue, LightSlateGray, LightSlateGrey, LightSteelBlue, LightYellow, Lime, LimeGreen, + Linen, Magenta, Maroon, MediumAquaMarine, MediumBlue, MediumOrchid, MediumPurple, MediumSeaGreen, MediumSlateBlue, + MediumSpringGreen, MediumTurquoise, MediumVioletRed, MidnightBlue, MintCream, MistyRose, Moccasin, NavajoWhite, Navy, + OldLace, Olive, OliveDrab, Orange, OrangeRed, Orchid, PaleGoldenRod, PaleGreen, PaleTurquoise, PaleVioletRed, + PapayaWhip, PeachPuff, Peru, Pink, Plum, PowderBlue, Purple, RebeccaPurple, Red, RosyBrown, RoyalBlue, SaddleBrown, + Salmon, SandyBrown, SeaGreen, SeaShell, Sienna, Silver, SkyBlue, SlateBlue, SlateGray, SlateGrey, Snow, SpringGreen, + SteelBlue, Tan, Teal, Thistle, Tomato, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen For example: diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index b5a01be9..5036f07b 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -390,12 +390,12 @@ Format: \fBhwb[a]( {ANGLE}, {PERCENTAGE}, {PERCENTAGE} [{PERCENTAGE}])\fR Format: \fBcmyk( {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE}, {PERCENTAGE} [, {PERCENTAGE} ])\fR . .IP "\(bu" 4 -Format: \fB\fR +Format: \fB{named\-color} [ / {PERCENTAGE} ]\fR . .IP "" 0 . .P -The in CSS proposed white\-space format is also supported\. +The in CSS 4 proposed white\-space format is also supported\. . .P The different values are: @@ -407,11 +407,17 @@ The different values are: \fB{INTEGER}\fR value can be between 0 and 255 or 0\-100 when representing percentage\. . .IP "\(bu" 4 -\fB{ANGLE}\fR Angle on the color wheel, can be in deg, rad, grad or turns\. When no unit is specified, degrees is assumed\. +\fB{ANGLE}\fR Angle on the color wheel, can be in \fBdeg\fR, \fBrad\fR, \fBgrad\fR or \fBturn\fR\. When no unit is specified, degrees is assumed\. . .IP "\(bu" 4 \fB{PERCENTAGE}\fR Can be between 0\-1\.0, or 0%\-100% . +.IP "\(bu" 4 +\fB{named\-color}\fR Is one of the following colors: +. +.IP +AliceBlue, AntiqueWhite, Aqua, Aquamarine, Azure, Beige, Bisque, Black, BlanchedAlmond, Blue, BlueViolet, Brown, BurlyWood, CadetBlue, Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk, Crimson, Cyan, DarkBlue, DarkCyan, DarkGoldenRod, DarkGray, DarkGrey, DarkGreen, DarkKhaki, DarkMagenta, DarkOliveGreen, DarkOrange, DarkOrchid, DarkRed, DarkSalmon, DarkSeaGreen, DarkSlateBlue, DarkSlateGray, DarkSlateGrey, DarkTurquoise, DarkViolet, DeepPink, DeepSkyBlue, DimGray, DimGrey, DodgerBlue, FireBrick, FloralWhite, ForestGreen, Fuchsia, Gainsboro, GhostWhite, Gold, GoldenRod, Gray, Grey, Green, GreenYellow, HoneyDew, HotPink, IndianRed, Indigo, Ivory, Khaki, Lavender, LavenderBlush, LawnGreen, LemonChiffon, LightBlue, LightCoral, LightCyan, LightGoldenRodYellow, LightGray, LightGrey, LightGreen, LightPink, LightSalmon, LightSeaGreen, LightSkyBlue, LightSlateGray, LightSlateGrey, LightSteelBlue, LightYellow, Lime, LimeGreen, Linen, Magenta, Maroon, MediumAquaMarine, MediumBlue, MediumOrchid, MediumPurple, MediumSeaGreen, MediumSlateBlue, MediumSpringGreen, MediumTurquoise, MediumVioletRed, MidnightBlue, MintCream, MistyRose, Moccasin, NavajoWhite, Navy, OldLace, Olive, OliveDrab, Orange, OrangeRed, Orchid, PaleGoldenRod, PaleGreen, PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff, Peru, Pink, Plum, PowderBlue, Purple, RebeccaPurple, Red, RosyBrown, RoyalBlue, SaddleBrown, Salmon, SandyBrown, SeaGreen, SeaShell, Sienna, Silver, SkyBlue, SlateBlue, SlateGray, SlateGrey, Snow, SpringGreen, SteelBlue, Tan, Teal, Thistle, Tomato, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen +. .IP "" 0 . .P From 72afc7b0399834bc2b6c3a45f761b548f47b3cab Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 18 May 2017 07:59:37 +0200 Subject: [PATCH 28/36] Add strikethrough highlight method. --- configure.ac | 4 +++ doc/rofi-theme-manpage.markdown | 1 + doc/rofi-theme.5 | 1 + include/theme.h | 2 ++ lexer/theme-lexer.l | 52 +++++++++++++++++---------------- lexer/theme-parser.y | 10 ++++--- source/helper.c | 6 ++++ source/theme.c | 3 ++ 8 files changed, 50 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index a77ce00e..0445e422 100644 --- a/configure.ac +++ b/configure.ac @@ -101,6 +101,7 @@ AC_CHECK_FUNC([fcntl],, AC_MSG_ERROR("Could not find fcntl")) AC_CHECK_FUNC([setlocale],,AC_MSG_ERROR("Could not find setlocale")) AC_CHECK_FUNC([atexit],, AC_MSG_ERROR("Could not find atexit in c library")) AC_CHECK_FUNC([glob],, AC_MSG_ERROR("Could not find glob in c library")) +AC_CHECK_FUNC([toupper],, AC_MSG_ERROR("Could not find toupper in c library")) AC_CHECK_HEADER([math.h],, AC_MSG_ERROR("Could not find math.h header file")) AC_SEARCH_LIBS([floor],[m],, AC_MSG_ERROR("Could not find floor in math library")) @@ -122,6 +123,9 @@ PKG_CHECK_MODULES([pango], [pango pangocairo]) PKG_CHECK_MODULES([cairo], [cairo cairo-xcb]) PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ]) +dnl --------------------------------------------------------------------- +dnl check - Unit testing. +dnl --------------------------------------------------------------------- AC_ARG_ENABLE([check], AS_HELP_STRING([--disable-check], [Build with checks using check library (default: enabled)])) AS_IF([test "x${enable_check}" != "xno"], [ PKG_CHECK_MODULES([check],[check >= 0.11.0], [HAVE_CHECK=1]) ]) diff --git a/doc/rofi-theme-manpage.markdown b/doc/rofi-theme-manpage.markdown index 313978db..27bec018 100644 --- a/doc/rofi-theme-manpage.markdown +++ b/doc/rofi-theme-manpage.markdown @@ -282,6 +282,7 @@ For example: ``` background: #FF0000; foreground: rgba(0,0,1, 0.5); +text: SeaGreen; ``` ## Text style diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index 5036f07b..a13702a6 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -429,6 +429,7 @@ For example: background: #FF0000; foreground: rgba(0,0,1, 0\.5); +text: SeaGreen; . .fi . diff --git a/include/theme.h b/include/theme.h index 16d03c1d..e6ca825f 100644 --- a/include/theme.h +++ b/include/theme.h @@ -42,6 +42,8 @@ typedef enum HL_BOLD = 1, /** underline */ HL_UNDERLINE = 2, + /** strikethrough */ + HL_STRIKETHROUGH = 16, /** italic */ HL_ITALIC = 4, /** color */ diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 36fbccab..cf85a0fb 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -184,10 +184,11 @@ EAST "east" WEST "west" /* Line Style */ -NONE "none" -BOLD "bold" -UNDERLINE "underline" -ITALIC "italic" +NONE "none" +BOLD "bold" +UNDERLINE "underline" +ITALIC "italic" +STRIKETHROUGH "strikethrough" /* ANGLES */ @@ -439,31 +440,32 @@ if ( queue == NULL ){ return T_COLOR; } /* Color schemes */ -{RGBA} { return T_COL_RGBA; } -{HSL} { return T_COL_HSL; } -{HWB} { return T_COL_HWB; } -{CMYK} { return T_COL_CMYK; } +{RGBA} { return T_COL_RGBA; } +{HSL} { return T_COL_HSL; } +{HWB} { return T_COL_HWB; } +{CMYK} { return T_COL_CMYK; } /* Fluff */ -{S_T_PARENT_LEFT} { return T_PARENT_LEFT; } -{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT;} -{COMMA} { return T_COMMA; } -{FORWARD_SLASH} { return T_FORWARD_SLASH; } +{S_T_PARENT_LEFT} { return T_PARENT_LEFT; } +{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT; } +{COMMA} { return T_COMMA; } +{FORWARD_SLASH} { return T_FORWARD_SLASH; } /* Position */ -{CENTER} { return T_POS_CENTER; } -{EAST} { return T_POS_EAST; } -{WEST} { return T_POS_WEST; } -{SOUTH} { return T_POS_SOUTH; } -{NORTH} { return T_POS_NORTH; } +{CENTER} { return T_POS_CENTER; } +{EAST} { return T_POS_EAST; } +{WEST} { return T_POS_WEST; } +{SOUTH} { return T_POS_SOUTH; } +{NORTH} { return T_POS_NORTH; } /* Highlight style */ -{NONE} { return T_NONE; } -{BOLD} { return T_BOLD; } -{ITALIC} { return T_ITALIC; } -{UNDERLINE} { return T_UNDERLINE; } +{NONE} { return T_NONE; } +{BOLD} { return T_BOLD; } +{ITALIC} { return T_ITALIC; } +{UNDERLINE} { return T_UNDERLINE; } +{STRIKETHROUGH} { return T_STRIKETHROUGH; } -{ANGLE_DEG} { return T_ANGLE_DEG; } -{ANGLE_RAD} { return T_ANGLE_RAD; } -{ANGLE_GRAD} { return T_ANGLE_GRAD; } -{ANGLE_TURN} { return T_ANGLE_TURN; } +{ANGLE_DEG} { return T_ANGLE_DEG; } +{ANGLE_RAD} { return T_ANGLE_RAD; } +{ANGLE_GRAD} { return T_ANGLE_GRAD; } +{ANGLE_TURN} { return T_ANGLE_TURN; } {COLOR_TRANSPARENT} { return T_COLOR_TRANSPARENT; diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 816bbd7c..e721b346 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -173,6 +173,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_BOLD "Bold" %token T_ITALIC "Italic" %token T_UNDERLINE "Underline" +%token T_STRIKETHROUGH "Strikethrough" %token T_DASH "Dash" %token T_SOLID "Solid" @@ -394,10 +395,11 @@ t_property_highlight_styles ; /** Single style. */ t_property_highlight_style -: T_NONE { $$ = HL_NONE; } -| T_BOLD { $$ = HL_BOLD; } -| T_UNDERLINE { $$ = HL_UNDERLINE; } -| T_ITALIC { $$ = HL_ITALIC; } +: T_NONE { $$ = HL_NONE; } +| T_BOLD { $$ = HL_BOLD; } +| T_UNDERLINE { $$ = HL_UNDERLINE; } +| T_STRIKETHROUGH { $$ = HL_STRIKETHROUGH; } +| T_ITALIC { $$ = HL_ITALIC; } ; /** Distance. */ diff --git a/source/helper.c b/source/helper.c index d31a4e20..e14a5e68 100644 --- a/source/helper.c +++ b/source/helper.c @@ -423,6 +423,12 @@ PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **t pa->end_index = end; pango_attr_list_insert ( retv, pa ); } + if ( th.style & HL_STRIKETHROUGH ) { + PangoAttribute *pa = pango_attr_strikethrough_new ( TRUE ); + pa->start_index = start; + pa->end_index = end; + pango_attr_list_insert ( retv, pa ); + } if ( th.style & HL_ITALIC ) { PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC ); pa->start_index = start; diff --git a/source/theme.c b/source/theme.c index 03f3e859..601738ea 100644 --- a/source/theme.c +++ b/source/theme.c @@ -169,6 +169,9 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p if ( p->value.highlight.style & HL_UNDERLINE ) { printf ( "underline " ); } + if ( p->value.highlight.style & HL_STRIKETHROUGH ) { + printf ( "strikethrough " ); + } if ( p->value.highlight.style & HL_ITALIC ) { printf ( "italic " ); } From fa125cb45601bd8fbee817215cee32dc63479c27 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 18 May 2017 08:14:41 +0200 Subject: [PATCH 29/36] Add extra test for angle unit. --- test/theme-parser-test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 2166758b..713f8726 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -777,7 +777,7 @@ START_TEST ( test_properties_color_hwb_ws ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { test1: hwb(190 deg 65 %0%); test2: hwb(295 grad 31% 29%);testa: hwb(0.736 turn 31% 29% / 40%); }"); + rofi_theme_parse_string ( "* { test1: hwb(190 deg 65 %0%); test2: hwb(295 grad 31% 29%);testa: hwb(0.736 turn 31% 29% / 40%); rada: hwb(0.2 rad 30% 30%/40%); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); @@ -798,6 +798,12 @@ START_TEST ( test_properties_color_hwb_ws ) ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "rada", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0.7 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0.376, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0.3 , 0.004); } END_TEST START_TEST ( test_properties_color_cmyk ) From 421f84285faffde1def20fe08c4173d129ae4dfd Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 18 May 2017 18:04:52 +0200 Subject: [PATCH 30/36] Add strikethrough to theme manpage. - extend theme test to hit all rgba rules. --- doc/rofi-theme-manpage.markdown | 2 +- doc/rofi-theme.5 | 2 +- test/theme-parser-test.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/rofi-theme-manpage.markdown b/doc/rofi-theme-manpage.markdown index 27bec018..7faf9cb6 100644 --- a/doc/rofi-theme-manpage.markdown +++ b/doc/rofi-theme-manpage.markdown @@ -287,7 +287,7 @@ text: SeaGreen; ## Text style -* Format: `(bold|italic|underline|none)` +* Format: `(bold|italic|underline|strikethrough|none)` Text style indicates how the text should be displayed. None indicates no style should be applied. diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index a13702a6..d698656a 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -438,7 +438,7 @@ text: SeaGreen; .SH "Text style" . .IP "\(bu" 4 -Format: \fB(bold|italic|underline|none)\fR +Format: \fB(bold|italic|underline|strikethrough|none)\fR . .IP "" 0 . diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 713f8726..2dbd8312 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -567,7 +567,7 @@ START_TEST ( test_properties_color_rgba_percent_p ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { red: rgba(100%,0%,0%,30%); green: rgba(0%,100%,0%,20%); blue: rgba(0%,0%,100%,70.0%); }"); + rofi_theme_parse_string ( "* { red: rgba(100%,0%,0%,30%); green: rgba(0%,100%,0%,20%); blue: rgba(0% 0% 100%/70.0%); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); ck_assert_ptr_nonnull ( p ); @@ -618,7 +618,7 @@ START_TEST ( test_properties_color_rgba ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { red: rgba(255,0,0,0.3); green: rgba(0,255,0,0.2); blue: rgba(0,0,255,0.7); }"); + rofi_theme_parse_string ( "* { red: rgba(255,0,0,0.3); green: rgba(0,255,0,0.2); blue: rgba(0 0 255 /0.7); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE ); ck_assert_ptr_nonnull ( p ); From 7b42adcca2f48fa8d4f356cb8cf48789370faefa Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 20 May 2017 14:40:16 +0200 Subject: [PATCH 31/36] Fix default theme sidebar mode. --- include/default-theme.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/default-theme.h b/include/default-theme.h index 3ad0dcbd..43af69e0 100644 --- a/include/default-theme.h +++ b/include/default-theme.h @@ -131,6 +131,10 @@ const char *default_theme = "#window.mainbox.sidebar.box {" " border: 1px dash 0px 0px ;" "}" + "#window.mainbox.sidebar button selected {" + " background: @selected-normal-background;" + " foreground: @selected-normal-foreground;" + "}" "#window.mainbox.inputbar {" " spacing: 0;" "}" From a42f4a41fdd506e4957e814b91bba1f9eec7fc5c Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 20 May 2017 15:37:29 +0200 Subject: [PATCH 32/36] Fix tests for default theme fix --- doc/default_theme.rasi | 4 ++++ doc/old-theme-convert-output.rasi | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/default_theme.rasi b/doc/default_theme.rasi index 99db388f..23c33889 100644 --- a/doc/default_theme.rasi +++ b/doc/default_theme.rasi @@ -100,6 +100,10 @@ #window.mainbox.sidebar.box { border: 1px dash 0px 0px ; } +#window.mainbox.sidebar.button.selected { + foreground: @selected-normal-foreground; + background: @selected-normal-background; +} #window.mainbox.inputbar { spacing: 0; } diff --git a/doc/old-theme-convert-output.rasi b/doc/old-theme-convert-output.rasi index d65afc01..3d03e77c 100644 --- a/doc/old-theme-convert-output.rasi +++ b/doc/old-theme-convert-output.rasi @@ -100,6 +100,10 @@ #window.mainbox.sidebar.box { border: 1px dash 0px 0px ; } +#window.mainbox.sidebar.button.selected { + foreground: @selected-normal-foreground; + background: @selected-normal-background; +} #window.mainbox.inputbar { spacing: 0; } From 8616e4e8c6782b642219aea60ea0be79b1afb42a Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 21 May 2017 13:34:58 +0200 Subject: [PATCH 33/36] Add whitespace check for hsl and error range check check --- test/theme-parser-test.c | 83 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 2dbd8312..1b6d7f06 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -362,7 +362,7 @@ START_TEST ( test_properties_style) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { none: none; bold: bold; underline: underline; italic: italic;}"); + rofi_theme_parse_string ( "* { none: none; bold: bold; underline: underline; italic: italic; st: italic strikethrough;}"); ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}}; th = rofi_theme_get_highlight ( &wid, "none", th); ck_assert_int_eq ( th.style , HL_NONE ); @@ -372,6 +372,8 @@ START_TEST ( test_properties_style) ck_assert_int_eq ( th.style , HL_ITALIC); th = rofi_theme_get_highlight ( &wid, "bold", th); ck_assert_int_eq ( th.style , HL_BOLD); + th = rofi_theme_get_highlight ( &wid, "st", th); + ck_assert_int_eq ( th.style , HL_ITALIC|HL_STRIKETHROUGH); } END_TEST START_TEST ( test_properties_style2 ) @@ -727,14 +729,36 @@ START_TEST ( test_properties_color_hsla ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { test1: hsla(127,40%,66.66666%); test2: hsla(0, 100%, 50%); }"); + rofi_theme_parse_string ( "* { test1: hsla(127,40%,66.66666%, 40%); test2: hsla(0, 100%, 50%,55%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x88/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.55 ); + ck_assert_double_eq_tol ( p->value.color.red , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); +} +END_TEST +START_TEST ( test_properties_color_hsl_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hsl(127 40% 66.66666%); test2: hsl(0 100% 50%); testa: hsl(127 40% 66.66666% / 30%);}"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", 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 , 0x88/255.0 , 0.004); - ck_assert_double_eq_tol ( p->value.color.green , 0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.green, 0xcd/255.0, 0.004 ); ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 , 0.004); p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); ck_assert_ptr_nonnull ( p ); @@ -742,6 +766,34 @@ START_TEST ( test_properties_color_hsla ) ck_assert_double_eq_tol ( p->value.color.red , 1 , 0.004); ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x88/255.0 ,0.004); + ck_assert_double_eq_tol ( p->value.color.green ,0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 ,0.004); +} +END_TEST +START_TEST ( test_properties_color_hsla_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hsla(127 40% 66.66666% / 0.3); test2: hsla(0 100% 50%/ 55%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.3 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x88/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0xcd/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0x90/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.55 ); + ck_assert_double_eq_tol ( p->value.color.red , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); } END_TEST START_TEST ( test_properties_color_hwb ) @@ -868,6 +920,16 @@ START_TEST ( test_properties_color_names ) g_free ( str ); } + { + rofi_theme_parse_string("* {color: transparent;}"); + 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 , 0.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 0.0, 0.004); + ck_assert_double_eq_tol ( p->value.color.green, 0.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0.0, 0.004); + } } END_TEST START_TEST ( test_properties_color_names_alpha ) @@ -1033,6 +1095,19 @@ START_TEST ( test_core_properties_error ) g_string_free ( error_msg, TRUE); error_msg = NULL; error = 0; + + const char *errstr2 = "Error while parsing theme: \n"\ + " Parser error: Value out of range: \n"\ + " Value: X = 500.00;\n"\ + " Range: 0.00 <= X <= 360.00.\n"\ + " Location: line 0 column 15 to line 0 column 18\n"; + rofi_theme_parse_string ( " * { test: hsl(500, 100% 10% ); }"); + ck_assert_int_eq ( error, 1); + ck_assert_str_eq ( error_msg->str, errstr2 ); + g_string_free ( error_msg, TRUE); + error_msg = NULL; + error = 0; + } END_TEST @@ -1120,6 +1195,8 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_argb); tcase_add_test ( tc_prop_color, test_properties_color_hsl); tcase_add_test ( tc_prop_color, test_properties_color_hsla); + tcase_add_test ( tc_prop_color, test_properties_color_hsl_ws); + tcase_add_test ( tc_prop_color, test_properties_color_hsla_ws); tcase_add_test ( tc_prop_color, test_properties_color_hwb); tcase_add_test ( tc_prop_color, test_properties_color_hwb_ws); tcase_add_test ( tc_prop_color, test_properties_color_cmyk); From dca5caaa4778f2e7973372fa33483f724610f2dc Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 22 May 2017 09:24:05 +0200 Subject: [PATCH 34/36] [Theme] Add small caps options (not working?) --- doc/rofi-theme-manpage.markdown | 10 ++- doc/rofi-theme.5 | 19 ++++- include/theme.h | 2 + lexer/theme-lexer.l | 2 + lexer/theme-parser.y | 2 + source/dialogs/script.c | 122 +++++++++++++++++++++++++++----- source/helper.c | 6 ++ 7 files changed, 141 insertions(+), 22 deletions(-) diff --git a/doc/rofi-theme-manpage.markdown b/doc/rofi-theme-manpage.markdown index 7faf9cb6..f6eb2ef9 100644 --- a/doc/rofi-theme-manpage.markdown +++ b/doc/rofi-theme-manpage.markdown @@ -274,7 +274,7 @@ The different values are: OldLace, Olive, OliveDrab, Orange, OrangeRed, Orchid, PaleGoldenRod, PaleGreen, PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff, Peru, Pink, Plum, PowderBlue, Purple, RebeccaPurple, Red, RosyBrown, RoyalBlue, SaddleBrown, Salmon, SandyBrown, SeaGreen, SeaShell, Sienna, Silver, SkyBlue, SlateBlue, SlateGray, SlateGrey, Snow, SpringGreen, - SteelBlue, Tan, Teal, Thistle, Tomato, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen + SteelBlue, Tan, Teal, Thistle, Tomato, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen For example: @@ -289,9 +289,15 @@ text: SeaGreen; * Format: `(bold|italic|underline|strikethrough|none)` -Text style indicates how the text should be displayed. None indicates no style +Text style indicates how the highlighted text is emphasised. None indicates no emphasis should be applied. + * `bold`: make the text thicker then the surrounding text. + * `italic`: put the highlighted text in script type (slanted). + * `underline`: put a line under the highlighted text. + * `strikethrough`: put a line through the highlighted text. + * `small caps`: emphasise the text using capitalization. + ## Line style * Format: `(dash|solid)` diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index d698656a..21f8877c 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -443,7 +443,24 @@ Format: \fB(bold|italic|underline|strikethrough|none)\fR .IP "" 0 . .P -Text style indicates how the text should be displayed\. None indicates no style should be applied\. +Text style indicates how the highlighted text is emphasised\. None indicates no emphasis should be applied\. +. +.IP "\(bu" 4 +\fBbold\fR: make the text thicker then the surrounding text\. +. +.IP "\(bu" 4 +\fBitalic\fR: put the highlighted text in script type (slanted)\. +. +.IP "\(bu" 4 +\fBunderline\fR: put a line under the highlighted text\. +. +.IP "\(bu" 4 +\fBstrikethrough\fR: put a line through the highlighted text\. +. +.IP "\(bu" 4 +\fBsmall caps\fR: emphasise the text using capitalization\. +. +.IP "" 0 . .SH "Line style" . diff --git a/include/theme.h b/include/theme.h index e6ca825f..8bdeddc1 100644 --- a/include/theme.h +++ b/include/theme.h @@ -44,6 +44,8 @@ typedef enum HL_UNDERLINE = 2, /** strikethrough */ HL_STRIKETHROUGH = 16, + /** small caps */ + HL_SMALL_CAPS = 32, /** italic */ HL_ITALIC = 4, /** color */ diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index cf85a0fb..80ee6584 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -189,6 +189,7 @@ BOLD "bold" UNDERLINE "underline" ITALIC "italic" STRIKETHROUGH "strikethrough" +SMALLCAPS "small caps" /* ANGLES */ @@ -461,6 +462,7 @@ if ( queue == NULL ){ {ITALIC} { return T_ITALIC; } {UNDERLINE} { return T_UNDERLINE; } {STRIKETHROUGH} { return T_STRIKETHROUGH; } +{SMALLCAPS} { return T_SMALLCAPS; } {ANGLE_DEG} { return T_ANGLE_DEG; } {ANGLE_RAD} { return T_ANGLE_RAD; } diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index e721b346..d66b7cc4 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -174,6 +174,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_ITALIC "Italic" %token T_UNDERLINE "Underline" %token T_STRIKETHROUGH "Strikethrough" +%token T_SMALLCAPS "Small CAPS" %token T_DASH "Dash" %token T_SOLID "Solid" @@ -400,6 +401,7 @@ t_property_highlight_style | T_UNDERLINE { $$ = HL_UNDERLINE; } | T_STRIKETHROUGH { $$ = HL_STRIKETHROUGH; } | T_ITALIC { $$ = HL_ITALIC; } +| T_SMALLCAPS { $$ = HL_SMALL_CAPS; } ; /** Distance. */ diff --git a/source/dialogs/script.c b/source/dialogs/script.c index a4daf289..df006ba4 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -39,28 +39,104 @@ #include "rofi.h" #include "dialogs/script.h" #include "helper.h" - +#include "widgets/textbox.h" #include "mode-private.h" -static char **get_script_output ( const char *command, unsigned int *length ) + +#define START_OF_HEADING '\x01' +#define START_OF_TEXT '\x02' +#define UNIT_SEPARATOR '\x1F' + +typedef enum { + PARSING_ENTRIES = 0, + PARSING_HEADER = 1 + +} ParserMode; + +typedef struct { + unsigned int id; + + ParserMode pmode; + char **cmd_list; + unsigned int cmd_list_length; + /** Display msg */ + char *message; + char *prompt; + char *format; + gboolean markup_rows; +} ScriptModePrivateData; + +static void parse_header ( Mode *sw, ScriptModePrivateData *pd, char *buffer, const ssize_t buffer_length ) +{ + if ( *buffer == START_OF_TEXT ) + { + pd->pmode = PARSING_ENTRIES; + return; + } + char *unit_sep = strchr ( buffer, UNIT_SEPARATOR); + if ( unit_sep ) + { + const char *command = buffer; + const char *value = unit_sep+1; + *unit_sep = '\0'; + if ( strcmp ( command, "message" ) == 0 ) { + if ( pd->message ) g_free ( pd->message ); + pd->message = g_strdup(value); + } + else if ( strcmp ( command, "prompt" ) == 0 ) { + if ( pd->prompt ) g_free ( pd->prompt ); + pd->prompt = g_strdup(value); + sw->display_name = pd->prompt; + } + else if ( strcmp ( command, "markup_rows" ) == 0 ){ + pd->markup_rows = strcasecmp( value, "true") == 0; + } + else if ( strcmp ( command, "format" ) == 0 ) { + if ( pd->format ) g_free ( pd->format ); + pd->format = g_strdup(value); + } + } +} + +static char **get_script_output ( Mode *sw, ScriptModePrivateData *pd, const char *command, unsigned int *length ) +{ + // Default to parsing entries. + pd->pmode = PARSING_ENTRIES; + char **retv = NULL; *length = 0; + unsigned int actual_length = 0; int fd = execute_generator ( command ); if ( fd >= 0 ) { FILE *inp = fdopen ( fd, "r" ); if ( inp ) { char *buffer = NULL; size_t buffer_length = 0; - while ( getline ( &buffer, &buffer_length, inp ) > 0 ) { - retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) ); + ssize_t read_length = 0; + while ( (read_length = getline ( &buffer, &buffer_length, inp )) > 0 ) { + if ( buffer[read_length-1] == '\n' ){ + buffer[read_length-1] = '\0'; + read_length--; + } + if ( buffer[0] == START_OF_HEADING ) { + pd->pmode = PARSING_HEADER; + parse_header( sw, pd, buffer+1, read_length); + continue; + } + if ( pd->pmode == PARSING_HEADER ){ + parse_header(sw, pd, buffer, read_length); + continue; + } + + if ( actual_length < ((*length)+2)) { + actual_length += 128; + retv = g_realloc ( retv, ( actual_length ) * sizeof ( char* ) ); + } + retv[( *length )] = g_strdup ( buffer ); retv[( *length ) + 1] = NULL; - // Filter out line-end. - if ( retv[( *length )][strlen ( buffer ) - 1] == '\n' ) { - retv[( *length )][strlen ( buffer ) - 1] = '\0'; - } ( *length )++; } @@ -78,9 +154,10 @@ static char **get_script_output ( const char *command, unsigned int *length ) static char **execute_executor ( Mode *sw, const char *result, unsigned int *length ) { + ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data; char *arg = g_shell_quote ( result ); char *command = g_strdup_printf ( "%s %s", (const char *) sw->ed, arg ); - char **retv = get_script_output ( command, length ); + char **retv = get_script_output ( sw, pd, command, length ); g_free ( command ); g_free ( arg ); return retv; @@ -96,19 +173,12 @@ static void script_switcher_free ( Mode *sw ) g_free ( sw ); } -typedef struct -{ - unsigned int id; - char **cmd_list; - unsigned int cmd_list_length; -} ScriptModePrivateData; - static int script_mode_init ( Mode *sw ) { if ( sw->private_data == NULL ) { ScriptModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) ); sw->private_data = (void *) pd; - pd->cmd_list = get_script_output ( (const char *) sw->ed, &( pd->cmd_list_length ) ); + pd->cmd_list = get_script_output ( sw,pd, (const char *) sw->ed, &( pd->cmd_list_length ) ); } return TRUE; } @@ -157,6 +227,8 @@ static void script_mode_destroy ( Mode *sw ) ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; if ( rmpd != NULL ) { g_strfreev ( rmpd->cmd_list ); + g_free ( rmpd->message ); + g_free ( rmpd->prompt ); g_free ( rmpd ); sw->private_data = NULL; } @@ -164,6 +236,9 @@ static void script_mode_destroy ( Mode *sw ) static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **list, int get_entry ) { ScriptModePrivateData *rmpd = sw->private_data; + if ( rmpd->markup_rows ) { + *state |= MARKUP; + } return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL; } @@ -172,6 +247,14 @@ static int script_token_match ( const Mode *sw, GRegex **tokens, unsigned int in ScriptModePrivateData *rmpd = sw->private_data; return helper_token_match ( tokens, rmpd->cmd_list[index] ); } +static char *script_get_message ( const Mode *sw ) +{ + ScriptModePrivateData *pd = (ScriptModePrivateData *) mode_get_private_data ( sw ); + if ( pd->message ) { + return g_strdup ( pd->message ); + } + return NULL; +} #include "mode-private.h" Mode *script_switcher_parse_setup ( const char *str ) @@ -198,9 +281,10 @@ Mode *script_switcher_parse_setup ( const char *str ) sw->_result = script_mode_result; sw->_destroy = script_mode_destroy; sw->_token_match = script_token_match; - sw->_get_completion = NULL, - sw->_preprocess_input = NULL, + sw->_get_completion = NULL; + sw->_preprocess_input = NULL; sw->_get_display_value = _get_display_value; + sw->_get_message = script_get_message; return sw; } diff --git a/source/helper.c b/source/helper.c index e14a5e68..7fa07478 100644 --- a/source/helper.c +++ b/source/helper.c @@ -429,6 +429,12 @@ PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **t pa->end_index = end; pango_attr_list_insert ( retv, pa ); } + if ( th.style & HL_SMALL_CAPS ) { + PangoAttribute *pa = pango_attr_variant_new ( PANGO_VARIANT_SMALL_CAPS ); + pa->start_index = start; + pa->end_index = end; + pango_attr_list_insert ( retv, pa ); + } if ( th.style & HL_ITALIC ) { PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC ); pa->start_index = start; From f5c57ff8218daa9d4a7513d2190a4a7c32eba3aa Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 23 May 2017 09:12:04 +0200 Subject: [PATCH 35/36] [TextBox] Add get_desired_width function. --- include/widgets/textbox.h | 1 + source/widgets/textbox.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index b25b4c02..fc75baa7 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -290,5 +290,6 @@ PangoAttrList *textbox_get_pango_attributes ( textbox *tb ); * @returns the visible text. */ const char *textbox_get_visible_text ( const textbox *tb ); +int textbox_get_desired_width ( widget *wid ); /*@}*/ #endif //ROFI_TEXTBOX_H diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 48c03084..c0761f11 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -797,3 +797,17 @@ int textbox_get_estimated_height ( const textbox *tb, int eh ) int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics ); return ( eh * height ) / PANGO_SCALE + widget_padding_get_padding_height ( WIDGET ( tb ) ); } +int textbox_get_desired_width ( widget *wid ) +{ + textbox *tb = (textbox *) wid; + unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0; + if ( tb->flags & TB_AUTOWIDTH ) { + return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset; + } + int width = 0; + pango_layout_set_width ( tb->layout, -1); + width = textbox_get_font_width ( tb ); + // Restore. + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); + return width + widget_padding_get_padding_width ( wid ) + offset; +} From f1261e181c888c212c860dcd77a4f7ccb0053ffa Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 23 May 2017 17:19:04 +0200 Subject: [PATCH 36/36] Revert changes to script. --- source/dialogs/script.c | 122 +++++++--------------------------------- 1 file changed, 19 insertions(+), 103 deletions(-) diff --git a/source/dialogs/script.c b/source/dialogs/script.c index df006ba4..a4daf289 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -39,104 +39,28 @@ #include "rofi.h" #include "dialogs/script.h" #include "helper.h" -#include "widgets/textbox.h" + #include "mode-private.h" - -#define START_OF_HEADING '\x01' -#define START_OF_TEXT '\x02' -#define UNIT_SEPARATOR '\x1F' - -typedef enum { - PARSING_ENTRIES = 0, - PARSING_HEADER = 1 - -} ParserMode; - -typedef struct +static char **get_script_output ( const char *command, unsigned int *length ) { - unsigned int id; - - ParserMode pmode; - char **cmd_list; - unsigned int cmd_list_length; - /** Display msg */ - char *message; - char *prompt; - char *format; - gboolean markup_rows; -} ScriptModePrivateData; - -static void parse_header ( Mode *sw, ScriptModePrivateData *pd, char *buffer, const ssize_t buffer_length ) -{ - if ( *buffer == START_OF_TEXT ) - { - pd->pmode = PARSING_ENTRIES; - return; - } - char *unit_sep = strchr ( buffer, UNIT_SEPARATOR); - if ( unit_sep ) - { - const char *command = buffer; - const char *value = unit_sep+1; - *unit_sep = '\0'; - if ( strcmp ( command, "message" ) == 0 ) { - if ( pd->message ) g_free ( pd->message ); - pd->message = g_strdup(value); - } - else if ( strcmp ( command, "prompt" ) == 0 ) { - if ( pd->prompt ) g_free ( pd->prompt ); - pd->prompt = g_strdup(value); - sw->display_name = pd->prompt; - } - else if ( strcmp ( command, "markup_rows" ) == 0 ){ - pd->markup_rows = strcasecmp( value, "true") == 0; - } - else if ( strcmp ( command, "format" ) == 0 ) { - if ( pd->format ) g_free ( pd->format ); - pd->format = g_strdup(value); - } - } -} - -static char **get_script_output ( Mode *sw, ScriptModePrivateData *pd, const char *command, unsigned int *length ) -{ - // Default to parsing entries. - pd->pmode = PARSING_ENTRIES; - char **retv = NULL; *length = 0; - unsigned int actual_length = 0; int fd = execute_generator ( command ); if ( fd >= 0 ) { FILE *inp = fdopen ( fd, "r" ); if ( inp ) { char *buffer = NULL; size_t buffer_length = 0; - ssize_t read_length = 0; - while ( (read_length = getline ( &buffer, &buffer_length, inp )) > 0 ) { - if ( buffer[read_length-1] == '\n' ){ - buffer[read_length-1] = '\0'; - read_length--; - } - if ( buffer[0] == START_OF_HEADING ) { - pd->pmode = PARSING_HEADER; - parse_header( sw, pd, buffer+1, read_length); - continue; - } - if ( pd->pmode == PARSING_HEADER ){ - parse_header(sw, pd, buffer, read_length); - continue; - } - - if ( actual_length < ((*length)+2)) { - actual_length += 128; - retv = g_realloc ( retv, ( actual_length ) * sizeof ( char* ) ); - } - + while ( getline ( &buffer, &buffer_length, inp ) > 0 ) { + retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) ); retv[( *length )] = g_strdup ( buffer ); retv[( *length ) + 1] = NULL; + // Filter out line-end. + if ( retv[( *length )][strlen ( buffer ) - 1] == '\n' ) { + retv[( *length )][strlen ( buffer ) - 1] = '\0'; + } ( *length )++; } @@ -154,10 +78,9 @@ static char **get_script_output ( Mode *sw, ScriptModePrivateData *pd, const cha static char **execute_executor ( Mode *sw, const char *result, unsigned int *length ) { - ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data; char *arg = g_shell_quote ( result ); char *command = g_strdup_printf ( "%s %s", (const char *) sw->ed, arg ); - char **retv = get_script_output ( sw, pd, command, length ); + char **retv = get_script_output ( command, length ); g_free ( command ); g_free ( arg ); return retv; @@ -173,12 +96,19 @@ static void script_switcher_free ( Mode *sw ) g_free ( sw ); } +typedef struct +{ + unsigned int id; + char **cmd_list; + unsigned int cmd_list_length; +} ScriptModePrivateData; + static int script_mode_init ( Mode *sw ) { if ( sw->private_data == NULL ) { ScriptModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) ); sw->private_data = (void *) pd; - pd->cmd_list = get_script_output ( sw,pd, (const char *) sw->ed, &( pd->cmd_list_length ) ); + pd->cmd_list = get_script_output ( (const char *) sw->ed, &( pd->cmd_list_length ) ); } return TRUE; } @@ -227,8 +157,6 @@ static void script_mode_destroy ( Mode *sw ) ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; if ( rmpd != NULL ) { g_strfreev ( rmpd->cmd_list ); - g_free ( rmpd->message ); - g_free ( rmpd->prompt ); g_free ( rmpd ); sw->private_data = NULL; } @@ -236,9 +164,6 @@ static void script_mode_destroy ( Mode *sw ) static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **list, int get_entry ) { ScriptModePrivateData *rmpd = sw->private_data; - if ( rmpd->markup_rows ) { - *state |= MARKUP; - } return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL; } @@ -247,14 +172,6 @@ static int script_token_match ( const Mode *sw, GRegex **tokens, unsigned int in ScriptModePrivateData *rmpd = sw->private_data; return helper_token_match ( tokens, rmpd->cmd_list[index] ); } -static char *script_get_message ( const Mode *sw ) -{ - ScriptModePrivateData *pd = (ScriptModePrivateData *) mode_get_private_data ( sw ); - if ( pd->message ) { - return g_strdup ( pd->message ); - } - return NULL; -} #include "mode-private.h" Mode *script_switcher_parse_setup ( const char *str ) @@ -281,10 +198,9 @@ Mode *script_switcher_parse_setup ( const char *str ) sw->_result = script_mode_result; sw->_destroy = script_mode_destroy; sw->_token_match = script_token_match; - sw->_get_completion = NULL; - sw->_preprocess_input = NULL; + sw->_get_completion = NULL, + sw->_preprocess_input = NULL, sw->_get_display_value = _get_display_value; - sw->_get_message = script_get_message; return sw; }