From 5721074b4819dcbe604978509d3b6e9d270390ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sat, 3 Jun 2017 23:33:08 +0200 Subject: Make backspace go up a level --- nncmpp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nncmpp.c b/nncmpp.c index 18c87c6..a2279b9 100644 --- a/nncmpp.c +++ b/nncmpp.c @@ -1400,6 +1400,7 @@ app_goto_tab (int tab_index) \ XX( CHOOSE, "Choose item" ) \ XX( DELETE, "Delete item" ) \ + XX( UP, "Go up a level" ) \ \ XX( SCROLL_UP, "Scroll up" ) \ XX( SCROLL_DOWN, "Scroll down" ) \ @@ -1713,6 +1714,7 @@ g_default_bindings[] = // Not sure how to set these up, they're pretty arbitrary so far { "Enter", ACTION_CHOOSE, {}}, { "Delete", ACTION_DELETE, {}}, + { "Backspace", ACTION_UP, {}}, { "a", ACTION_MPD_ADD, {}}, { "r", ACTION_MPD_REPLACE, {}}, @@ -2048,6 +2050,24 @@ library_tab_on_action (enum action action) default: hard_assert (!"invalid item type"); } return true; + case ACTION_UP: + { + // TODO: probably put this in a special function + char *path = g_library_tab.path.str; + if (!*path) + return false; + + char *last_slash; + if ((last_slash = strrchr (path, '/'))) + { + char *up = xstrndup (path, last_slash - path); + library_tab_reload (up); + free (up); + } + else + library_tab_reload (""); + return true; + } case ACTION_MPD_REPLACE: // FIXME: we also need to play it if we've been playing things already if (x.type != LIBRARY_DIR && x.type != LIBRARY_FILE) -- cgit v1.2.3