diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-12-10 19:48:44 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-12-10 19:48:44 +0100 |
commit | 5fd76b75b1e1e0d72f7bb821ac5db5bca4be10b7 (patch) | |
tree | 3754bfa8f4c718aa6965f1685527d965a38525fc /lexer | |
parent | db248ea7659c0eeaaaf46d58fb14bd9522d02223 (diff) |
Add some color stuff
Diffstat (limited to 'lexer')
-rw-r--r-- | lexer/theme-lexer.l | 12 | ||||
-rw-r--r-- | lexer/theme-parser.y | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 59c67c28..90e66b39 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -24,8 +24,16 @@ 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]+ { yylval.colorval = (unsigned int)strtoull ( &yytext[1], NULL, 16); return T_COLOR;} -[\r\n]+ ; +#[0-9A-Fa-f]+ { + union { unsigned int val; struct { unsigned char a,r,g,b;};} 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; + return T_COLOR; +} + [\r\n]+ ; <*><<EOF>> { yyterminate(); diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 2079ddd1..952303e4 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -21,7 +21,7 @@ Widget *rofi_theme = NULL; double fval; char *sval; int bval; - unsigned int colorval; + ThemeColor colorval; Widget *theme; GList *name_path; Property *property; |