From 77973fc0266b454f44cdcc7782b1a3debdd6d7aa Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Fri, 23 Oct 2020 03:49:39 +0200 Subject: Group help message by action Considerably more useful and concise. --- sdn.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sdn.cpp b/sdn.cpp index 1ad601a..ab07d3a 100644 --- a/sdn.cpp +++ b/sdn.cpp @@ -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 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"); } -- cgit v1.2.3-70-g09d2