Make backspace go up a level

This commit is contained in:
Přemysl Eric Janouch 2017-06-03 23:33:08 +02:00
parent a1436318b6
commit 5721074b48
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 20 additions and 0 deletions

View File

@ -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)