Allow running arbitrary MPD commands
This commit is contained in:
parent
4261c81468
commit
33f5ba0b60
2
liberty
2
liberty
|
@ -1 +1 @@
|
|||
Subproject commit 3835b6e49975039a9f72b8920238f3141e7becea
|
||||
Subproject commit 6e9217e5d05d95849fbaa795f92eca4ad86b1507
|
22
nncmpp.c
22
nncmpp.c
|
@ -1555,6 +1555,7 @@ app_goto_tab (int tab_index)
|
|||
\
|
||||
XX( MPD_ADD, "Add song to playlist" ) \
|
||||
XX( MPD_REPLACE, "Replace playlist with song" ) \
|
||||
XX( MPD_COMMAND, "Send a raw command to MPD" ) \
|
||||
\
|
||||
XX( CHOOSE, "Choose item" ) \
|
||||
XX( DELETE, "Delete item" ) \
|
||||
|
@ -1844,6 +1845,22 @@ app_setvol (int value)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
app_on_editor_end (bool confirmed)
|
||||
{
|
||||
struct mpd_client *c = &g.client;
|
||||
if (!confirmed)
|
||||
return;
|
||||
|
||||
size_t len;
|
||||
char *u8 = (char *) u32_to_u8 (g.editor_line, g.editor_len + 1, NULL, &len);
|
||||
mpd_client_send_command_raw (c, u8);
|
||||
free (u8);
|
||||
|
||||
mpd_client_add_task (c, mpd_on_simple_response, NULL);
|
||||
mpd_client_idle (c, 0);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
static bool
|
||||
|
@ -1865,6 +1882,10 @@ app_process_action (enum action action)
|
|||
clear ();
|
||||
app_invalidate ();
|
||||
return true;
|
||||
case ACTION_MPD_COMMAND:
|
||||
app_editor_start (':');
|
||||
g.on_editor_end = app_on_editor_end;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
|
@ -2071,6 +2092,7 @@ g_default_bindings[] =
|
|||
{ "Backspace", ACTION_UP, {}},
|
||||
{ "a", ACTION_MPD_ADD, {}},
|
||||
{ "r", ACTION_MPD_REPLACE, {}},
|
||||
{ ":", ACTION_MPD_COMMAND, {}},
|
||||
|
||||
{ "Left", ACTION_MPD_PREVIOUS, {}},
|
||||
{ "Right", ACTION_MPD_NEXT, {}},
|
||||
|
|
Loading…
Reference in New Issue