From 98fb747e6ae7ccded2e8aa46154df5d834a72e1a Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 17 Jul 2013 01:33:12 +0200 Subject: Add several help topic aliases Add aliases and choose the right help topic if the user requests help on a key binding or a key binding label. Signed-off-by: Lukas Fleischer --- src/calcurse.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 8 deletions(-) diff --git a/src/calcurse.c b/src/calcurse.c index 9127c98..00181b7 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -500,20 +500,104 @@ static inline void key_generic_cmd(void) if (!strcmp(cmd_name, "help")) { char *topic = strtok(NULL, " "); + char *topic_res = topic; char path[BUFSIZ]; - if (!topic) - topic = "intro"; + if (!topic_res) + topic_res = "intro"; + snprintf(path, BUFSIZ, DOCDIR "/%s.txt", topic_res); - snprintf(path, BUFSIZ, DOCDIR "/%s.txt", topic); + if (!io_file_exist(path) && keys_str2int(topic_res) > 0 && + keys_get_action(keys_str2int(topic_res)) > 0) { + int ch = keys_str2int(topic_res); + enum key action = keys_get_action(ch); + topic_res = (char *)keys_get_label(action); + snprintf(path, BUFSIZ, DOCDIR "/%s.txt", topic_res); + } - if (!io_file_exist(path) && keys_str2int(topic) > 0 && - keys_get_action(keys_str2int(topic)) > 0) { - enum key action = keys_get_action(keys_str2int(topic)); - snprintf(path, BUFSIZ, DOCDIR "/%s.txt", - keys_get_label(action)); + if (!io_file_exist(path)) { + if (!strcmp(topic_res, "generic-credits")) + topic_res = "credits"; + else if (!strcmp(topic_res, "generic-help")) + topic_res = "intro"; + else if (!strcmp(topic_res, "generic-save")) + topic_res = "save"; + else if (!strcmp(topic_res, "generic-copy")) + topic_res = "copy_paste"; + else if (!strcmp(topic_res, "generic-paste")) + topic_res = "copy_paste"; + else if (!strcmp(topic_res, "generic-change-view")) + topic_res = "tab"; + else if (!strcmp(topic_res, "generic-import")) + topic_res = "import"; + else if (!strcmp(topic_res, "generic-export")) + topic_res = "export"; + else if (!strcmp(topic_res, "generic-goto")) + topic_res = "goto"; + else if (!strcmp(topic_res, "generic-other-cmd")) + topic_res = "other"; + else if (!strcmp(topic_res, "generic-config-menu")) + topic_res = "config"; + else if (!strcmp(topic_res, "generic-add-appt")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-add-todo")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-prev-day")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-next-day")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-prev-week")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-next-week")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-prev-month")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-next-month")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-prev-year")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-next-year")) + topic_res = "general"; + else if (!strcmp(topic_res, "generic-goto-today")) + topic_res = "general"; + else if (!strcmp(topic_res, "move-right")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "move-left")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "move-down")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "move-up")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "start-of-week")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "end-of-week")) + topic_res = "displacement"; + else if (!strcmp(topic_res, "add-item")) + topic_res = "add"; + else if (!strcmp(topic_res, "del-item")) + topic_res = "delete"; + else if (!strcmp(topic_res, "edit-item")) + topic_res = "edit"; + else if (!strcmp(topic_res, "view-item")) + topic_res = "view"; + else if (!strcmp(topic_res, "pipe-item")) + topic_res = "pipe"; + else if (!strcmp(topic_res, "flag-item")) + topic_res = "flag"; + else if (!strcmp(topic_res, "repeat")) + topic_res = "repeat"; + else if (!strcmp(topic_res, "edit-note")) + topic_res = "enote"; + else if (!strcmp(topic_res, "view-note")) + topic_res = "vnote"; + else if (!strcmp(topic_res, "raise-priority")) + topic_res = "priority"; + else if (!strcmp(topic_res, "lower-priority")) + topic_res = "priority"; + snprintf(path, BUFSIZ, DOCDIR "/%s.txt", topic_res); } + if (io_file_exist(path)) { wins_launch_external(path, conf.pager); } else { -- cgit v1.2.3-54-g00ecf