Group help message by action

Considerably more useful and concise.
This commit is contained in:
Přemysl Eric Janouch 2020-10-23 03:49:39 +02:00
parent 61be9528e4
commit 77973fc026
Signed by: p
GPG Key ID: A0420B94F92B9493

12
sdn.cpp
View File

@ -979,11 +979,13 @@ fun show_help () {
for (const auto &kv : g_binding_contexts) {
fprintf (contents, "%s\n",
underline (capitalize (kv.first + " key bindings")).c_str ());
for (const auto &kv : *kv.second) {
auto key = encode_key (kv.first);
key.append (max (0, 10 - compute_width (to_wide (key))), ' ');
fprintf (contents, "%s %s\n",
key.c_str (), g.action_names[kv.second].c_str ());
map<action, string> agg;
for (const auto &kv : *kv.second)
agg[kv.second] += encode_key (kv.first) + " ";
for (const auto &kv : agg) {
auto action = g.action_names[kv.first];
action.append (max (0, 20 - int (action.length ())), ' ');
fprintf (contents, "%s %s\n", action.c_str (), kv.second.c_str ());
}
fprintf (contents, "\n");
}