summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/rofi-types.h2
-rw-r--r--include/widgets/textbox.h6
-rw-r--r--lexer/theme-lexer.l2
-rw-r--r--lexer/theme-parser.y2
-rw-r--r--source/rofi.c2
-rw-r--r--source/theme.c3
-rw-r--r--source/widgets/textbox.c12
-rw-r--r--source/xrmoptions.c4
-rw-r--r--test/box-test.c5
-rw-r--r--test/scrollbar-test.c4
-rw-r--r--test/theme-parser-test.c5
11 files changed, 44 insertions, 3 deletions
diff --git a/include/rofi-types.h b/include/rofi-types.h
index 80998463..4e2d1882 100644
--- a/include/rofi-types.h
+++ b/include/rofi-types.h
@@ -80,6 +80,8 @@ typedef enum
ROFI_PU_EM,
/** PixelWidget in percentage */
ROFI_PU_PERCENT,
+ /** PixelWidth in CH. */
+ ROFI_PU_CH,
} RofiPixelUnit;
/**
diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h
index b330045b..3ea8074b 100644
--- a/include/widgets/textbox.h
+++ b/include/widgets/textbox.h
@@ -237,6 +237,12 @@ int textbox_get_font_width ( const textbox *tb );
double textbox_get_estimated_char_width ( void );
/**
+ * Estimate the width of a 0.
+ *
+ * @returns the width of a 0 in pixels.
+ */
+double textbox_get_estimated_ch ( void );
+/**
* Estimate the height of a character.
*
* @returns the height of a character in pixels.
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index bf53b0f4..57ca2064 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -170,6 +170,7 @@ PNNUMBER [-+]?[[:digit:]]+
REAL [-+]?[[:digit:]]+(\.[[:digit:]]+)?
PX (px)
EM (em)
+CH (ch)
PERCENT (\%)
ASTERIX \*
@@ -411,6 +412,7 @@ if ( queue == NULL ){
}
<PROPERTIES>{EM} { return T_UNIT_EM; }
+<PROPERTIES>{CH} { return T_UNIT_CH; }
<PROPERTIES>{PX} { return T_UNIT_PX; }
<PROPERTIES>{PERCENT} { return T_PERCENT; }
<PROPERTIES>{LS_SOLID} { return T_SOLID; }
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 2b242260..3ad65543 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -182,6 +182,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_UNIT_PX "pixels"
%token T_UNIT_EM "em"
+%token T_UNIT_CH "ch"
%token T_UNIT_PERCENT "%"
%token T_ANGLE_DEG "Degrees"
@@ -470,6 +471,7 @@ t_property_distance
t_property_unit
: T_UNIT_PX { $$ = ROFI_PU_PX; }
| T_UNIT_EM { $$ = ROFI_PU_EM; }
+| T_UNIT_CH { $$ = ROFI_PU_CH; }
| T_PERCENT { $$ = ROFI_PU_PERCENT; }
;
/******
diff --git a/source/rofi.c b/source/rofi.c
index 6ce618fa..f1a6c600 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -909,7 +909,7 @@ int main ( int argc, char *argv[] )
return EXIT_SUCCESS;
}
if ( find_arg ( "-dump-config" ) >= 0 ) {
- config_parse_dump_config_rasi_format ( TRUE );
+ config_parse_dump_config_rasi_format ( FALSE );
cleanup ();
return EXIT_SUCCESS;
}
diff --git a/source/theme.c b/source/theme.c
index 92cf416a..9691b77c 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -635,6 +635,9 @@ int distance_get_pixel ( RofiDistance d, RofiOrientation ori )
if ( d.type == ROFI_PU_EM ) {
return d.distance * textbox_get_estimated_char_height ();
}
+ else if ( d.type == ROFI_PU_CH ) {
+ return d.distance * textbox_get_estimated_ch ();
+ }
else if ( d.type == ROFI_PU_PERCENT ) {
if ( ori == ROFI_ORIENTATION_VERTICAL ) {
int height = 0;
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index a2854ff3..c60a1acb 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -897,6 +897,18 @@ double textbox_get_estimated_char_width ( void )
return char_width;
}
+static double ch_width = -1;
+double textbox_get_estimated_ch ( void )
+{
+
+ if ( ch_width < 0 ) {
+ int width = pango_font_metrics_get_approximate_digit_width ( p_metrics );
+ ch_width = ( width ) / (double) PANGO_SCALE;
+ }
+ return ch_width;
+
+}
+
int textbox_get_estimated_height ( const textbox *tb, int eh )
{
int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics );
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 8434bc4e..d00e617b 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -550,7 +550,7 @@ void config_parse_xresource_dump ( void )
static void config_parse_dump_config_option ( XrmOption *option )
{
- if ( option->type == xrm_Char ) {
+ if ( option->type == xrm_Char || option->source == CONFIG_DEFAULT ) {
printf ( "/*" );
}
printf ( "\t%s: ", option->name );
@@ -586,7 +586,7 @@ static void config_parse_dump_config_option ( XrmOption *option )
}
printf ( ";" );
- if ( option->type == xrm_Char ) {
+ if ( option->type == xrm_Char || option->source == CONFIG_DEFAULT ) {
printf ( "*/" );
}
printf ( "\n" );
diff --git a/test/box-test.c b/test/box-test.c
index 7cc437d3..0d276d63 100644
--- a/test/box-test.c
+++ b/test/box-test.c
@@ -84,6 +84,11 @@ int textbox_get_estimated_char_height ( void )
{
return 16;
}
+double textbox_get_estimated_ch ( void );
+double textbox_get_estimated_ch ( void )
+{
+ return 8;
+}
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
{
diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c
index f69b3eb7..0fb98019 100644
--- a/test/scrollbar-test.c
+++ b/test/scrollbar-test.c
@@ -74,6 +74,10 @@ double textbox_get_estimated_char_height ( void )
{
return 16;
}
+double textbox_get_estimated_ch ( void )
+{
+ return 8.0;
+}
void listview_set_selected ( G_GNUC_UNUSED listview *lv, G_GNUC_UNUSED unsigned int selected )
{
diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c
index cd9e6ca6..53b15b9c 100644
--- a/test/theme-parser-test.c
+++ b/test/theme-parser-test.c
@@ -66,6 +66,11 @@ double textbox_get_estimated_char_height ( void )
return 16.0;
}
+double textbox_get_estimated_ch ( void )
+{
+ return 8.0;
+}
+
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;