mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[#158] Patch implementing -only-match mode.
This commit is contained in:
parent
94c9303d89
commit
89d2190f8e
2 changed files with 34 additions and 0 deletions
|
@ -507,6 +507,11 @@ The following options are further explained in the theming section:
|
||||||
or a set of rows: -u 0,2
|
or a set of rows: -u 0,2
|
||||||
Or any combination: -u 0,2-3,9
|
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
|
### Message dialog
|
||||||
|
|
||||||
`-e` *message*
|
`-e` *message*
|
||||||
|
|
|
@ -157,10 +157,39 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
parse_ranges ( str, &active_list, &num_active_list );
|
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 {
|
do {
|
||||||
int next_pos = selected_line;
|
int next_pos = selected_line;
|
||||||
int mretv = menu ( list, length, input, dmenu_prompt,
|
int mretv = menu ( list, length, input, dmenu_prompt,
|
||||||
token_match, NULL, &selected_line, config.levenshtein_sort, get_display_data, list, &next_pos );
|
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.
|
// We normally do not want to restart the loop.
|
||||||
restart = FALSE;
|
restart = FALSE;
|
||||||
if ( ( mretv & MENU_OK ) && list[selected_line] != NULL ) {
|
if ( ( mretv & MENU_OK ) && list[selected_line] != NULL ) {
|
||||||
|
|
Loading…
Reference in a new issue