Compare commits
No commits in common. "6298235e227bf98e5869d555747cb055963a2658" and "0e443c0dcd3e904b60b0efd69cb0fca62cf8240c" have entirely different histories.
6298235e22
...
0e443c0dcd
114
nncmpp.c
114
nncmpp.c
@ -1548,10 +1548,6 @@ app_goto_tab (int tab_index)
|
|||||||
XX( MPD_SEARCH, "Global search" ) \
|
XX( MPD_SEARCH, "Global search" ) \
|
||||||
XX( MPD_ADD, "Add selection to playlist" ) \
|
XX( MPD_ADD, "Add selection to playlist" ) \
|
||||||
XX( MPD_REPLACE, "Replace playlist" ) \
|
XX( MPD_REPLACE, "Replace playlist" ) \
|
||||||
XX( MPD_REPEAT, "Toggle repeat" ) \
|
|
||||||
XX( MPD_RANDOM, "Toggle random playback" ) \
|
|
||||||
XX( MPD_SINGLE, "Toggle single song playback" ) \
|
|
||||||
XX( MPD_CONSUME, "Toggle consume" ) \
|
|
||||||
XX( MPD_UPDATE_DB, "Update MPD database" ) \
|
XX( MPD_UPDATE_DB, "Update MPD database" ) \
|
||||||
XX( MPD_COMMAND, "Send raw command to MPD" ) \
|
XX( MPD_COMMAND, "Send raw command to MPD" ) \
|
||||||
\
|
\
|
||||||
@ -1702,14 +1698,6 @@ app_on_editor_end (bool confirmed)
|
|||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
static bool
|
|
||||||
app_mpd_toggle (const char *name)
|
|
||||||
{
|
|
||||||
const char *s = str_map_find (&g.playback_info, name);
|
|
||||||
bool value = s && strcmp (s, "0");
|
|
||||||
return MPD_SIMPLE (name, value ? "0" : "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
app_process_action (enum action action)
|
app_process_action (enum action action)
|
||||||
{
|
{
|
||||||
@ -1779,10 +1767,6 @@ app_process_action (enum action action)
|
|||||||
case ACTION_MPD_NEXT: return MPD_SIMPLE ("next");
|
case ACTION_MPD_NEXT: return MPD_SIMPLE ("next");
|
||||||
case ACTION_MPD_FORWARD: return MPD_SIMPLE ("seekcur", "+10");
|
case ACTION_MPD_FORWARD: return MPD_SIMPLE ("seekcur", "+10");
|
||||||
case ACTION_MPD_BACKWARD: return MPD_SIMPLE ("seekcur", "-10");
|
case ACTION_MPD_BACKWARD: return MPD_SIMPLE ("seekcur", "-10");
|
||||||
case ACTION_MPD_REPEAT: return app_mpd_toggle ("repeat");
|
|
||||||
case ACTION_MPD_RANDOM: return app_mpd_toggle ("random");
|
|
||||||
case ACTION_MPD_SINGLE: return app_mpd_toggle ("single");
|
|
||||||
case ACTION_MPD_CONSUME: return app_mpd_toggle ("consume");
|
|
||||||
case ACTION_MPD_UPDATE_DB: return MPD_SIMPLE ("update");
|
case ACTION_MPD_UPDATE_DB: return MPD_SIMPLE ("update");
|
||||||
|
|
||||||
case ACTION_MPD_VOLUME_UP: return app_setvol (g.volume + 10);
|
case ACTION_MPD_VOLUME_UP: return app_setvol (g.volume + 10);
|
||||||
@ -3069,28 +3053,7 @@ info_tab_init (void)
|
|||||||
|
|
||||||
// --- Help tab ----------------------------------------------------------------
|
// --- Help tab ----------------------------------------------------------------
|
||||||
|
|
||||||
static struct
|
static struct strv g_help_tab_lines;
|
||||||
{
|
|
||||||
struct tab super; ///< Parent class
|
|
||||||
ARRAY (enum action, actions) ///< Actions for content
|
|
||||||
struct strv lines; ///< Visible content
|
|
||||||
}
|
|
||||||
g_help_tab;
|
|
||||||
|
|
||||||
static bool
|
|
||||||
help_tab_on_action (enum action action)
|
|
||||||
{
|
|
||||||
struct tab *self = g.active_tab;
|
|
||||||
if (self->item_selected < 0
|
|
||||||
|| self->item_selected >= (int) g_help_tab.actions_len
|
|
||||||
|| action != ACTION_CHOOSE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
action = g_help_tab.actions[self->item_selected];
|
|
||||||
return action != ACTION_NONE
|
|
||||||
&& action != ACTION_CHOOSE // avoid recursion
|
|
||||||
&& app_process_action (action);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_tab_strfkey (const termo_key_t *key, struct strv *out)
|
help_tab_strfkey (const termo_key_t *key, struct strv *out)
|
||||||
@ -3108,20 +3071,7 @@ help_tab_strfkey (const termo_key_t *key, struct strv *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_tab_assign_action (enum action action)
|
help_tab_group (struct binding *keys, size_t len, struct strv *out)
|
||||||
{
|
|
||||||
hard_assert (g_help_tab.lines.len > g_help_tab.actions_len);
|
|
||||||
|
|
||||||
size_t to_push = g_help_tab.lines.len - g_help_tab.actions_len;
|
|
||||||
ARRAY_RESERVE (g_help_tab.actions, to_push);
|
|
||||||
for (size_t i = 1; i < to_push; i++)
|
|
||||||
g_help_tab.actions[g_help_tab.actions_len++] = ACTION_NONE;
|
|
||||||
g_help_tab.actions[g_help_tab.actions_len++] = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
help_tab_group (struct binding *keys, size_t len, struct strv *out,
|
|
||||||
bool bound[ACTION_COUNT])
|
|
||||||
{
|
{
|
||||||
for (enum action i = 0; i < ACTION_COUNT; i++)
|
for (enum action i = 0; i < ACTION_COUNT; i++)
|
||||||
{
|
{
|
||||||
@ -3135,71 +3085,39 @@ help_tab_group (struct binding *keys, size_t len, struct strv *out,
|
|||||||
strv_append_owned (out, xstrdup_printf
|
strv_append_owned (out, xstrdup_printf
|
||||||
(" %-30s %s", g_actions[i].description, joined));
|
(" %-30s %s", g_actions[i].description, joined));
|
||||||
free (joined);
|
free (joined);
|
||||||
|
|
||||||
bound[i] = true;
|
|
||||||
help_tab_assign_action (i);
|
|
||||||
}
|
}
|
||||||
strv_free (&ass);
|
strv_free (&ass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
help_tab_unbound (struct strv *out, bool bound[ACTION_COUNT])
|
|
||||||
{
|
|
||||||
for (enum action i = 0; i < ACTION_COUNT; i++)
|
|
||||||
if (!bound[i])
|
|
||||||
{
|
|
||||||
strv_append_owned (out,
|
|
||||||
xstrdup_printf (" %-30s", g_actions[i].description));
|
|
||||||
help_tab_assign_action (i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_tab_on_item_draw (size_t item_index, struct row_buffer *buffer, int width)
|
help_tab_on_item_draw (size_t item_index, struct row_buffer *buffer, int width)
|
||||||
{
|
{
|
||||||
(void) width;
|
(void) width;
|
||||||
|
|
||||||
hard_assert (item_index < g_help_tab.lines.len);
|
hard_assert (item_index < g_help_tab_lines.len);
|
||||||
const char *line = g_help_tab.lines.vector[item_index];
|
const char *line = g_help_tab_lines.vector[item_index];
|
||||||
row_buffer_append (buffer, line, *line == ' ' ? 0 : A_BOLD);
|
row_buffer_append (buffer, line, *line == ' ' ? 0 : A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tab *
|
static struct tab *
|
||||||
help_tab_init (void)
|
help_tab_init (void)
|
||||||
{
|
{
|
||||||
ARRAY_INIT (g_help_tab.actions);
|
g_help_tab_lines = strv_make ();
|
||||||
struct strv *lines = &g_help_tab.lines;
|
|
||||||
*lines = strv_make ();
|
|
||||||
|
|
||||||
bool bound[ACTION_COUNT] = { [ACTION_NONE] = true };
|
strv_append (&g_help_tab_lines, "Normal mode actions");
|
||||||
|
help_tab_group (g_normal_keys, g_normal_keys_len, &g_help_tab_lines);
|
||||||
|
strv_append (&g_help_tab_lines, "");
|
||||||
|
|
||||||
strv_append (lines, "Normal mode actions");
|
strv_append (&g_help_tab_lines, "Editor mode actions");
|
||||||
help_tab_group (g_normal_keys, g_normal_keys_len, lines, bound);
|
help_tab_group (g_editor_keys, g_editor_keys_len, &g_help_tab_lines);
|
||||||
strv_append (lines, "");
|
strv_append (&g_help_tab_lines, "");
|
||||||
|
|
||||||
strv_append (lines, "Editor mode actions");
|
static struct tab super;
|
||||||
help_tab_group (g_editor_keys, g_editor_keys_len, lines, bound);
|
tab_init (&super, "Help");
|
||||||
strv_append (lines, "");
|
super.on_item_draw = help_tab_on_item_draw;
|
||||||
|
super.item_count = g_help_tab_lines.len;
|
||||||
bool have_unbound = false;
|
return &super;
|
||||||
for (enum action i = 0; i < ACTION_COUNT; i++)
|
|
||||||
if (!bound[i])
|
|
||||||
have_unbound = true;
|
|
||||||
|
|
||||||
if (have_unbound)
|
|
||||||
{
|
|
||||||
strv_append (lines, "Unbound actions");
|
|
||||||
help_tab_unbound (lines, bound);
|
|
||||||
strv_append (lines, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tab *super = &g_help_tab.super;
|
|
||||||
tab_init (super, "Help");
|
|
||||||
super->on_action = help_tab_on_action;
|
|
||||||
super->on_item_draw = help_tab_on_item_draw;
|
|
||||||
super->item_count = lines->len;
|
|
||||||
return super;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Debug tab ---------------------------------------------------------------
|
// --- Debug tab ---------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user