aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-23 03:49:39 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-23 03:51:26 +0200
commit77973fc0266b454f44cdcc7782b1a3debdd6d7aa (patch)
tree8ea5ce1dda56b05df1af26e29f8b8e9737d63bc2
parent61be9528e4b3eeb0e2366f386df1897709b21394 (diff)
downloadsdn-77973fc0266b454f44cdcc7782b1a3debdd6d7aa.tar.gz
sdn-77973fc0266b454f44cdcc7782b1a3debdd6d7aa.tar.xz
sdn-77973fc0266b454f44cdcc7782b1a3debdd6d7aa.zip
Group help message by action
Considerably more useful and concise.
-rw-r--r--sdn.cpp12
1 files 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<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");
}