From f36484f4043be83dba7e3a242d96636f2f7a29c1 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 18 Jul 2013 11:29:10 +0200 Subject: Split online help code into a separate function Reintroduce help.c and move the online help code into a new function display_help(). Signed-off-by: Lukas Fleischer --- src/calcurse.c | 101 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 100 deletions(-) (limited to 'src/calcurse.c') diff --git a/src/calcurse.c b/src/calcurse.c index 2588721..3879fec 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -500,107 +500,8 @@ 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_res) - topic_res = "intro"; - snprintf(path, BUFSIZ, DOCDIR "/%s.txt", topic_res); - - if (!io_file_exists(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_exists(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_exists(path)) { - wins_launch_external(path, conf.pager); - } else { + if (!display_help(topic)) { char error_msg[BUFSIZ]; snprintf(error_msg, BUFSIZ, -- cgit v1.2.3-54-g00ecf