1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

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_DOUBLE,
P_STRING, P_STRING,
P_BOOLEAN, P_BOOLEAN,
P_COLOR P_COLOR,
// Used in padding.
P_PADDING,
} PropertyType; } PropertyType;
typedef struct typedef struct
@ -40,6 +42,7 @@ typedef struct {
char *s; char *s;
int b; int b;
ThemeColor color; ThemeColor color;
Padding padding;
} value; } value;
} Property; } Property;

View file

@ -23,7 +23,9 @@ WHITESPACE [[:space:]]
WORD [[:alnum:]-]+ WORD [[:alnum:]-]+
STRING [[:print:]]+ STRING [[:print:]]+
HEX [[:xdigit:]] HEX [[:xdigit:]]
NUMBER [[:digit:]-] NUMBER [[:digit:]]
PX (px)
NEWLINES (\r|\n)+
%x PROPERTIES %x PROPERTIES
%x NAMESTR %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}+ { 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>{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>\"{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} { <PROPERTIES>#{HEX}{8} {
union { unsigned int val; struct { unsigned char b,g,r,a;};} val; 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)strtoull ( &yytext[1], NULL, 16);
@ -146,7 +153,8 @@ if ( queue == NULL ){
return T_COLOR; return T_COLOR;
} }
<*>(\r\n|\n) { <*>(\r\n) {
printf("newlines\n");
yylloc->last_column = 1; yylloc->last_column = 1;
yylloc->last_line ++; yylloc->last_line ++;
}; };

View file

@ -11,6 +11,7 @@
%{ %{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <glib.h>
#include "theme.h" #include "theme.h"
@ -39,6 +40,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token <sval> NAME_ELEMENT %token <sval> NAME_ELEMENT
%token <bval> T_BOOLEAN %token <bval> T_BOOLEAN
%token <colorval> T_COLOR %token <colorval> T_COLOR
%token <ival> T_PIXEL
%token <sval> CLASS_NAME %token <sval> CLASS_NAME
%token <sval> FIRST_NAME %token <sval> FIRST_NAME
@ -165,6 +167,16 @@ property
$$->name = $1; $$->name = $1;
$$->value.b = $3; $$->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; } 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 ) 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 ); 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 ){ 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; return pad;
} }