[Theme3.0] Change reference to use the CSS like var() syntax.

Supports defaults var(name, default); var(name);
Where default can be another property.
(https://www.w3schools.com/css/css3_variables.asp)

This deprecates the @name syntax.

Fixes: #876
This commit is contained in:
Dave Davenport 2019-01-29 17:56:45 +01:00
parent 964af7ad35
commit 40da1b25e2
6 changed files with 342 additions and 288 deletions

View File

@ -2,37 +2,37 @@
* rofi -dump-theme output.
**/
* {
selected-normal-foreground: @lightbg;
selected-normal-foreground: var(lightbg);
foreground: rgba ( 0, 43, 54, 100 % );
normal-foreground: @foreground;
alternate-normal-background: @lightbg;
normal-foreground: var(foreground);
alternate-normal-background: var(lightbg);
red: rgba ( 220, 50, 47, 100 % );
selected-urgent-foreground: @background;
selected-urgent-foreground: var(background);
blue: rgba ( 38, 139, 210, 100 % );
urgent-foreground: @red;
alternate-urgent-background: @lightbg;
active-foreground: @blue;
urgent-foreground: var(red);
alternate-urgent-background: var(lightbg);
active-foreground: var(blue);
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: @background;
alternate-active-background: @lightbg;
selected-active-foreground: var(background);
alternate-active-background: var(lightbg);
background: rgba ( 253, 246, 227, 100 % );
alternate-normal-foreground: @foreground;
normal-background: @background;
alternate-normal-foreground: var(foreground);
normal-background: var(background);
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: @lightfg;
border-color: @foreground;
selected-normal-background: var(lightfg);
border-color: var(foreground);
spacing: 2;
separatorcolor: @foreground;
urgent-background: @background;
selected-urgent-background: @red;
alternate-urgent-foreground: @red;
separatorcolor: var(foreground);
urgent-background: var(background);
selected-urgent-background: var(red);
alternate-urgent-foreground: var(red);
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @blue;
active-background: @background;
selected-active-background: @blue;
alternate-active-foreground: var(blue);
active-background: var(background);
selected-active-background: var(blue);
}
window {
background-color: @background;
background-color: var(background);
border: 1;
padding: 5;
}
@ -42,16 +42,16 @@ mainbox {
}
message {
border: 2px dash 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
padding: 1px ;
}
textbox {
text-color: @foreground;
text-color: var(foreground);
}
listview {
fixed-height: 0;
border: 2px dash 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
spacing: 2px ;
scrollbar: true;
padding: 2px 0px 0px ;
@ -61,77 +61,77 @@ element {
padding: 1px ;
}
element normal.normal {
background-color: @normal-background;
text-color: @normal-foreground;
background-color: var(normal-background);
text-color: var(normal-foreground);
}
element normal.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
background-color: var(urgent-background);
text-color: var(urgent-foreground);
}
element normal.active {
background-color: @active-background;
text-color: @active-foreground;
background-color: var(active-background);
text-color: var(active-foreground);
}
element selected.normal {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
background-color: var(selected-normal-background);
text-color: var(selected-normal-foreground);
}
element selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
background-color: var(selected-urgent-background);
text-color: var(selected-urgent-foreground);
}
element selected.active {
background-color: @selected-active-background;
text-color: @selected-active-foreground;
background-color: var(selected-active-background);
text-color: var(selected-active-foreground);
}
element alternate.normal {
background-color: @alternate-normal-background;
text-color: @alternate-normal-foreground;
background-color: var(alternate-normal-background);
text-color: var(alternate-normal-foreground);
}
element alternate.urgent {
background-color: @alternate-urgent-background;
text-color: @alternate-urgent-foreground;
background-color: var(alternate-urgent-background);
text-color: var(alternate-urgent-foreground);
}
element alternate.active {
background-color: @alternate-active-background;
text-color: @alternate-active-foreground;
background-color: var(alternate-active-background);
text-color: var(alternate-active-foreground);
}
scrollbar {
width: 4px ;
border: 0;
handle-color: @normal-foreground;
handle-color: var(normal-foreground);
handle-width: 8px ;
padding: 0;
}
sidebar {
border: 2px dash 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
}
button {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
button selected {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
background-color: var(selected-normal-background);
text-color: var(selected-normal-foreground);
}
inputbar {
spacing: 0px ;
text-color: @normal-foreground;
text-color: var(normal-foreground);
padding: 1px ;
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
case-indicator {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
entry {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
prompt {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
textbox-prompt-colon {
expand: false;
@ -141,5 +141,5 @@ textbox-prompt-colon {
}
error-message {
background-color: rgba ( 0, 0, 0, 0 % );
text-color: @normal-foreground;
text-color: var(normal-foreground);
}

View File

@ -4,7 +4,7 @@
* {
selected-normal-foreground: rgba ( 2, 20, 63, 100 % );
foreground: rgba ( 219, 223, 188, 100 % );
normal-foreground: @foreground;
normal-foreground: var(foreground);
alternate-normal-background: rgba ( 0, 0, 0, 0 % );
red: rgba ( 220, 50, 47, 100 % );
selected-urgent-foreground: rgba ( 2, 20, 63, 100 % );
@ -16,7 +16,7 @@
selected-active-foreground: rgba ( 2, 20, 63, 100 % );
alternate-active-background: rgba ( 0, 0, 0, 0 % );
background: rgba ( 0, 0, 33, 87 % );
alternate-normal-foreground: @foreground;
alternate-normal-foreground: var(foreground);
normal-background: rgba ( 0, 0, 0, 0 % );
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: rgba ( 219, 223, 188, 100 % );
@ -25,14 +25,14 @@
separatorcolor: rgba ( 219, 223, 188, 100 % );
urgent-background: rgba ( 0, 0, 0, 0 % );
selected-urgent-background: rgba ( 255, 129, 127, 100 % );
alternate-urgent-foreground: @urgent-foreground;
alternate-urgent-foreground: var(urgent-foreground);
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @active-foreground;
alternate-active-foreground: var(active-foreground);
active-background: rgba ( 0, 0, 0, 0 % );
selected-active-background: rgba ( 138, 196, 255, 100 % );
}
window {
background-color: @background;
background-color: var(background);
border: 1;
padding: 5;
}
@ -42,16 +42,16 @@ mainbox {
}
message {
border: 2px 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
padding: 1px ;
}
textbox {
text-color: @foreground;
text-color: var(foreground);
}
listview {
fixed-height: 0;
border: 2px 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
spacing: 2px ;
scrollbar: true;
padding: 2px 0px 0px ;
@ -61,77 +61,77 @@ element {
padding: 1px ;
}
element normal.normal {
background-color: @normal-background;
text-color: @normal-foreground;
background-color: var(normal-background);
text-color: var(normal-foreground);
}
element normal.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
background-color: var(urgent-background);
text-color: var(urgent-foreground);
}
element normal.active {
background-color: @active-background;
text-color: @active-foreground;
background-color: var(active-background);
text-color: var(active-foreground);
}
element selected.normal {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
background-color: var(selected-normal-background);
text-color: var(selected-normal-foreground);
}
element selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
background-color: var(selected-urgent-background);
text-color: var(selected-urgent-foreground);
}
element selected.active {
background-color: @selected-active-background;
text-color: @selected-active-foreground;
background-color: var(selected-active-background);
text-color: var(selected-active-foreground);
}
element alternate.normal {
background-color: @alternate-normal-background;
text-color: @alternate-normal-foreground;
background-color: var(alternate-normal-background);
text-color: var(alternate-normal-foreground);
}
element alternate.urgent {
background-color: @alternate-urgent-background;
text-color: @alternate-urgent-foreground;
background-color: var(alternate-urgent-background);
text-color: var(alternate-urgent-foreground);
}
element alternate.active {
background-color: @alternate-active-background;
text-color: @alternate-active-foreground;
background-color: var(alternate-active-background);
text-color: var(alternate-active-foreground);
}
scrollbar {
width: 4px ;
border: 0;
handle-color: @normal-foreground;
handle-color: var(normal-foreground);
handle-width: 8px ;
padding: 0;
}
sidebar {
border: 2px 0px 0px ;
border-color: @separatorcolor;
border-color: var(separatorcolor);
}
button {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
button selected {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
background-color: var(selected-normal-background);
text-color: var(selected-normal-foreground);
}
inputbar {
spacing: 0px ;
text-color: @normal-foreground;
text-color: var(normal-foreground);
padding: 1px ;
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
case-indicator {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
entry {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
prompt {
spacing: 0;
text-color: @normal-foreground;
text-color: var(normal-foreground);
}
textbox-prompt-colon {
expand: false;
@ -141,5 +141,5 @@ textbox-prompt-colon {
}
error-message {
background-color: rgba ( 0, 0, 0, 0 % );
text-color: @normal-foreground;
text-color: var(normal-foreground);
}

View File

@ -176,7 +176,7 @@ typedef enum
WL_SOUTH_WEST = WL_SOUTH | WL_WEST,
} WindowLocation;
typedef union
typedef union _PropertyValue
{
/** integer */
int i;
@ -197,6 +197,8 @@ typedef union
char *name;
/** Cached looked up ref */
struct Property *ref;
/** Property default */
struct Property *def_value;
} link;
/** Highlight Style */
RofiHighlightColorStyle highlight;

View File

@ -229,6 +229,8 @@ FORWARD_SLASH \/
LIST_OPEN \[
LIST_CLOSE \]
VAR_START "var"
CPP_COMMENT "//"
C_COMMENT_OPEN "/*"
@ -241,6 +243,8 @@ CONFIGURATION (?i:configuration)
%x INCLUDE
%x PROPERTIES
%x PROPERTIES_ENV
%x PROPERTIES_VAR
%x PROPERTIES_VAR_DEFAULT
%x PROPERTIES_LIST
%x NAMESTR
%x SECTION
@ -419,30 +423,30 @@ if ( queue == NULL ){
/* After Namestr/Classstr we want to go to state str, then to { */
<INITIAL,SECTION>{WHITESPACE}+ ; // ignore all whitespace
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_LIST>{WHITESPACE}+ ; // ignore all whitespace
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST,PROPERTIES_VAR>{WHITESPACE}+ ; // ignore all whitespace
<SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; }
<PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;}
<PROPERTIES,PROPERTIES_ENV>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
<PROPERTIES,PROPERTIES_ENV>{PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
<PROPERTIES,PROPERTIES_ENV>{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
<PROPERTIES,PROPERTIES_ENV>{STRING} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;}
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{STRING} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;}
<PROPERTIES,PROPERTIES_ENV>@{WORD} {
yylval->sval = g_strdup(yytext);
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>@{WORD} {
yylval->sval = g_strdup(yytext+1);
return T_LINK;
}
<PROPERTIES,PROPERTIES_ENV>{EM} { return T_UNIT_EM; }
<PROPERTIES,PROPERTIES_ENV>{CH} { return T_UNIT_CH; }
<PROPERTIES,PROPERTIES_ENV>{PX} { return T_UNIT_PX; }
<PROPERTIES,PROPERTIES_ENV>{PERCENT} { return T_PERCENT; }
<PROPERTIES,PROPERTIES_ENV>{LS_SOLID} { return T_SOLID; }
<PROPERTIES,PROPERTIES_ENV>{LS_DASH} { return T_DASH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{EM} { return T_UNIT_EM; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CH} { return T_UNIT_CH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{PX} { return T_UNIT_PX; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{PERCENT} { return T_PERCENT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LS_SOLID} { return T_SOLID; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LS_DASH} { return T_DASH; }
<PROPERTIES,PROPERTIES_ENV>{INHERIT} { return T_INHERIT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{INHERIT} { return T_INHERIT; }
<PROPERTIES,PROPERTIES_ENV>{ENV} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ENV} {
yytext[yyleng-1] = '\0';
const char *val = g_getenv(yytext+2);
if ( val ) {
@ -468,54 +472,74 @@ if ( queue == NULL ){
* Color parsing. It is easier to do this at lexer level.
* Other schemes are done at yacc level.
*/
<PROPERTIES,PROPERTIES_ENV>#{HEX}{8} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>#{HEX}{8} {
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;
}
<PROPERTIES,PROPERTIES_ENV>#{HEX}{6} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>#{HEX}{6} {
yylval->colorval.alpha = 1.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;
}
<PROPERTIES,PROPERTIES_ENV>#{HEX}{3} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>#{HEX}{3} {
yylval->colorval.alpha = 1.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;
}
<PROPERTIES,PROPERTIES_ENV>#{HEX}{4} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>#{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;
}
<PROPERTIES,PROPERTIES_ENV>argb:{HEX}{8} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>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;
}
<PROPERTIES,PROPERTIES_ENV>argb:{HEX}{7} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>argb:{HEX}{7} {
return T_ERROR_ARGB_SPEC;
}
/* Color schemes */
<PROPERTIES,PROPERTIES_ENV>{RGBA} { return T_COL_RGBA; }
<PROPERTIES,PROPERTIES_ENV>{HSL} { return T_COL_HSL; }
<PROPERTIES,PROPERTIES_ENV>{HWB} { return T_COL_HWB; }
<PROPERTIES,PROPERTIES_ENV>{CMYK} { return T_COL_CMYK; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{RGBA} { return T_COL_RGBA; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{HSL} { return T_COL_HSL; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{HWB} { return T_COL_HWB; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CMYK} { return T_COL_CMYK; }
/* Fluff */
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{VAR_START}{S_T_PARENT_LEFT} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(PROPERTIES_VAR);
return T_VAR_START;
}
<PROPERTIES_VAR>{S_T_PARENT_RIGHT} {
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
return T_VAR_CLOSE;
}
<PROPERTIES_VAR>{COMMA} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(PROPERTIES_VAR_DEFAULT);
return T_COMMA;
}
<PROPERTIES_VAR_DEFAULT>{S_T_PARENT_RIGHT} {
// Pop 2.
g_queue_pop_head ( queue );
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
return T_VAR_CLOSE;
}
<PROPERTIES,PROPERTIES_ENV>{S_T_PARENT_LEFT} { return T_PARENT_LEFT; }
<PROPERTIES,PROPERTIES_ENV>{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_LIST>{COMMA} { return T_COMMA; }
<PROPERTIES,PROPERTIES_ENV>{LIST_OPEN} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST>{COMMA} { return T_COMMA; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LIST_OPEN} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(PROPERTIES_LIST);
return T_LIST_OPEN;
@ -524,33 +548,33 @@ if ( queue == NULL ){
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
return T_LIST_CLOSE;
}
<PROPERTIES,PROPERTIES_ENV>{FORWARD_SLASH} { return T_FORWARD_SLASH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{FORWARD_SLASH} { return T_FORWARD_SLASH; }
/* Position */
<PROPERTIES,PROPERTIES_ENV>{CENTER} { return T_POS_CENTER; }
<PROPERTIES,PROPERTIES_ENV>{EAST} { return T_POS_EAST; }
<PROPERTIES,PROPERTIES_ENV>{WEST} { return T_POS_WEST; }
<PROPERTIES,PROPERTIES_ENV>{SOUTH} { return T_POS_SOUTH; }
<PROPERTIES,PROPERTIES_ENV>{NORTH} { return T_POS_NORTH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CENTER} { return T_POS_CENTER; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{EAST} { return T_POS_EAST; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{WEST} { return T_POS_WEST; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{SOUTH} { return T_POS_SOUTH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{NORTH} { return T_POS_NORTH; }
/* Highlight style */
<PROPERTIES,PROPERTIES_ENV>{NONE} { return T_NONE; }
<PROPERTIES,PROPERTIES_ENV>{BOLD} { return T_BOLD; }
<PROPERTIES,PROPERTIES_ENV>{ITALIC} { return T_ITALIC; }
<PROPERTIES,PROPERTIES_ENV>{UNDERLINE} { return T_UNDERLINE; }
<PROPERTIES,PROPERTIES_ENV>{STRIKETHROUGH} { return T_STRIKETHROUGH; }
<PROPERTIES,PROPERTIES_ENV>{SMALLCAPS} { return T_SMALLCAPS; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{NONE} { return T_NONE; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{BOLD} { return T_BOLD; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ITALIC} { return T_ITALIC; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{UNDERLINE} { return T_UNDERLINE; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{STRIKETHROUGH} { return T_STRIKETHROUGH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{SMALLCAPS} { return T_SMALLCAPS; }
<PROPERTIES,PROPERTIES_ENV>{ANGLE_DEG} { return T_ANGLE_DEG; }
<PROPERTIES,PROPERTIES_ENV>{ANGLE_RAD} { return T_ANGLE_RAD; }
<PROPERTIES,PROPERTIES_ENV>{ANGLE_GRAD} { return T_ANGLE_GRAD; }
<PROPERTIES,PROPERTIES_ENV>{ANGLE_TURN} { return T_ANGLE_TURN; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_DEG} { return T_ANGLE_DEG; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_RAD} { return T_ANGLE_RAD; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_GRAD} { return T_ANGLE_GRAD; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_TURN} { return T_ANGLE_TURN; }
<PROPERTIES,PROPERTIES_ENV>{ORIENTATION_HORI} { return ORIENTATION_HORI; }
<PROPERTIES,PROPERTIES_ENV>{ORIENTATION_VERT} { return ORIENTATION_VERT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ORIENTATION_HORI} { return ORIENTATION_HORI; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ORIENTATION_VERT} { return ORIENTATION_VERT; }
<PROPERTIES,PROPERTIES_ENV>{COLOR_TRANSPARENT} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{COLOR_TRANSPARENT} {
return T_COLOR_TRANSPARENT;
}
<PROPERTIES,PROPERTIES_ENV>{COLOR_NAME} {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{COLOR_NAME} {
for ( unsigned int iter = 0; iter < num_CSSColors; iter++){
if ( strcasecmp(yytext, CSSColors[iter].name )== 0 ) {
yylval->colorval.alpha = 1.0;
@ -563,7 +587,7 @@ if ( queue == NULL ){
REJECT;
}
<INITIAL,PROPERTIES_ENV><<EOF>> {
<INITIAL,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT><<EOF>> {
ParseObject *po = g_queue_pop_head ( file_queue );
if ( po ) {
if ( po->type == PT_FILE ){
@ -610,7 +634,7 @@ if ( queue == NULL ){
<SECTION>. {
return T_ERROR_SECTION;
}
<PROPERTIES_LIST>{WORD} {
<PROPERTIES_LIST,PROPERTIES_VAR>{WORD} {
yylval->sval = g_strdup(yytext);
return T_ELEMENT;
}
@ -620,7 +644,7 @@ if ( queue == NULL ){
return T_ELEMENT;
}
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_LIST>. {
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST>. {
return T_ERROR_PROPERTY;
}
<NAMESTR>. {

View File

@ -199,6 +199,8 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_COL_HWB "hwb colorscheme"
%token T_COL_CMYK "cmyk colorscheme"
%token T_VAR_START "Variable"
%token T_VAR_CLOSE "Variable close"
%token T_PARENT_LEFT "Parent left ('(')"
%token T_PARENT_RIGHT "Parent right (')')"
%token T_COMMA "comma separator (',')"
@ -228,6 +230,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%type <list> t_entry_name_path
%type <list> t_entry_name_path_selectors
%type <property> t_property
%type <property> t_property_element
%type <property_list> t_property_list
%type <property_list> t_property_list_optional
%type <colorval> t_property_color
@ -361,85 +364,86 @@ t_property_list:
;
t_property
: t_property_name T_PSEP T_INHERIT T_PCLOSE {
$$ = rofi_theme_property_create ( P_INHERIT );
$$->name = $1;
}
| t_property_name T_PSEP T_INT T_PCLOSE {
$$ = rofi_theme_property_create ( P_INTEGER );
$$->name = $1;
$$->value.i = $3;
}
| t_property_name T_PSEP T_DOUBLE T_PCLOSE {
$$ = rofi_theme_property_create ( P_DOUBLE );
$$->name = $1;
$$->value.f = $3;
}
| t_property_name T_PSEP T_STRING T_PCLOSE {
$$ = rofi_theme_property_create ( P_STRING );
$$->name = $1;
$$->value.s = $3;
}
| t_property_name T_PSEP T_LINK T_PCLOSE {
: t_property_name T_PSEP t_property_element T_PCLOSE {
$$ = $3;
$$->name = $1;
}
| t_property_name T_PSEP T_VAR_START T_ELEMENT T_VAR_CLOSE T_PCLOSE{
$$ = rofi_theme_property_create ( P_LINK );
$$->name = $1;
$$->value.link.name = $3;
$$->value.link.name = $4;
}
| t_property_name T_PSEP T_BOOLEAN T_PCLOSE {
| t_property_name T_PSEP T_VAR_START T_ELEMENT T_COMMA t_property_element T_VAR_CLOSE T_PCLOSE{
$$ = rofi_theme_property_create ( P_LINK );
$$->name = $1;
$$->value.link.name = $4;
$$->value.link.def_value = $6;
}
t_property_element
: T_INHERIT {
$$ = rofi_theme_property_create ( P_INHERIT );
}
| T_INT {
$$ = rofi_theme_property_create ( P_INTEGER );
$$->value.i = $1;
}
| T_DOUBLE {
$$ = rofi_theme_property_create ( P_DOUBLE );
$$->value.f = $1;
}
| T_STRING {
$$ = rofi_theme_property_create ( P_STRING );
$$->value.s = $1;
}
| T_LINK {
$$ = rofi_theme_property_create ( P_LINK );
$$->value.link.name = $1;
}
| T_BOOLEAN {
$$ = rofi_theme_property_create ( P_BOOLEAN );
$$->name = $1;
$$->value.b = $3;
$$->value.b = $1;
}
| t_property_name T_PSEP t_property_distance T_PCLOSE {
| t_property_distance {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (RofiPadding){ $3, $3, $3, $3 };
$$->value.padding = (RofiPadding){ $1, $1, $1, $1 };
}
| t_property_name T_PSEP t_property_distance_zero t_property_distance_zero T_PCLOSE {
| t_property_distance_zero t_property_distance_zero {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (RofiPadding){ $3, $4, $3, $4 };
$$->value.padding = (RofiPadding){ $1, $2, $1, $2 };
}
| t_property_name T_PSEP t_property_distance_zero t_property_distance_zero t_property_distance_zero T_PCLOSE {
| t_property_distance_zero t_property_distance_zero t_property_distance_zero {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (RofiPadding){ $3, $4, $5, $4 };
$$->value.padding = (RofiPadding){ $1, $2, $3, $2 };
}
| t_property_name T_PSEP t_property_distance_zero t_property_distance_zero t_property_distance_zero t_property_distance_zero T_PCLOSE {
| t_property_distance_zero t_property_distance_zero t_property_distance_zero t_property_distance_zero {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (RofiPadding){ $3, $4, $5, $6 };
$$->value.padding = (RofiPadding){ $1, $2, $3, $4 };
}
| t_property_name T_PSEP t_property_position T_PCLOSE{
| t_property_position {
$$ = rofi_theme_property_create ( P_POSITION );
$$->name = $1;
$$->value.i = $3;
$$->value.i = $1;
}
| t_property_name T_PSEP t_property_highlight_styles t_property_color T_PCLOSE {
| t_property_highlight_styles t_property_color {
$$ = rofi_theme_property_create ( P_HIGHLIGHT );
$$->name = $1;
$$->value.highlight.style = $3|ROFI_HL_COLOR;
$$->value.highlight.color = $4;
$$->value.highlight.style = $1|ROFI_HL_COLOR;
$$->value.highlight.color = $2;
}
| t_property_name T_PSEP t_property_highlight_styles T_PCLOSE {
| t_property_highlight_styles {
$$ = rofi_theme_property_create ( P_HIGHLIGHT );
$$->name = $1;
$$->value.highlight.style = $3;
$$->value.highlight.style = $1;
}
| t_property_name T_PSEP t_property_color T_PCLOSE {
| t_property_color {
$$ = rofi_theme_property_create ( P_COLOR );
$$->name = $1;
$$->value.color = $3;
$$->value.color = $1;
}
| t_property_name T_PSEP T_LIST_OPEN t_property_element_list_optional T_LIST_CLOSE T_PCLOSE {
| T_LIST_OPEN t_property_element_list_optional T_LIST_CLOSE {
$$ = rofi_theme_property_create ( P_LIST );
$$->name = $1;
$$->value.list = $4;
$$->value.list = $2;
}
| t_property_name T_PSEP t_property_orientation T_PCLOSE {
| t_property_orientation {
$$ = rofi_theme_property_create ( P_ORIENTATION );
$$->name = $1;
$$->value.i = $3;
$$->value.i = $1;
}
;

View File

@ -91,6 +91,9 @@ Property* rofi_theme_property_copy ( Property *p )
case P_LINK:
retv->value.link.name = g_strdup ( p->value.link.name );
retv->value.link.ref = NULL;
if ( p->value.link.def_value ){
retv->value.link.def_value = rofi_theme_property_copy(p->value.link.def_value);
}
break;
default:
retv->value = p->value;
@ -109,6 +112,9 @@ void rofi_theme_property_free ( Property *p )
}
else if ( p->type == P_LINK ) {
g_free ( p->value.link.name );
if ( p->value.link.def_value ) {
rofi_theme_property_free ( p->value.link.def_value );
}
}
g_slice_free ( Property, p );
}
@ -176,103 +182,114 @@ const char * const WindowLocationStr[9] = {
"west"
};
static void int_rofi_theme_print_property ( Property *p )
{
switch ( p->type )
{
case P_LIST:
printf ( "[ " );
for ( GList *iter = p->value.list; iter != NULL; iter = g_list_next ( iter ) ) {
printf ( "%s", (char *) ( iter->data ) );
if ( iter->next != NULL ) {
printf ( "," );
}
}
printf ( " ]" );
break;
case P_ORIENTATION:
printf ( "%s", ( p->value.i == ROFI_ORIENTATION_HORIZONTAL ) ? "horizontal" : "vertical" );
break;
case P_HIGHLIGHT:
if ( p->value.highlight.style & ROFI_HL_BOLD ) {
printf ( "bold " );
}
if ( p->value.highlight.style & ROFI_HL_UNDERLINE ) {
printf ( "underline " );
}
if ( p->value.highlight.style & ROFI_HL_STRIKETHROUGH ) {
printf ( "strikethrough " );
}
if ( p->value.highlight.style & ROFI_HL_ITALIC ) {
printf ( "italic " );
}
if ( p->value.highlight.style & ROFI_HL_COLOR ) {
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 ) );
}
break;
case P_POSITION:
printf ( "%s", WindowLocationStr[p->value.i] );
break;
case P_STRING:
printf ( "\"%s\"", p->value.s );
break;
case P_INTEGER:
printf ( "%d", p->value.i );
break;
case P_DOUBLE:
printf ( "%.2f", p->value.f );
break;
case P_BOOLEAN:
printf ( "%s", p->value.b ? "true" : "false" );
break;
case P_COLOR:
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 ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) &&
distance_compare ( p->value.padding.left, p->value.padding.top ) ) {
rofi_theme_print_distance ( p->value.padding.left );
}
else if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) ) {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.left );
}
else if ( !distance_compare ( p->value.padding.top, p->value.padding.bottom ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) ) {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.left );
rofi_theme_print_distance ( p->value.padding.bottom );
}
else {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.right );
rofi_theme_print_distance ( p->value.padding.bottom );
rofi_theme_print_distance ( p->value.padding.left );
}
break;
case P_LINK:
if ( p->value.link.def_value) {
printf( "var( %s, ", p->value.link.name );
int_rofi_theme_print_property ( p->value.link.def_value );
printf (")");
}else {
printf ( "var(%s)", p->value.link.name );
}
break;
case P_INHERIT:
printf ( "inherit" );
break;
default:
break;
}
}
static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p )
{
int pl = strlen ( p->name );
printf ( "%*s%s:%*s ", depth, "", p->name, (int) pnl - pl, "" );
switch ( p->type )
{
case P_LIST:
printf ( "[ " );
for ( GList *iter = p->value.list; iter != NULL; iter = g_list_next ( iter ) ) {
printf ( "%s", (char *) ( iter->data ) );
if ( iter->next != NULL ) {
printf ( "," );
}
}
printf ( " ];" );
break;
case P_ORIENTATION:
printf ( "%s;", ( p->value.i == ROFI_ORIENTATION_HORIZONTAL ) ? "horizontal" : "vertical" );
break;
case P_HIGHLIGHT:
if ( p->value.highlight.style & ROFI_HL_BOLD ) {
printf ( "bold " );
}
if ( p->value.highlight.style & ROFI_HL_UNDERLINE ) {
printf ( "underline " );
}
if ( p->value.highlight.style & ROFI_HL_STRIKETHROUGH ) {
printf ( "strikethrough " );
}
if ( p->value.highlight.style & ROFI_HL_ITALIC ) {
printf ( "italic " );
}
if ( p->value.highlight.style & ROFI_HL_COLOR ) {
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;
case P_POSITION:
printf ( "%s;", WindowLocationStr[p->value.i] );
break;
case P_STRING:
printf ( "\"%s\";", p->value.s );
break;
case P_INTEGER:
printf ( "%d;", p->value.i );
break;
case P_DOUBLE:
printf ( "%.2f;", p->value.f );
break;
case P_BOOLEAN:
printf ( "%s;", p->value.b ? "true" : "false" );
break;
case P_COLOR:
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 ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) &&
distance_compare ( p->value.padding.left, p->value.padding.top ) ) {
rofi_theme_print_distance ( p->value.padding.left );
}
else if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) ) {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.left );
}
else if ( !distance_compare ( p->value.padding.top, p->value.padding.bottom ) &&
distance_compare ( p->value.padding.left, p->value.padding.right ) ) {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.left );
rofi_theme_print_distance ( p->value.padding.bottom );
}
else {
rofi_theme_print_distance ( p->value.padding.top );
rofi_theme_print_distance ( p->value.padding.right );
rofi_theme_print_distance ( p->value.padding.bottom );
rofi_theme_print_distance ( p->value.padding.left );
}
printf ( ";" );
break;
case P_LINK:
printf ( "%s;", p->value.link.name );
break;
case P_INHERIT:
printf ( "inherit;" );
break;
default:
break;
}
int_rofi_theme_print_property ( p );
putchar ( ';' );
putchar ( '\n' );
}
@ -439,7 +456,8 @@ static ThemeWidget *rofi_theme_find ( ThemeWidget *widget, const char *name, con
static void rofi_theme_resolve_link_property ( Property *p, int depth )
{
// Set name, remove '@' prefix.
const char *name = p->value.link.name + 1;
const char *name = p->value.link.name;// + (*(p->value.link.name)== '@'?1:0;
g_info ( "Resolving link to %s", p->value.link.name);
if ( depth > 20 ) {
g_warning ( "Found more then 20 redirects for property. Stopping." );
p->value.link.ref = p;
@ -448,6 +466,7 @@ static void rofi_theme_resolve_link_property ( Property *p, int depth )
if ( rofi_theme->properties && g_hash_table_contains ( rofi_theme->properties, name ) ) {
Property *pr = g_hash_table_lookup ( rofi_theme->properties, name );
g_info ("Resolving link %s found: %s", p->value.link.name, pr->name);
if ( pr->type == P_LINK ) {
if ( pr->value.link.ref == NULL ) {
rofi_theme_resolve_link_property ( pr, depth + 1 );
@ -462,6 +481,11 @@ static void rofi_theme_resolve_link_property ( Property *p, int depth )
return;
}
}
// No found and we have default value.
if ( p->value.link.def_value ){
p->value.link.ref = p->value.link.def_value;
return;
}
// No found, set ref to self.
p->value.link.ref = p;