Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improve require-input user experience #1765

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Deiwin Sarjas
Dimitar Yordanov
Edwin Pujols
eigengrau
Enrico Lamperti
Eric Engeström
Fangrui Song
fice-t
Expand Down
3 changes: 1 addition & 2 deletions doc/rofi-theme.5
Original file line number Diff line number Diff line change
Expand Up @@ -1579,8 +1579,7 @@ The order the elements are layed out. Vertical is the original 'column' view.
Do not reduce the number of columns shown when number of visible elements is not enough to fill them all.
.IP \(bu 2
\fBrequire-input\fP: boolean
Listview requires user input to be unhidden. The list will still respond to normal interaction.
Hitting accept will still activate the selected entry.
Listview requires user input to be unhidden. Hitting accept with no input won't activate any entry.

.RE

Expand Down
3 changes: 1 addition & 2 deletions doc/rofi-theme.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,7 @@ The following properties are currently supported:
* **fixed-columns**: boolean
Do not reduce the number of columns shown when number of visible elements is not enough to fill them all.
* **require-input**: boolean
Listview requires user input to be unhidden. The list will still respond to normal interaction.
Hitting accept will still activate the selected entry.
Listview requires user input to be unhidden. Hitting accept with no input won't activate any entry.

Each element is a `box` called `element`. Each `element` can contain an `element-icon` and `element-text`.

Expand Down
6 changes: 4 additions & 2 deletions source/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
}
case ACCEPT_ENTRY: {
rofi_view_refilter_force(state);
// If a valid item is selected, return that..
// If a valid item is selected, return that.
unsigned int selected = listview_get_selected(state->list_view);
state->selected_line = UINT32_MAX;
if (selected < state->filtered_lines) {
Expand All @@ -1728,7 +1728,9 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
state->retv = MENU_CUSTOM_INPUT;
}

state->quit = TRUE;
if (selected != UINT32_MAX) {
state->quit = TRUE;
}
Comment on lines +1731 to +1733
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And checking the selected value here, before defining it's time to quit, would keep rofi open when require_input is enabled and there's no input. The user can still quit rofi normally by using the expected method, kb-cancel.

break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions source/widgets/listview.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ void listview_set_num_elements(listview *lv, unsigned int rows) {
}

unsigned int listview_get_selected(listview *lv) {
if (lv->require_input && !lv->filtered) {
return UINT32_MAX;
}
Comment on lines +580 to +582
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enough to avoid auto-selecting the first item when require_input is enabled and there's no input:

if (lv != NULL) {
return lv->selected;
}
Expand Down