aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-05-30 14:41:44 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-05-30 14:41:44 +0200
commit14dba91dd1b13f1839687c3cd37c245768d36b95 (patch)
treec3036e288e45f8c45dd4691f95c8de584d4d3239
parentdcb2829e9b9792065918ba9903cd03051d36f89f (diff)
downloadnncmpp-14dba91dd1b13f1839687c3cd37c245768d36b95.tar.gz
nncmpp-14dba91dd1b13f1839687c3cd37c245768d36b95.tar.xz
nncmpp-14dba91dd1b13f1839687c3cd37c245768d36b95.zip
Add a go-to-playing action and binding
-rw-r--r--NEWS2
-rw-r--r--nncmpp.actions2
-rw-r--r--nncmpp.c8
3 files changed, 12 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index b337626..a33f735 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/nncmpp.actions b/nncmpp.actions
index 55db685..1eed3b7 100644
--- a/nncmpp.actions
+++ b/nncmpp.actions
@@ -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
diff --git a/nncmpp.c b/nncmpp.c
index 266588d..e05af0b 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -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: