rofi-blocks
rofi-blocks copied to clipboard
Setting the selected line?
Hi,
Since rofi-blocks allows you to update list content on the fly, it could be great for making nested menus. One "issue" I have ran into is not being able to control what line is selected/active after selecting an entry.
Say you have a Main Menu with 5 items, each containing at least 1 submenu.
- Queue -> submenu
- Artists -> submenu
- Albums -> submenu
- Genres -> submenu
- Recent -> submenu
Menu option 5, Recent
, contains 10 lines. When opening Recent
line 5/10 is automatically the selected-row, where line 1 would be the expected behavior in this case.
In many uses cases rofi-blocks current behavior is an asset, this is just an example where its not.
You can currently mark a line as active
or urgent
, being able to do the same for -selected-row
would be very nice to have.
{"text":"with object, you can use flags", "urgent":true},
{"text":"such as urgent and highlight", "highlight": true},
{"text":"The selected row", "selected": true}
I have looked through rofi-blocks source to try and get an idea on whether or not it could be implemented, but I soon realized my c
skills are just not up to the task :/
Hi,
Thanks for trying at least :+1:
I think, and will assume, you mean highlight
instead of active
, but is a good name, if not better, that selected
, since you have not selected the entry yet.
To be honest, I had this problem too, with the top_advanced.sh example. I am wondering what should happen when 2 or more lines are defined as active
. As only one line should be active, I will have to choose the first or last., to simplify, I will choose the first one, and ignore the rest.
Edit: I do not see what should happen when I put active: false
on an active line, should I set the first entry as active?
I think, and will assume, you mean highlight instead of active, but is a good name, if not better, that selected, since you have not selected the entry yet.
Yup, typo on my part :/ I do agree that active
is probably a more accurate description than selected
in this regard, for reasons you described.
I am wondering what should happen when 2 or more lines are defined as active. As only one line should be active, I will have to choose the first or last., to simplify, I will choose the first one, and ignore the rest.
That sounds like correct behavior imo.
Edit: I do not see what should happen when I put active: false on an active line, should I set the first entry as active?
Hmmm, good question. Perhaps @fogine could offer some better input than me on this issue?
I would design it in a similar manner to rofi
s selected-row
option.. Only a single entry can be the active (selected) one at a time so it doesnt make sense to make the active
option be nested as part of lines[].active
. Instead it could be defined as top level option and take a number (index of a line) instead of boolean
and if invalid index is defined, the first row/entry should be the active one
I did play around with it, and decided to implement with @fogine input, it had less edge cases to worry than the active
on the line. About the invalid index case, I let rofi handle it with rofi_view_set_selected_line
, and it works as @fogine described.
The new property is active entry
. Non-numeric values, negative and floating numbers are ignored
I also added a new example demonstrating it: focus_entry
This works great :)
About the invalid index case, I let rofi handle it with rofi_view_set_selected_line
Nice.
After playing with it a bit and thinking about it more, having active entry
set as a top-level entry does make more sense. Thanks for the input @fogine.
And much appreciate the quick implementation @OmarCastro!
Hi, believe I ran into a bug.
Initial rofi view is a Main Menu with 5 items each contains at least 1 submenu.
- Queue -> submenu
- Artists -> submenu
- Albums -> submenu
- Genres -> submenu
- Recent -> submenu
User selects row 0
, Queue. Queue contains 6
lines and user set {active entry: 5}
(starting at 0), but on render of view line 0
displays as active entry
.
Although line 0
displays as the active entry
, using rofi's debugger output looks correct.
(process:8765): BlocksMode-DEBUG: 21:35:03.087: handling received line
(process:8765): BlocksMode-DEBUG: 21:35:03.087: entry_to_focus 5
(process:8765): BlocksMode-DEBUG: 21:35:03.087: reloading rofi view
(process:8765): BlocksMode-DEBUG: 21:35:03.099: calling on_render
(process:8765): BlocksMode-DEBUG: 21:35:03.099: on_render.selected line 5
(process:8765): BlocksMode-DEBUG: 21:35:03.099: on_render.next pos 1
(process:8765): BlocksMode-DEBUG: 21:35:03.099: on_render.active line 0
(process:8765): BlocksMode-DEBUG: 21:35:03.188: blocks_mode_get_num_entries
(process:8765): BlocksMode-DEBUG: 21:35:03.188: blocks_mode_get_message
(process:8765): BlocksMode-DEBUG: 21:35:03.203: calling on_render
it appears active line
≯ num lines in initial view
, in this case 5... hmmm.
Thanks for your time.