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