mirror of https://github.com/davatorium/rofi.git
Use true/false for hmode and fixed-num-lines
* Also update man page to reflect this.
This commit is contained in:
parent
f29751b573
commit
beced5d36e
|
@ -68,13 +68,13 @@ Settings config = {
|
||||||
// Location of the window. WL_CENTER, WL_NORTH_WEST, WL_NORTH,WL_NORTH_EAST, etc.
|
// Location of the window. WL_CENTER, WL_NORTH_WEST, WL_NORTH,WL_NORTH_EAST, etc.
|
||||||
.location = WL_CENTER,
|
.location = WL_CENTER,
|
||||||
// Mode of window, list (Vertical) or dmenu like (Horizontal)
|
// Mode of window, list (Vertical) or dmenu like (Horizontal)
|
||||||
.hmode = VERTICAL,
|
.hmode = FALSE,
|
||||||
// Padding of the window.
|
// Padding of the window.
|
||||||
.padding = 5,
|
.padding = 5,
|
||||||
.show_title = 1,
|
.show_title = 1,
|
||||||
.y_offset = 0,
|
.y_offset = 0,
|
||||||
.x_offset = 0,
|
.x_offset = 0,
|
||||||
.fixed_num_lines = 0
|
.fixed_num_lines = FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +106,7 @@ void config_sanity_check( void )
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !( config.hmode == VERTICAL || config.hmode == HORIZONTAL ) )
|
if ( !( config.hmode == TRUE || config.hmode == FALSE ) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "config.hmode is invalid.\n");
|
fprintf(stderr, "config.hmode is invalid.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -140,9 +140,8 @@ void config_print( void )
|
||||||
}
|
}
|
||||||
printf("# Lines: %3d\n", config.menu_lines);
|
printf("# Lines: %3d\n", config.menu_lines);
|
||||||
printf("# Columns: %3d\n", config.menu_columns);
|
printf("# Columns: %3d\n", config.menu_columns);
|
||||||
printf("Fixed number of lines: %5s\n", config.fixed_num_lines?"true":"false");
|
printf("Fixed number of lines: %5s\n", config.fixed_num_lines?"true":"false");
|
||||||
printf("Drawing mode: %10s\n",
|
printf("Horizontal model: %5s\n", config.hmode == TRUE?"true":"false");
|
||||||
config.hmode == VERTICAL?"Vertical":"Horizontal");
|
|
||||||
|
|
||||||
|
|
||||||
printf("Font: %35s\n", config.menu_font);
|
printf("Font: %35s\n", config.menu_font);
|
||||||
|
|
23
doc/rofi.1
23
doc/rofi.1
|
@ -7,6 +7,8 @@ rofi \- a simple EWMH window switcher
|
||||||
.IR pct_scr ]
|
.IR pct_scr ]
|
||||||
.RB [ \-lines
|
.RB [ \-lines
|
||||||
.IR lines ]
|
.IR lines ]
|
||||||
|
.RB [ \-columns
|
||||||
|
.IR columns ]
|
||||||
.RB [ \-font
|
.RB [ \-font
|
||||||
.IR xftfont ]
|
.IR xftfont ]
|
||||||
.RB [ \-fg
|
.RB [ \-fg
|
||||||
|
@ -31,6 +33,7 @@ rofi \- a simple EWMH window switcher
|
||||||
.RB [ \-loc
|
.RB [ \-loc
|
||||||
.IR position ]
|
.IR position ]
|
||||||
.RB [ \-hmode ]
|
.RB [ \-hmode ]
|
||||||
|
.RB [ \-fixed\-num\-lines ]
|
||||||
.RB [ \-padding
|
.RB [ \-padding
|
||||||
.IR padding ]
|
.IR padding ]
|
||||||
.RB [ \-version ]
|
.RB [ \-version ]
|
||||||
|
@ -160,12 +163,19 @@ rofi -o "75"
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B -lines
|
.B -lines
|
||||||
Maximum number of entries the menu may show before scrolling (default: 25).
|
Maximum number of lines the menu may show before scrolling (default: 25).
|
||||||
.P
|
.P
|
||||||
.RS
|
.RS
|
||||||
rofi -lines 25
|
rofi -lines 25
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
.B -columns
|
||||||
|
The number of columns the menu may show before scrolling (default: 25).
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
rofi -columns 2
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
.B -width
|
.B -width
|
||||||
Set the width of the menu as a percentage of the screen width (default: 60).
|
Set the width of the menu as a percentage of the screen width (default: 60).
|
||||||
.P
|
.P
|
||||||
|
@ -193,9 +203,16 @@ monitor:
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B -hmode
|
.B -hmode
|
||||||
Switch to horizontal mode (ala dmenu). You can specify the number of elements with the
|
Switch to horizontal mode (ala dmenu). The number of elements is the number of
|
||||||
|
.IR lines
|
||||||
|
times the number of
|
||||||
|
.IR columns
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
.B -fixed-num-lines
|
||||||
|
Keep a fixed number of visible lines (See the
|
||||||
.IR -lines
|
.IR -lines
|
||||||
option.
|
option.)
|
||||||
.TP
|
.TP
|
||||||
.B -padding
|
.B -padding
|
||||||
Define the inner margin of the window. Default is 5 pixels.
|
Define the inner margin of the window. Default is 5 pixels.
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
#define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 )
|
#define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 )
|
||||||
#define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
|
#define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const char *cache_dir;
|
extern const char *cache_dir;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -53,11 +61,6 @@ typedef enum _WindowLocation
|
||||||
WL_WEST = 8
|
WL_WEST = 8
|
||||||
} WindowLocation;
|
} WindowLocation;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
VERTICAL = 0,
|
|
||||||
HORIZONTAL = 1
|
|
||||||
} WindowMode;
|
|
||||||
/**
|
/**
|
||||||
* Settings
|
* Settings
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +89,7 @@ typedef struct _Settings
|
||||||
char * run_key;
|
char * run_key;
|
||||||
char * ssh_key;
|
char * ssh_key;
|
||||||
WindowLocation location;
|
WindowLocation location;
|
||||||
WindowMode hmode;
|
unsigned int hmode;
|
||||||
unsigned int padding;
|
unsigned int padding;
|
||||||
int y_offset;
|
int y_offset;
|
||||||
int x_offset;
|
int x_offset;
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
max_rows = config.menu_lines;
|
max_rows = config.menu_lines;
|
||||||
}
|
}
|
||||||
// More hacks.
|
// More hacks.
|
||||||
if ( config.hmode == HORIZONTAL )
|
if ( config.hmode == TRUE )
|
||||||
{
|
{
|
||||||
max_rows = 1;
|
max_rows = 1;
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
int element_width = w - ( 2 * ( config.padding ) );
|
int element_width = w - ( 2 * ( config.padding ) );
|
||||||
// Divide by the # columns
|
// Divide by the # columns
|
||||||
element_width /= config.menu_columns;
|
element_width /= config.menu_columns;
|
||||||
if ( config.hmode == HORIZONTAL )
|
if ( config.hmode == TRUE )
|
||||||
{
|
{
|
||||||
element_width = ( w - ( 2 * ( config.padding ) ) - max_elements * LINE_MARGIN ) / ( max_elements + 1 );
|
element_width = ( w - ( 2 * ( config.padding ) ) - max_elements * LINE_MARGIN ) / ( max_elements + 1 );
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1076,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
textbox *text = textbox_create ( box, TB_AUTOHEIGHT | TB_EDITABLE,
|
textbox *text = textbox_create ( box, TB_AUTOHEIGHT | TB_EDITABLE,
|
||||||
( config.padding )+prompt_tb->w,
|
( config.padding )+prompt_tb->w,
|
||||||
( config.padding ),
|
( config.padding ),
|
||||||
((config.hmode == HORIZONTAL)?
|
((config.hmode == TRUE)?
|
||||||
element_width:(w - (2 * ( config.padding ) ) ))-prompt_tb->w, 1,
|
element_width:(w - (2 * ( config.padding ) ) ))-prompt_tb->w, 1,
|
||||||
config.menu_font, config.menu_fg, config.menu_bg,
|
config.menu_font, config.menu_fg, config.menu_bg,
|
||||||
( input != NULL ) ? *input : "" );
|
( input != NULL ) ? *input : "" );
|
||||||
|
@ -1092,12 +1092,12 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
|
|
||||||
for ( i = 0; i < max_elements; i++ )
|
for ( i = 0; i < max_elements; i++ )
|
||||||
{
|
{
|
||||||
int line = ( i ) % max_rows + ( ( config.hmode == VERTICAL ) ? 1 : 0 );
|
int line = ( i ) % max_rows + ( ( config.hmode == FALSE ) ? 1 : 0 );
|
||||||
int col = ( i ) / max_rows + ( ( config.hmode == VERTICAL ) ? 0 : 1 );
|
int col = ( i ) / max_rows + ( ( config.hmode == FALSE ) ? 0 : 1 );
|
||||||
boxes[i] = textbox_create ( box,
|
boxes[i] = textbox_create ( box,
|
||||||
0,
|
0,
|
||||||
( config.padding ) + col * ( element_width + LINE_MARGIN ), // X
|
( config.padding ) + col * ( element_width + LINE_MARGIN ), // X
|
||||||
line * line_height + config.padding + ( ( config.hmode == HORIZONTAL ) ? 0 : LINE_MARGIN ), // y
|
line * line_height + config.padding + ( ( config.hmode == TRUE ) ? 0 : LINE_MARGIN ), // y
|
||||||
element_width, // w
|
element_width, // w
|
||||||
line_height, // h
|
line_height, // h
|
||||||
config.menu_font, config.menu_fg, config.menu_bg, "" );
|
config.menu_font, config.menu_fg, config.menu_bg, "" );
|
||||||
|
@ -1105,7 +1105,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
}
|
}
|
||||||
// Arrows
|
// Arrows
|
||||||
textbox *arrowbox_top = NULL, *arrowbox_bottom = NULL;
|
textbox *arrowbox_top = NULL, *arrowbox_bottom = NULL;
|
||||||
if ( config.hmode == VERTICAL )
|
if ( config.hmode == FALSE )
|
||||||
{
|
{
|
||||||
arrowbox_top = textbox_create ( box, TB_AUTOHEIGHT | TB_AUTOWIDTH,
|
arrowbox_top = textbox_create ( box, TB_AUTOHEIGHT | TB_AUTOWIDTH,
|
||||||
( config.padding ),
|
( config.padding ),
|
||||||
|
@ -1170,7 +1170,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
int h = line_height * ( max_rows + 1 ) + ( config.padding ) * 2 + LINE_MARGIN;
|
int h = line_height * ( max_rows + 1 ) + ( config.padding ) * 2 + LINE_MARGIN;
|
||||||
|
|
||||||
|
|
||||||
if ( config.hmode == HORIZONTAL )
|
if ( config.hmode == TRUE )
|
||||||
{
|
{
|
||||||
h = line_height + ( config.padding ) * 2;
|
h = line_height + ( config.padding ) * 2;
|
||||||
}
|
}
|
||||||
|
@ -1245,7 +1245,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
|
||||||
max_elements, arrowbox_top,
|
max_elements, arrowbox_top,
|
||||||
arrowbox_bottom );
|
arrowbox_bottom );
|
||||||
// Why do we need the specian -1?
|
// Why do we need the specian -1?
|
||||||
if ( config.hmode == VERTICAL && max_elements > 0 )
|
if ( config.hmode == FALSE && max_elements > 0 )
|
||||||
{
|
{
|
||||||
XDrawLine ( display, main_window, gc, ( config.padding ),
|
XDrawLine ( display, main_window, gc, ( config.padding ),
|
||||||
line_height + ( config.padding ) + ( LINE_MARGIN - 2 ) / 2,
|
line_height + ( config.padding ) + ( LINE_MARGIN - 2 ) / 2,
|
||||||
|
@ -1932,7 +1932,7 @@ static void parse_cmd_options ( int argc, char ** argv )
|
||||||
|
|
||||||
if ( find_arg ( argc, argv, "-hmode" ) >= 0 )
|
if ( find_arg ( argc, argv, "-hmode" ) >= 0 )
|
||||||
{
|
{
|
||||||
config.hmode = HORIZONTAL;
|
config.hmode = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keybindings
|
// Keybindings
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
xrm_String = 0,
|
xrm_String = 0,
|
||||||
xrm_Number = 1
|
xrm_Number = 1,
|
||||||
|
xrm_Boolean= 2
|
||||||
} XrmOptionType;
|
} XrmOptionType;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -72,9 +73,9 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_Number, "location", { .num = &config.location }, NULL },
|
{ xrm_Number, "location", { .num = &config.location }, NULL },
|
||||||
{ xrm_Number, "yoffset", { .num = &config.y_offset }, NULL },
|
{ xrm_Number, "yoffset", { .num = &config.y_offset }, NULL },
|
||||||
{ xrm_Number, "xoffset", { .num = &config.x_offset }, NULL },
|
{ xrm_Number, "xoffset", { .num = &config.x_offset }, NULL },
|
||||||
{ xrm_Number, "fixed_num_lines", { .num = &config.fixed_num_lines }, NULL },
|
{ xrm_Boolean,"fixed-num-lines", { .num = &config.fixed_num_lines }, NULL },
|
||||||
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL },
|
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL },
|
||||||
{ xrm_Number, "hmode", { .num = &config.hmode }, NULL },
|
{ xrm_Boolean,"hmode", { .num = &config.hmode }, NULL },
|
||||||
/* Key bindings */
|
/* Key bindings */
|
||||||
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
||||||
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
||||||
|
@ -129,6 +130,14 @@ void parse_xresource_options ( Display *display )
|
||||||
{
|
{
|
||||||
*xrmOptions[i].num = strtol ( xrmValue.addr, NULL, 10 );
|
*xrmOptions[i].num = strtol ( xrmValue.addr, NULL, 10 );
|
||||||
}
|
}
|
||||||
|
else if ( xrmOptions[i].type == xrm_Boolean )
|
||||||
|
{
|
||||||
|
if(xrmValue.size > 0 && strncasecmp(xrmValue.addr, "true", xrmValue.size) == 0) {
|
||||||
|
*xrmOptions[i].num = TRUE;
|
||||||
|
} else {
|
||||||
|
*xrmOptions[i].num = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free ( class );
|
free ( class );
|
||||||
|
|
Loading…
Reference in New Issue