Remove hmode. (Rather no implementation then a bad one.)

This commit is contained in:
Dave Davenport 2015-02-10 07:42:40 +01:00
parent e76db3fce3
commit a50219e903
7 changed files with 23 additions and 87 deletions

View file

@ -87,8 +87,6 @@ Settings config = {
*
*/
.location = WL_CENTER,
/** Mode of window, list (Vertical) or dmenu like (Horizontal) */
.hmode = FALSE,
/** Padding between elements */
.padding = 5,
/** Y offset */

View file

@ -21,7 +21,6 @@ rofi - A window switcher, run dialog and dmenu replacement
[ -rkey *comdo* ]
[ -terminal *terminal* ]
[ -location *position* ]
[ -hmode ]
[ -fixed-num-lines ]
[ -padding *padding* ]
[ -opacity *opacity%* ]
@ -295,11 +294,6 @@ The default key combinations are:
Default: *0*
`-hmode`
Switch to horizontal mode (ala dmenu). The number of elements is the number of `lines` times the
number of `columns`.
`-fixed-num-lines`
Keep a fixed number of visible lines (See the `-lines` option.)
@ -308,10 +302,6 @@ The default key combinations are:
Define the inner margin of the window.
To make rofi look like dmenu:
rofi -hmode -padding 0
Default: *5*
`-sidebar-mode`

View file

@ -19,7 +19,6 @@ rofi \- A window switcher, run dialog and dmenu replacement
[ \-rkey \fIcomdo\fP ]
[ \-terminal \fIterminal\fP ]
[ \-location \fIposition\fP ]
[ \-hmode ]
[ \-fixed\-num\-lines ]
[ \-padding \fIpadding\fP ]
[ \-opacity \fIopacity%\fP ]
@ -377,11 +376,6 @@ monitor:
.IP
Default: \fI0\fP
.PP
\fB\fC\-hmode\fR
.IP
Switch to horizontal mode (ala dmenu). The number of elements is the number of \fB\fClines\fR times the
number of \fB\fCcolumns\fR\&.
.PP
\fB\fC\-fixed\-num\-lines\fR
.IP
Keep a fixed number of visible lines (See the \fB\fC\-lines\fR option.)
@ -390,14 +384,6 @@ Keep a fixed number of visible lines (See the \fB\fC\-lines\fR option.)
.IP
Define the inner margin of the window.
.IP
To make rofi look like dmenu:
.PP
.RS
.nf
rofi \-hmode \-padding 0
.fi
.RE
.IP
Default: \fI5\fP
.PP
\fB\fC\-sidebar\-mode\fR

View file

@ -182,8 +182,6 @@ typedef struct _Settings
char * ssh_key;
/** Windows location/gravity */
WindowLocation location;
/** Horizontal mode. */
unsigned int hmode;
/** Padding between elements */
unsigned int padding;
/** Y offset */

View file

@ -419,10 +419,6 @@ void config_parse_cmd_options ( int argc, char ** argv )
// Parse commandline arguments about behavior
find_arg_str ( argc, argv, "-terminal", &( config.terminal_emulator ) );
if ( find_arg ( argc, argv, "-hmode" ) >= 0 ) {
config.hmode = TRUE;
}
find_arg_str ( argc, argv, "-ssh-client", &( config.ssh_client ) );
find_arg_str ( argc, argv, "-ssh-command", &( config.ssh_command ) );
find_arg_str ( argc, argv, "-run-command", &( config.run_command ) );
@ -473,10 +469,6 @@ void config_sanity_check ( void )
WL_WEST, config.location, WL_CENTER );
exit ( 1 );
}
if ( !( config.hmode == TRUE || config.hmode == FALSE ) ) {
fprintf ( stderr, "config.hmode is invalid.\n" );
exit ( 1 );
}
// If alternative row is not set, copy the normal background color.
if ( config.menu_bg_alt == NULL ) {
config.menu_bg_alt = config.menu_bg;

View file

@ -529,10 +529,6 @@ static void menu_calculate_rows_columns ( MenuState *state )
state->columns = 1;
}
}
// More hacks.
if ( config.hmode == TRUE ) {
state->max_rows = 1;
}
}
/**
@ -561,10 +557,6 @@ static void menu_calculate_window_and_element_width ( MenuState *state, workarea
state->element_width = state->w - ( 2 * ( config.padding ) );
// Divide by the # columns
state->element_width = ( state->element_width - ( state->columns - 1 ) * LINE_MARGIN ) / state->columns;
if ( config.hmode == TRUE ) {
state->element_width = ( state->w - ( 2 * ( config.padding ) ) - state->max_elements * LINE_MARGIN ) / (
state->max_elements + 1 );
}
}
}
@ -916,13 +908,11 @@ static void menu_update ( MenuState *state )
state->max_elements, state->arrowbox_top,
state->arrowbox_bottom );
// Why do we need the specian -1?
if ( config.hmode == FALSE ) {
int line_height = textbox_get_height ( state->text );
XDrawLine ( display, main_window, gc, ( config.padding ),
line_height + ( config.padding ) + ( LINE_MARGIN ) / 2,
state->w - ( ( config.padding ) ) - 1,
line_height + ( config.padding ) + ( LINE_MARGIN ) / 2 );
}
int line_height = textbox_get_height ( state->text );
XDrawLine ( display, main_window, gc, ( config.padding ),
line_height + ( config.padding ) + ( LINE_MARGIN ) / 2,
state->w - ( ( config.padding ) ) - 1,
line_height + ( config.padding ) + ( LINE_MARGIN ) / 2 );
if ( config.sidebar_mode == TRUE ) {
int line_height = textbox_get_height ( state->text );
@ -1028,8 +1018,8 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
( config.padding ),
0, 0, NORMAL, prompt );
// Entry box
int entrybox_width = (
( config.hmode == TRUE ) ? state.element_width : ( state.w - ( 2 * ( config.padding ) ) ) )
int entrybox_width = state.w
- ( 2 * ( config.padding ) )
- textbox_get_width ( state.prompt_tb )
- textbox_get_width ( state.case_indicator );
@ -1058,15 +1048,15 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
// filtered list display
state.boxes = g_malloc0_n ( state.max_elements, sizeof ( textbox* ) );
int y_offset = config.padding + ( ( config.hmode == FALSE ) ? line_height : 0 );
int x_offset = config.padding + ( ( config.hmode == FALSE ) ? 0 : ( state.element_width + LINE_MARGIN ) );
int y_offset = config.padding + line_height;
int x_offset = config.padding;
for ( i = 0; i < state.max_elements; i++ ) {
int line = ( i ) % state.max_rows;
int col = ( i ) / state.max_rows;
int ex = col * ( state.element_width + LINE_MARGIN );
int ey = line * element_height + ( ( config.hmode == TRUE ) ? 0 : LINE_MARGIN );
int ey = line * element_height + LINE_MARGIN;
state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0,
ex + x_offset,
@ -1076,34 +1066,20 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
}
// Arrows
state.arrowbox_top = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_AUTOWIDTH,
( config.padding ),
( config.padding ),
0, 0,
NORMAL,
( config.hmode == FALSE ) ? "" : "" );
( config.padding ), ( config.padding ),
0, 0, NORMAL,
"" );
state.arrowbox_bottom = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_AUTOWIDTH,
( config.padding ),
( config.padding ),
0, 0,
NORMAL,
( config.hmode == FALSE ) ? "" : "" );
( config.padding ), ( config.padding ),
0, 0, NORMAL,
"" );
if ( config.hmode == FALSE ) {
textbox_move ( state.arrowbox_top,
state.w - config.padding - state.arrowbox_top->w,
config.padding + line_height + LINE_MARGIN );
textbox_move ( state.arrowbox_bottom,
state.w - config.padding - state.arrowbox_bottom->w,
config.padding + state.max_rows * element_height + LINE_MARGIN );
}
else {
textbox_move ( state.arrowbox_bottom,
state.w - config.padding - state.arrowbox_top->w,
config.padding );
textbox_move ( state.arrowbox_top,
state.w - config.padding - state.arrowbox_bottom->w - state.arrowbox_top->w,
config.padding );
}
textbox_move ( state.arrowbox_top,
state.w - config.padding - state.arrowbox_top->w,
config.padding + line_height + LINE_MARGIN );
textbox_move ( state.arrowbox_bottom,
state.w - config.padding - state.arrowbox_bottom->w,
config.padding + state.max_rows * element_height + LINE_MARGIN );
// filtered list
state.filtered = (char * *) g_malloc0_n ( state.num_lines, sizeof ( char* ) );
@ -1115,9 +1091,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
// resize window vertically to suit
// Subtract the margin of the last row.
state.h = line_height + element_height * state.max_rows + ( config.padding ) * 2 + LINE_MARGIN;
if ( config.hmode == TRUE ) {
state.h = line_height + ( config.padding ) * 2;
}
// Add entry
if ( config.sidebar_mode == TRUE ) {
state.h += line_height + LINE_MARGIN;

View file

@ -96,8 +96,6 @@ static XrmOption xrmOptions[] = {
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL },
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL },
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL },
{ xrm_Boolean, "hmode", { .num = &config.hmode }, NULL },
{ xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL },
{ xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL },