mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add ch
as size unit.
This commit is contained in:
parent
6dae152e31
commit
ba296f9210
11 changed files with 44 additions and 3 deletions
|
@ -80,6 +80,8 @@ typedef enum
|
|||
ROFI_PU_EM,
|
||||
/** PixelWidget in percentage */
|
||||
ROFI_PU_PERCENT,
|
||||
/** PixelWidth in CH. */
|
||||
ROFI_PU_CH,
|
||||
} RofiPixelUnit;
|
||||
|
||||
/**
|
||||
|
|
|
@ -236,6 +236,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.
|
||||
*
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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; }
|
||||
;
|
||||
/******
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue