summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-12-11 17:50:03 +0100
committerDave Davenport <qball@gmpclient.org>2016-12-11 17:50:03 +0100
commit7f40ed1065fda7b4531b25e919cc8a46954cd1d7 (patch)
tree5e332c82f92726717e3611ed6226ca5976838720
parenta0096f52c4958398419058ee098a632f96137db3 (diff)
Add support for rgb() rgba() color codes
-rw-r--r--lexer/theme-lexer.l19
-rw-r--r--lexer/theme-parser.y7
2 files changed, 18 insertions, 8 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 28e38f26..f0ce33cf 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -23,6 +23,7 @@ int yylex(void);
(true|false) { yylval.bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
[_\-a-zA-Z0-9]+ { yylval.sval = g_strdup(yytext); return N_STRING;}
\"[_\-a-zA-Z0-9 \t]+\" { yytext[yyleng-1] = '\0'; yylval.sval = g_strdup(&yytext[1]); return T_STRING;}
+
#[0-9A-Fa-f]{8} {
union { unsigned int val; struct { unsigned char b,g,r,a;};} val;
val.val = (unsigned int)strtoull ( &yytext[1], NULL, 16);
@@ -34,13 +35,29 @@ int yylex(void);
}
#[0-9A-Fa-f]{6} {
union { unsigned int val; struct { unsigned char b,g,r,a;};} val;
- val.val = (unsigned int)strtoull ( &yytext[1], NULL, 16);
+ 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;
return T_COLOR;
}
+rgba\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[01](\.[0-9]+)?\) {
+ char *endptr = &yytext[5];
+ yylval.colorval.red = g_ascii_strtoull ( endptr, &endptr, 10);
+ yylval.colorval.green= g_ascii_strtoull ( endptr+1, &endptr, 10);
+ yylval.colorval.blue= g_ascii_strtoull ( endptr+1, &endptr, 10);
+ yylval.colorval.alpha= g_ascii_strtod ( endptr+1, NULL);
+ return T_COLOR;
+}
+rgb\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\) {
+ char *endptr = &yytext[4];
+ yylval.colorval.red = g_ascii_strtoull ( endptr, &endptr, 10);
+ yylval.colorval.green = g_ascii_strtoull ( endptr+1, &endptr, 10);
+ yylval.colorval.blue = g_ascii_strtoull ( endptr+1, &endptr, 10);
+ yylval.colorval.alpha = 1.0;
+ return T_COLOR;
+}
[\r\n]+ ;
<*><<EOF>> {
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index b48198a8..f7d528af 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -51,7 +51,6 @@ Widget *rofi_theme = NULL;
%type <name_path> name_path
%type <property> property
%type <property_list> property_list
-%type <property_list> properties
%type <property_list> optional_properties
%start start
@@ -99,12 +98,6 @@ optional_properties
: %empty { $$ = NULL; }
| property_list { $$ = $1; }
;
-/*
-properties: BOPEN property_list BCLOSE { $$ = $2;}
- | BOPEN BCLOSE { $$ = NULL; }
- | %empty { $$ = NULL; }
- ;
-*/
property_list:
property {