1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

[#158] Patch implementing -only-match mode.

This commit is contained in:
Dave Davenport 2015-05-07 21:07:15 +02:00
parent 94c9303d89
commit 89d2190f8e
2 changed files with 34 additions and 0 deletions

View file

@ -507,6 +507,11 @@ The following options are further explained in the theming section:
or a set of rows: -u 0,2
Or any combination: -u 0,2-3,9
`-only-match`
Only return a selected item, do not allow custom entry.
This mode always returns an entry, or returns directly when no entries given.
### Message dialog
`-e` *message*

View file

@ -157,10 +157,39 @@ int dmenu_switcher_dialog ( char **input )
parse_ranges ( str, &active_list, &num_active_list );
}
int only_selected = FALSE;
if ( find_arg ( "-only-match" ) >= 0 ) {
only_selected = TRUE;
if ( length == 0 ) {
return TRUE;
}
}
do {
int next_pos = selected_line;
int mretv = menu ( list, length, input, dmenu_prompt,
token_match, NULL, &selected_line, config.levenshtein_sort, get_display_data, list, &next_pos );
// Special behavior.
if ( only_selected ) {
restart = TRUE;
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && list[selected_line] != NULL ) {
if ( number_mode ) {
fprintf ( stdout, "%d", selected_line );
}
else {
fputs ( list[selected_line], stdout );
}
retv = TRUE;
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
retv = 10 + ( mretv & MENU_LOWER_MASK );
}
fputc ( '\n', stdout );
fflush ( stdout );
return retv;
}
selected_line = next_pos - 1;
continue;
}
// We normally do not want to restart the loop.
restart = FALSE;
if ( ( mretv & MENU_OK ) && list[selected_line] != NULL ) {