Show unbound actions in help
This commit is contained in:
parent
0e443c0dcd
commit
5ade0f082e
33
nncmpp.c
33
nncmpp.c
|
@ -3071,7 +3071,8 @@ help_tab_strfkey (const termo_key_t *key, struct strv *out)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_tab_group (struct binding *keys, size_t len, struct strv *out)
|
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++)
|
||||||
{
|
{
|
||||||
|
@ -3085,11 +3086,24 @@ 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;
|
||||||
}
|
}
|
||||||
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -3104,15 +3118,28 @@ static struct tab *
|
||||||
help_tab_init (void)
|
help_tab_init (void)
|
||||||
{
|
{
|
||||||
g_help_tab_lines = strv_make ();
|
g_help_tab_lines = strv_make ();
|
||||||
|
bool bound[ACTION_COUNT] = { [ACTION_NONE] = true };
|
||||||
|
|
||||||
strv_append (&g_help_tab_lines, "Normal mode actions");
|
strv_append (&g_help_tab_lines, "Normal mode actions");
|
||||||
help_tab_group (g_normal_keys, g_normal_keys_len, &g_help_tab_lines);
|
help_tab_group (g_normal_keys, g_normal_keys_len, &g_help_tab_lines, bound);
|
||||||
strv_append (&g_help_tab_lines, "");
|
strv_append (&g_help_tab_lines, "");
|
||||||
|
|
||||||
strv_append (&g_help_tab_lines, "Editor mode actions");
|
strv_append (&g_help_tab_lines, "Editor mode actions");
|
||||||
help_tab_group (g_editor_keys, g_editor_keys_len, &g_help_tab_lines);
|
help_tab_group (g_editor_keys, g_editor_keys_len, &g_help_tab_lines, bound);
|
||||||
strv_append (&g_help_tab_lines, "");
|
strv_append (&g_help_tab_lines, "");
|
||||||
|
|
||||||
|
bool have_unbound = false;
|
||||||
|
for (enum action i = 0; i < ACTION_COUNT; i++)
|
||||||
|
if (!bound[i])
|
||||||
|
have_unbound = true;
|
||||||
|
|
||||||
|
if (have_unbound)
|
||||||
|
{
|
||||||
|
strv_append (&g_help_tab_lines, "Unbound actions");
|
||||||
|
help_tab_unbound (&g_help_tab_lines, bound);
|
||||||
|
strv_append (&g_help_tab_lines, "");
|
||||||
|
}
|
||||||
|
|
||||||
static struct tab super;
|
static struct tab super;
|
||||||
tab_init (&super, "Help");
|
tab_init (&super, "Help");
|
||||||
super.on_item_draw = help_tab_on_item_draw;
|
super.on_item_draw = help_tab_on_item_draw;
|
||||||
|
|
Loading…
Reference in New Issue