Rename HL_ to ROFI_HL_ and fix box test.

This commit is contained in:
Dave Davenport 2017-06-02 16:09:20 +02:00
parent eec5c6eadc
commit 48bf1709b6
8 changed files with 55 additions and 55 deletions

View file

@ -37,20 +37,20 @@
typedef enum
{
/** no highlight */
HL_NONE = 0,
ROFI_HL_NONE = 0,
/** bold */
HL_BOLD = 1,
ROFI_HL_BOLD = 1,
/** underline */
HL_UNDERLINE = 2,
ROFI_HL_UNDERLINE = 2,
/** strikethrough */
HL_STRIKETHROUGH = 16,
ROFI_HL_STRIKETHROUGH = 16,
/** small caps */
HL_SMALL_CAPS = 32,
ROFI_HL_SMALL_CAPS = 32,
/** italic */
HL_ITALIC = 4,
ROFI_HL_ITALIC = 4,
/** color */
HL_COLOR = 8
} HighlightStyle;
ROFI_HL_COLOR = 8
} RofiHighlightStyle;
/** Style of line */
typedef enum
@ -156,7 +156,7 @@ typedef struct
typedef struct
{
/** style to display */
HighlightStyle style;
RofiHighlightStyle style;
/** Color */
ThemeColor color;
} ThemeHighlight;

View file

@ -358,7 +358,7 @@ t_property
| t_property_name T_PSEP t_property_highlight_styles t_property_color T_PCLOSE {
$$ = rofi_theme_property_create ( P_HIGHLIGHT );
$$->name = $1;
$$->value.highlight.style = $3|HL_COLOR;
$$->value.highlight.style = $3|ROFI_HL_COLOR;
$$->value.highlight.color = $4;
}
| t_property_name T_PSEP t_property_highlight_styles T_PCLOSE {
@ -422,12 +422,12 @@ t_property_highlight_styles
;
/** Single style. */
t_property_highlight_style
: T_NONE { $$ = HL_NONE; }
| T_BOLD { $$ = HL_BOLD; }
| T_UNDERLINE { $$ = HL_UNDERLINE; }
| T_STRIKETHROUGH { $$ = HL_STRIKETHROUGH; }
| T_ITALIC { $$ = HL_ITALIC; }
| T_SMALLCAPS { $$ = HL_SMALL_CAPS; }
: T_NONE { $$ = ROFI_HL_NONE; }
| T_BOLD { $$ = ROFI_HL_BOLD; }
| T_UNDERLINE { $$ = ROFI_HL_UNDERLINE; }
| T_STRIKETHROUGH { $$ = ROFI_HL_STRIKETHROUGH; }
| T_ITALIC { $$ = ROFI_HL_ITALIC; }
| T_SMALLCAPS { $$ = ROFI_HL_SMALL_CAPS; }
;
/** Distance. */

View file

@ -411,37 +411,37 @@ PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **t
for ( int index = ( count > 1 ) ? 1 : 0; index < count; index++ ) {
int start, end;
g_match_info_fetch_pos ( gmi, index, &start, &end );
if ( th.style & HL_BOLD ) {
if ( th.style & ROFI_HL_BOLD ) {
PangoAttribute *pa = pango_attr_weight_new ( PANGO_WEIGHT_BOLD );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
if ( th.style & HL_UNDERLINE ) {
if ( th.style & ROFI_HL_UNDERLINE ) {
PangoAttribute *pa = pango_attr_underline_new ( PANGO_UNDERLINE_SINGLE );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
if ( th.style & HL_STRIKETHROUGH ) {
if ( th.style & ROFI_HL_STRIKETHROUGH ) {
PangoAttribute *pa = pango_attr_strikethrough_new ( TRUE );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
if ( th.style & HL_SMALL_CAPS ) {
if ( th.style & ROFI_HL_SMALL_CAPS ) {
PangoAttribute *pa = pango_attr_variant_new ( PANGO_VARIANT_SMALL_CAPS );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
if ( th.style & HL_ITALIC ) {
if ( th.style & ROFI_HL_ITALIC ) {
PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
if ( th.style & HL_COLOR ) {
if ( th.style & ROFI_HL_COLOR ) {
PangoAttribute *pa = pango_attr_foreground_new (
th.color.red * 65535,
th.color.green * 65535,

View file

@ -164,19 +164,19 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p
switch ( p->type )
{
case P_HIGHLIGHT:
if ( p->value.highlight.style & HL_BOLD ) {
if ( p->value.highlight.style & ROFI_HL_BOLD ) {
printf ( "bold " );
}
if ( p->value.highlight.style & HL_UNDERLINE ) {
if ( p->value.highlight.style & ROFI_HL_UNDERLINE ) {
printf ( "underline " );
}
if ( p->value.highlight.style & HL_STRIKETHROUGH ) {
if ( p->value.highlight.style & ROFI_HL_STRIKETHROUGH ) {
printf ( "strikethrough " );
}
if ( p->value.highlight.style & HL_ITALIC ) {
if ( p->value.highlight.style & ROFI_HL_ITALIC ) {
printf ( "italic " );
}
if ( p->value.highlight.style & HL_COLOR ) {
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 ),

View file

@ -911,7 +911,7 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB
textbox_icon ( t, icon );
if ( state->tokens && config.show_match ) {
ThemeHighlight th = { HL_BOLD | HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
ThemeHighlight th = { ROFI_HL_BOLD | ROFI_HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th );
helper_token_match_get_pango_attr ( th, state->tokens, textbox_get_visible_text ( t ), list );
}

View file

@ -554,12 +554,12 @@ int widget_get_desired_height ( widget *wid )
if ( wid && wid->get_desired_height ) {
return wid->get_desired_height ( wid );
}
return 0;
return wid->h;
}
int widget_get_desired_width ( widget *wid )
{
if ( wid && wid->get_desired_width ) {
return wid->get_desired_width ( wid );
}
return 0;
return wid->w;
}

View file

@ -32,6 +32,7 @@
#include <assert.h>
#include <glib.h>
#include <string.h>
#include <theme.h>
#include <widgets/box.h>
#include <widgets/widget.h>
#include <widgets/widget-internal.h>
@ -91,7 +92,7 @@ void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
{
box *b = box_create ( "box", BOX_HORIZONTAL );
box *b = box_create ( "box", ORIENTATION_HORIZONTAL );
//box_set_padding ( b, 5 );
widget_resize ( WIDGET (b), 100, 20);
@ -153,7 +154,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( "box", BOX_VERTICAL );
box *b = box_create ( "box", ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 100);
//box_set_padding ( b, 5 );
@ -187,35 +188,34 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
// TODO should this happen automagically?
widget_update ( WIDGET ( b ) ) ;
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 48);
TASSERTE ( wid1->h, 38);
TASSERTE ( wid2->w, 20);
TASSERTE ( wid2->h, 48);
TASSERTE ( wid2->h, 38);
TASSERTE ( wid3->w, 20);
TASSERTE ( wid3->h, 0);
TASSERTE ( wid3->h, 20);
widget_resize ( WIDGET (b ), 20, 200 );
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 98);
TASSERTE ( wid1->h, 88);
TASSERTE ( wid2->w, 20);
TASSERTE ( wid2->h, 98);
TASSERTE ( wid2->h, 88);
TASSERTE ( wid3->w, 20);
// has no height, gets no height.
TASSERTE ( wid3->h, 0);
TASSERTE ( wid3->h, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
widget *wid4 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
box_add ( b , WIDGET( wid4 ), FALSE, 5 );
TASSERTE ( wid4->y, 200);
TASSERTE ( wid4->y, 180);
widget *wid5 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE, 6 );
TASSERTE ( wid5->y, 136);
TASSERTE ( wid5->y, 149);
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( "box", BOX_VERTICAL );
box *b = box_create ( "box", ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 90);
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));

View file

@ -366,17 +366,17 @@ START_TEST ( test_properties_style)
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string ( "* { none: none; bold: bold; underline: underline; italic: italic; st: italic strikethrough;}");
ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "none", th);
ck_assert_int_eq ( th.style , HL_NONE );
ck_assert_int_eq ( th.style , ROFI_HL_NONE );
th = rofi_theme_get_highlight ( &wid, "underline", th);
ck_assert_int_eq ( th.style , HL_UNDERLINE);
ck_assert_int_eq ( th.style , ROFI_HL_UNDERLINE);
th = rofi_theme_get_highlight ( &wid, "italic", th);
ck_assert_int_eq ( th.style , HL_ITALIC);
ck_assert_int_eq ( th.style , ROFI_HL_ITALIC);
th = rofi_theme_get_highlight ( &wid, "bold", th);
ck_assert_int_eq ( th.style , HL_BOLD);
ck_assert_int_eq ( th.style , ROFI_HL_BOLD);
th = rofi_theme_get_highlight ( &wid, "st", th);
ck_assert_int_eq ( th.style , HL_ITALIC|HL_STRIKETHROUGH);
ck_assert_int_eq ( th.style , ROFI_HL_ITALIC|ROFI_HL_STRIKETHROUGH);
}
END_TEST
START_TEST ( test_properties_style2 )
@ -386,15 +386,15 @@ START_TEST ( test_properties_style2 )
wid.state = NULL;
rofi_theme_parse_string ( "* { boldu: bold underline ; boldi: bold italic; underlinei: underline italic; italicu: italic underline;}");
ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "boldu", th);
ck_assert_int_eq ( th.style , (HL_UNDERLINE|HL_BOLD));
ck_assert_int_eq ( th.style , (ROFI_HL_UNDERLINE|ROFI_HL_BOLD));
th = rofi_theme_get_highlight ( &wid, "boldi", th);
ck_assert_int_eq ( th.style , (HL_ITALIC|HL_BOLD));
ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_BOLD));
th = rofi_theme_get_highlight ( &wid, "underlinei", th);
ck_assert_int_eq ( th.style , (HL_ITALIC|HL_UNDERLINE));
ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_UNDERLINE));
th = rofi_theme_get_highlight ( &wid, "italicu", th);
ck_assert_int_eq ( th.style , (HL_ITALIC|HL_UNDERLINE));
ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_UNDERLINE));
}
END_TEST
START_TEST ( test_properties_style_color )
@ -403,9 +403,9 @@ START_TEST ( test_properties_style_color )
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string ( "* { comb: bold #123; }");
ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "comb", th);
ck_assert_int_eq ( th.style , (HL_BOLD|HL_COLOR));
ck_assert_int_eq ( th.style , (ROFI_HL_BOLD|ROFI_HL_COLOR));
ck_assert_double_eq ( th.color.red , (1/15.0));
ck_assert_double_eq ( th.color.green , (2/15.0));
ck_assert_double_eq ( th.color.blue , (3/15.0));