Add a go-to-playing action and binding

This commit is contained in:
Přemysl Eric Janouch 2023-05-30 14:41:44 +02:00
parent dcb2829e9b
commit 14dba91dd1
Signed by: p
GPG Key ID: A0420B94F92B9493
3 changed files with 12 additions and 0 deletions

2
NEWS
View File

@ -11,6 +11,8 @@ Unreleased
* X11: fixed rendering of overflowing, partially visible list items
* Added a "o" binding to select the currently playing song
* Added Readline-like M-u, M-l, M-c editor bindings

View File

@ -46,6 +46,8 @@ CENTER_CURSOR, Center the cursor
MOVE_UP, Move selection up
MOVE_DOWN, Move selection down
GOTO_PLAYING, Go to playing song
GOTO_TOP, Go to top
GOTO_BOTTOM, Go to bottom
GOTO_ITEM_PREVIOUS, Go to previous item

View File

@ -3021,6 +3021,7 @@ g_normal_defaults[] =
{ "C-PageUp", ACTION_TAB_PREVIOUS },
{ "C-PageDown", ACTION_TAB_NEXT },
{ "o", ACTION_GOTO_PLAYING },
{ "Home", ACTION_GOTO_TOP },
{ "End", ACTION_GOTO_BOTTOM },
{ "M-<", ACTION_GOTO_TOP },
@ -3343,6 +3344,13 @@ current_tab_on_action (enum action action)
switch (action)
{
const char *id;
case ACTION_GOTO_PLAYING:
if (g.song < 0 || (size_t) g.song >= tab->item_count)
return false;
tab->item_selected = g.song;
app_ensure_selection_visible ();
return true;
case ACTION_MOVE_UP:
return current_tab_move_selection (-1);
case ACTION_MOVE_DOWN: