From 48ace0dd89c1be4794f1a3d430718ee8ad350bd6 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 14 May 2004 19:59:09 +0000 Subject: [project @ 2004-05-14 19:59:09 by rjw] Interactive help tokens now fall back to their base key when not available. Help menu is now fully implemented. F1 opens the help page. svn path=/import/netsurf/; revision=864 --- riscos/help.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'riscos/help.c') diff --git a/riscos/help.c b/riscos/help.c index fd026fd4a..d20d5e10c 100644 --- a/riscos/help.c +++ b/riscos/help.c @@ -13,6 +13,7 @@ #include #include #include "oslib/help.h" +#include "oslib/taskmanager.h" #include "oslib/wimp.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/help.h" @@ -40,6 +41,8 @@ The prefixes are followed by either the icon number (eg 'HelpToolbar7'), or a series of numbers representing the menu structure (eg 'HelpBrowserMenu3-1-2'). + If '' is not available, then simply '' is then used. For example + if 'HelpToolbar7' is not available then 'HelpToolbar' is then tried. */ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token); @@ -165,13 +168,32 @@ void ro_gui_interactive_help_request(wimp_message *message) { */ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token) { char *translated_token; + char *base_token; help_full_message_reply *reply; /* Check if the message exists */ translated_token = (char *)messages_get(token); - if (translated_token == token) return; - + if (translated_token == token) { + + /* Find the key from the token. + */ + base_token = translated_token; + while (base_token[0] != 0x00) { + if ((base_token[0] == '-') || + ((base_token[0] >= '0') && (base_token[0] <= '9'))) { + base_token[0] = 0x00; + } else { + *base_token++; + } + } + + /* Check if the base key exists + */ + translated_token = (char *)messages_get(token); + if (translated_token == token) return; + } + /* Copy our message string */ reply = (help_full_message_reply *)message; @@ -185,3 +207,32 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token reply->your_ref = reply->my_ref; wimp_send_message(wimp_USER_MESSAGE, (wimp_message *)reply, reply->sender); } + + +/** + * Checks if interactive help is running + * + * \return the task handle of !Help, or 0 if not available + */ +int ro_gui_interactive_help_available() { + taskmanager_task task; + int context = 0; + char *end; + + /* Attempt to find 'Help' + */ + do { + if (xtaskmanager_enumerate_tasks(context, &task, sizeof(taskmanager_task), + &context, &end)) return 0; + + /* We can't just use strcmp due to string termination issues. + */ + if (strncmp(task.name, "Help", 4) == 0) { + if (task.name[4] < 32) return (int)task.task; + } + } while (context >= 0); + + /* Return failure + */ + return 0; +} -- cgit v1.2.3