summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/help.c')
-rw-r--r--apps/plugins/puzzles/help.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/help.c b/apps/plugins/puzzles/help.c
new file mode 100644
index 0000000000..13ca7eaa8a
--- /dev/null
+++ b/apps/plugins/puzzles/help.c
@@ -0,0 +1,48 @@
1#include "help.h"
2#include "lib/simple_viewer.h"
3
4void full_help(const char *name)
5{
6 int ch_num = -1;
7 /* search the help text for a chapter with this name */
8 for(int ch = 0; ch < help_numchapters; ++ch)
9 {
10 char *str = help_text + help_chapteroffsets[ch];
11 char *ptr = strchr(str, ':') + 1;
12 const char *namep = name;
13 if(*ptr++ != ' ')
14 continue;
15
16 while(*ptr == *namep && *ptr && *namep)
17 {
18 ptr++;
19 namep++;
20 }
21 if(*namep == '\0' && (*ptr == '\n' || *ptr == ' ')) /* full match */
22 {
23 ch_num = ch;
24 break;
25 }
26 }
27 if(ch_num < 0)
28 {
29 rb->splashf(HZ * 2, "No topic found for `%s' (REPORT ME!)", name);
30 return;
31 }
32 char *buf = smalloc(help_maxlen + 1);
33 rb->memset(buf, 0, help_maxlen + 1);
34 if(ch_num < help_numchapters - 1)
35 {
36 /* safe to look ahead */
37 memcpy(buf, help_text + help_chapteroffsets[ch_num], help_chapteroffsets[ch_num + 1] - help_chapteroffsets[ch_num]);
38 }
39 else
40 rb->strlcpy(buf, help_text + help_chapteroffsets[ch_num], help_maxlen + 1);
41
42 rb->lcd_set_foreground(LCD_WHITE);
43 unsigned old_bg = rb->lcd_get_background();
44 rb->lcd_set_background(LCD_BLACK);
45 view_text(name, buf);
46 rb->lcd_set_background(old_bg);
47 sfree(buf);
48}