Padding should be specified in px now and 4 borders can be specified on

one pixel line.
This commit is contained in:
Dave Davenport 2016-12-31 21:37:19 +01:00
parent 2bfbb464e6
commit 5f424fa598
4 changed files with 28 additions and 31 deletions

View File

@ -7,7 +7,9 @@ typedef enum {
P_DOUBLE,
P_STRING,
P_BOOLEAN,
P_COLOR
P_COLOR,
// Used in padding.
P_PADDING,
} PropertyType;
typedef struct
@ -40,6 +42,7 @@ typedef struct {
char *s;
int b;
ThemeColor color;
Padding padding;
} value;
} Property;

View File

@ -23,7 +23,9 @@ WHITESPACE [[:space:]]
WORD [[:alnum:]-]+
STRING [[:print:]]+
HEX [[:xdigit:]]
NUMBER [[:digit:]-]
NUMBER [[:digit:]]
PX (px)
NEWLINES (\r|\n)+
%x PROPERTIES
%x NAMESTR
@ -102,6 +104,11 @@ if ( queue == NULL ){
<PROPERTIES>{NUMBER}+ { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
<PROPERTIES>{NUMBER}+\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
<PROPERTIES>\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;}
<PROPERTIES>{NUMBER}+{PX} {
yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10);
return T_PIXEL;
}
<PROPERTIES>#{HEX}{8} {
union { unsigned int val; struct { unsigned char b,g,r,a;};} val;
val.val = (unsigned int)strtoull ( &yytext[1], NULL, 16);
@ -146,7 +153,8 @@ if ( queue == NULL ){
return T_COLOR;
}
<*>(\r\n|\n) {
<*>(\r\n) {
printf("newlines\n");
yylloc->last_column = 1;
yylloc->last_line ++;
};

View File

@ -11,6 +11,7 @@
%{
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include "theme.h"
@ -39,6 +40,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token <sval> NAME_ELEMENT
%token <bval> T_BOOLEAN
%token <colorval> T_COLOR
%token <ival> T_PIXEL
%token <sval> CLASS_NAME
%token <sval> FIRST_NAME
@ -165,6 +167,16 @@ property
$$->name = $1;
$$->value.b = $3;
}
| pvalue PSEP T_PIXEL PCLOSE {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (Padding){ $3, $3, $3, $3, FALSE };
}
| pvalue PSEP T_PIXEL T_PIXEL T_PIXEL T_PIXEL PCLOSE {
$$ = rofi_theme_property_create ( P_PADDING );
$$->name = $1;
$$->value.padding = (Padding){ $3, $4, $5, $6, FALSE };
}
;
pvalue: N_STRING { $$ = $1; }

View File

@ -285,35 +285,9 @@ void rofi_theme_get_color ( const char *wclass, const char *name, const char *s
Padding rofi_theme_get_padding ( const char *wclass, const char *name, const char *state, const char *property, Padding pad )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
if ( p ){
pad.left = pad.top = pad.bottom = pad.right = p->value.i;
pad = p->value.padding;
}
char *s = g_strdup_printf("%s-top", property);
p = rofi_theme_find_property ( widget, P_INTEGER, s );
if ( p ){
pad.top = p->value.i;
}
g_free(s);
s = g_strdup_printf("%s-left", property);
p = rofi_theme_find_property ( widget, P_INTEGER, s );
if ( p ){
pad.left = p->value.i;
}
g_free(s);
s = g_strdup_printf("%s-bottom", property);
p = rofi_theme_find_property ( widget, P_INTEGER, s );
if ( p ){
pad.bottom = p->value.i;
}
g_free(s);
s = g_strdup_printf("%s-right", property);
p = rofi_theme_find_property ( widget, P_INTEGER, s );
if ( p ){
pad.right = p->value.i;
}
g_free(s);
return pad;
}