1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-07-31 21:59:25 -04:00

Make dmenu mode behave more like dmenu

This commit is contained in:
Qball Cow 2014-01-30 18:23:52 +01:00
parent 39b25093bd
commit c32e18b600
7 changed files with 12 additions and 11 deletions

View file

@ -118,8 +118,9 @@ SwitcherMode dmenu_switcher_dialog ( char **input )
retv = DMENU_DIALOG; retv = DMENU_DIALOG;
} else if ( n >=0 && list[n] != NULL ) { } else if ( n >=0 && list[n] != NULL ) {
fputs( list[n],stdout ); fputs( list[n],stdout );
} else if ( n == -3 && *input != NULL && *input[0] != '\0' ) {
fputs( *input, stdout );
} }
for ( unsigned int i=0; list[i] != NULL; i++ ) { for ( unsigned int i=0; list[i] != NULL; i++ ) {
free( list[i] ); free( list[i] );
} }

View file

@ -271,7 +271,7 @@ SwitcherMode mark_switcher_dialog ( char **input )
} }
int shift=0; int shift=0;
int n = menu( cmd_list, input, "mark ", NULL, &shift,token_match, NULL ); int n = menu( cmd_list, input, "mark:", NULL, &shift,token_match, NULL );
if ( n == -2 ) { if ( n == -2 ) {
retv = NEXT_DIALOG; retv = NEXT_DIALOG;

View file

@ -178,7 +178,7 @@ SwitcherMode profile_switcher_dialog ( char **input )
} }
int shift=0; int shift=0;
int n = menu( cmd_list, input, "profile ", NULL, &shift,token_match, NULL ); int n = menu( cmd_list, input, "profile:", NULL, &shift,token_match, NULL );
if ( n == -2 ) { if ( n == -2 ) {
retv = NEXT_DIALOG; retv = NEXT_DIALOG;

View file

@ -247,7 +247,7 @@ SwitcherMode run_switcher_dialog ( char **input )
} }
int shift=0; int shift=0;
int n = menu( cmd_list, input, "$ ", NULL, &shift,token_match, NULL ); int n = menu( cmd_list, input, "$", NULL, &shift,token_match, NULL );
if ( n == -2 ) { if ( n == -2 ) {
retv = NEXT_DIALOG; retv = NEXT_DIALOG;

View file

@ -1130,7 +1130,7 @@ SwitcherMode run_switcher_window ( char **input )
} }
} }
Time time; Time time;
int n = menu( list, input, "> ", &time, NULL,window_match, ids ); int n = menu( list, input, ">", &time, NULL,window_match, ids );
if ( n == -2 ) { if ( n == -2 ) {
retv = NEXT_DIALOG; retv = NEXT_DIALOG;

View file

@ -245,7 +245,7 @@ SwitcherMode ssh_switcher_dialog ( char **input )
} }
int shift=0; int shift=0;
int n = menu( cmd_list, input, "ssh ", NULL, &shift,token_match, NULL ); int n = menu( cmd_list, input, "ssh", NULL, &shift,token_match, NULL );
if ( n == -2 ) { if ( n == -2 ) {
retv = NEXT_DIALOG; retv = NEXT_DIALOG;

View file

@ -112,9 +112,9 @@ void textbox_font( textbox *tb, char *font, char *fg, char *bg )
// outer code may need line height, width, etc // outer code may need line height, width, etc
void textbox_extents( textbox *tb ) void textbox_extents( textbox *tb )
{ {
int length = strlen( tb->text ) + strlen( tb->prompt ); int length = strlen( tb->text ) + strlen( tb->prompt) +1;
char *line = alloca( length + 1 ); char *line = alloca( length + 1 );
sprintf( line, "%s%s", tb->prompt, tb->text ); sprintf( line, "%s %s", tb->prompt, tb->text );
XftTextExtents8( display, tb->font, ( unsigned char* )line, length, &tb->extents ); XftTextExtents8( display, tb->font, ( unsigned char* )line, length, &tb->extents );
} }
@ -220,12 +220,12 @@ void textbox_draw( textbox *tb )
int cursor_width = MAX( 2, line_height/10 ); int cursor_width = MAX( 2, line_height/10 );
if ( tb->flags & TB_EDITABLE ) { if ( tb->flags & TB_EDITABLE ) {
int prompt_len = strlen( prompt ); int prompt_len = strlen( prompt ) +1;
length = text_len + prompt_len; length = text_len + prompt_len;
cursor_offset = MIN( tb->cursor + prompt_len, length ); cursor_offset = MIN( tb->cursor + prompt_len, length );
line = alloca( length + 10 ); line = alloca( length + 10 );
sprintf( line, "%s%s", prompt, text ); sprintf( line, "%s %s", prompt, text );
// replace spaces so XftTextExtents8 includes their width // replace spaces so XftTextExtents8 includes their width
for ( i = 0; i < length; i++ ) if ( isspace( line[i] ) ) line[i] = '_'; for ( i = 0; i < length; i++ ) if ( isspace( line[i] ) ) line[i] = '_';
@ -235,7 +235,7 @@ void textbox_draw( textbox *tb )
cursor_x = extents.width; cursor_x = extents.width;
// restore correct text string with spaces // restore correct text string with spaces
sprintf( line, "%s%s", prompt, text ); sprintf( line, "%s %s", prompt, text );
} }
// calc full input text width // calc full input text width