mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Move position parsing to bison file.
This commit is contained in:
parent
2a381856aa
commit
cf8796ccd3
4 changed files with 73 additions and 50 deletions
|
@ -56,22 +56,22 @@ typedef enum
|
||||||
{
|
{
|
||||||
/** Center */
|
/** Center */
|
||||||
WL_CENTER = 0,
|
WL_CENTER = 0,
|
||||||
/** Left top corner. */
|
|
||||||
WL_NORTH_WEST = 1,
|
|
||||||
/** Top middle */
|
/** Top middle */
|
||||||
WL_NORTH = 2,
|
WL_NORTH = 1,
|
||||||
/** Top right */
|
|
||||||
WL_NORTH_EAST = 3,
|
|
||||||
/** Middle right */
|
/** Middle right */
|
||||||
WL_EAST = 4,
|
WL_EAST = 2,
|
||||||
/** Bottom right */
|
|
||||||
WL_SOUTH_EAST = 5,
|
|
||||||
/** Bottom middle */
|
/** Bottom middle */
|
||||||
WL_SOUTH = 6,
|
WL_SOUTH = 4,
|
||||||
/** Bottom left */
|
|
||||||
WL_SOUTH_WEST = 7,
|
|
||||||
/** Middle left */
|
/** Middle left */
|
||||||
WL_WEST = 8
|
WL_WEST = 8,
|
||||||
|
/** Left top corner. */
|
||||||
|
WL_NORTH_WEST = WL_NORTH|WL_WEST,
|
||||||
|
/** Top right */
|
||||||
|
WL_NORTH_EAST = WL_NORTH|WL_EAST,
|
||||||
|
/** Bottom right */
|
||||||
|
WL_SOUTH_EAST = WL_SOUTH|WL_EAST,
|
||||||
|
/** Bottom left */
|
||||||
|
WL_SOUTH_WEST = WL_SOUTH|WL_WEST,
|
||||||
} WindowLocation;
|
} WindowLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -539,42 +539,11 @@ if ( queue == NULL ){
|
||||||
return T_COLOR;
|
return T_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
<PROPERTIES>{CENTER} {
|
<PROPERTIES>{CENTER} { return T_POS_CENTER; }
|
||||||
yylval->ival = WL_CENTER;
|
<PROPERTIES>{EAST} { return T_POS_EAST; }
|
||||||
return T_POSITION;
|
<PROPERTIES>{WEST} { return T_POS_WEST; }
|
||||||
}
|
<PROPERTIES>{SOUTH} { return T_POS_SOUTH; }
|
||||||
<PROPERTIES>{EAST} {
|
<PROPERTIES>{NORTH} { return T_POS_NORTH; }
|
||||||
yylval->ival = WL_EAST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{WEST} {
|
|
||||||
yylval->ival = WL_WEST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{SOUTH}{EAST} {
|
|
||||||
yylval->ival = WL_SOUTH_EAST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{SOUTH}{WEST} {
|
|
||||||
yylval->ival = WL_SOUTH_WEST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{SOUTH} {
|
|
||||||
yylval->ival = WL_SOUTH;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{NORTH}{EAST} {
|
|
||||||
yylval->ival = WL_NORTH_EAST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{NORTH}{WEST} {
|
|
||||||
yylval->ival = WL_NORTH_WEST;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{NORTH} {
|
|
||||||
yylval->ival = WL_NORTH;
|
|
||||||
return T_POSITION;
|
|
||||||
}
|
|
||||||
<PROPERTIES>{NONE} {
|
<PROPERTIES>{NONE} {
|
||||||
yylval->ival = HL_NONE;
|
yylval->ival = HL_NONE;
|
||||||
return T_HIGHLIGHT_STYLE;
|
return T_HIGHLIGHT_STYLE;
|
||||||
|
|
|
@ -81,6 +81,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
double fval;
|
double fval;
|
||||||
char *sval;
|
char *sval;
|
||||||
int bval;
|
int bval;
|
||||||
|
WindowLocation wloc;
|
||||||
ThemeColor colorval;
|
ThemeColor colorval;
|
||||||
ThemeWidget *theme;
|
ThemeWidget *theme;
|
||||||
GList *name_path;
|
GList *name_path;
|
||||||
|
@ -100,7 +101,6 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token <fval> T_DOUBLE
|
%token <fval> T_DOUBLE
|
||||||
%token <sval> T_STRING
|
%token <sval> T_STRING
|
||||||
%token <sval> N_STRING "property name"
|
%token <sval> N_STRING "property name"
|
||||||
%token <ival> T_POSITION;
|
|
||||||
%token <ival> T_HIGHLIGHT_STYLE
|
%token <ival> T_HIGHLIGHT_STYLE
|
||||||
%token <sval> NAME_ELEMENT "Element name"
|
%token <sval> NAME_ELEMENT "Element name"
|
||||||
%token <bval> T_BOOLEAN
|
%token <bval> T_BOOLEAN
|
||||||
|
@ -108,6 +108,12 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token <distance> T_PIXEL
|
%token <distance> T_PIXEL
|
||||||
%token <sval> T_LINK
|
%token <sval> T_LINK
|
||||||
%token <sval> FIRST_NAME
|
%token <sval> FIRST_NAME
|
||||||
|
%token T_POS_CENTER "Center"
|
||||||
|
%token T_POS_EAST "East"
|
||||||
|
%token T_POS_WEST "West"
|
||||||
|
%token T_POS_NORTH "North"
|
||||||
|
%token T_POS_SOUTH "South"
|
||||||
|
|
||||||
|
|
||||||
%token BOPEN "bracket open ('{')"
|
%token BOPEN "bracket open ('{')"
|
||||||
%token BCLOSE "bracket close ('}')"
|
%token BCLOSE "bracket close ('}')"
|
||||||
|
@ -120,6 +126,9 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token CONFIGURATION "Configuration block"
|
%token CONFIGURATION "Configuration block"
|
||||||
|
|
||||||
%type <ival> highlight_styles
|
%type <ival> highlight_styles
|
||||||
|
%type <wloc> t_position
|
||||||
|
%type <wloc> t_position_ew
|
||||||
|
%type <wloc> t_position_sn
|
||||||
%type <sval> entry
|
%type <sval> entry
|
||||||
%type <sval> pvalue
|
%type <sval> pvalue
|
||||||
%type <theme> entries
|
%type <theme> entries
|
||||||
|
@ -242,7 +251,7 @@ property
|
||||||
$$->name = $1;
|
$$->name = $1;
|
||||||
$$->value.padding = (Padding){ $3, $4, $5, $6 };
|
$$->value.padding = (Padding){ $3, $4, $5, $6 };
|
||||||
}
|
}
|
||||||
| pvalue PSEP T_POSITION PCLOSE{
|
| pvalue PSEP t_position PCLOSE{
|
||||||
$$ = rofi_theme_property_create ( P_POSITION );
|
$$ = rofi_theme_property_create ( P_POSITION );
|
||||||
$$->name = $1;
|
$$->name = $1;
|
||||||
$$->value.i = $3;
|
$$->value.i = $3;
|
||||||
|
@ -260,6 +269,30 @@ property
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position can be either center,
|
||||||
|
* East or West, North Or South
|
||||||
|
* Or combi of East or West and North or South
|
||||||
|
*/
|
||||||
|
t_position
|
||||||
|
: T_POS_CENTER { $$ =WL_CENTER;}
|
||||||
|
| t_position_ew
|
||||||
|
| t_position_sn
|
||||||
|
| t_position_ew t_position_sn { $$ = $1|$2;}
|
||||||
|
| t_position_sn t_position_ew { $$ = $1|$2;}
|
||||||
|
;
|
||||||
|
t_position_ew
|
||||||
|
: T_POS_EAST { $$ = WL_EAST;}
|
||||||
|
| T_POS_WEST { $$ = WL_WEST;}
|
||||||
|
;
|
||||||
|
t_position_sn
|
||||||
|
: T_POS_NORTH { $$ = WL_NORTH;}
|
||||||
|
| T_POS_SOUTH { $$ = WL_SOUTH;}
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Highlight style, allow mulitple styles to be combined.
|
||||||
|
*/
|
||||||
highlight_styles:
|
highlight_styles:
|
||||||
T_HIGHLIGHT_STYLE { $$ = $1; }
|
T_HIGHLIGHT_STYLE { $$ = $1; }
|
||||||
| highlight_styles T_HIGHLIGHT_STYLE {
|
| highlight_styles T_HIGHLIGHT_STYLE {
|
||||||
|
|
|
@ -332,6 +332,27 @@ START_TEST ( test_properties_position)
|
||||||
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southeast", WL_WEST) , WL_SOUTH_EAST);
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southeast", WL_WEST) , WL_SOUTH_EAST);
|
||||||
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northwest", WL_NORTH) , WL_NORTH_WEST);
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northwest", WL_NORTH) , WL_NORTH_WEST);
|
||||||
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northeast", WL_CENTER) , WL_NORTH_EAST);
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northeast", WL_CENTER) , WL_NORTH_EAST);
|
||||||
|
rofi_theme_parse_string ( "* { southwest: south west; southeast: south east; northwest: north west; northeast:north east;}" );
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southwest", WL_EAST) , WL_SOUTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "southeast", WL_WEST) , WL_SOUTH_EAST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northwest", WL_NORTH) , WL_NORTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "northeast", WL_CENTER) , WL_NORTH_EAST);
|
||||||
|
rofi_theme_parse_string ( "* { westsouth: westsouth; eastsouth: eastsouth; westnorth: westnorth; eastnorth:eastnorth;}" );
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westsouth", WL_EAST) , WL_SOUTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastsouth", WL_WEST) , WL_SOUTH_EAST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westnorth", WL_NORTH) , WL_NORTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastnorth", WL_CENTER) , WL_NORTH_EAST);
|
||||||
|
rofi_theme_parse_string ( "* { westsouth: west south; eastsouth: east south; westnorth: west north; eastnorth:east north;}" );
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westsouth", WL_EAST) , WL_SOUTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastsouth", WL_WEST) , WL_SOUTH_EAST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "westnorth", WL_NORTH) , WL_NORTH_WEST);
|
||||||
|
ck_assert_int_eq ( rofi_theme_get_position ( &wid, "eastnorth", WL_CENTER) , WL_NORTH_EAST);
|
||||||
|
rofi_theme_parse_string ( "* { westeast: west east;}" );
|
||||||
|
// Should return error.
|
||||||
|
// TODO: check error message.
|
||||||
|
g_string_free ( error_msg, TRUE);
|
||||||
|
error_msg = NULL;
|
||||||
|
error = 0;
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue