summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/genhelp.sh
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-03-17 22:54:07 -0400
committerFranklin Wei <git@fwei.tk>2018-03-17 22:54:21 -0400
commit77641d59a7ece60554da6cc1337d885786e5fc3f (patch)
tree5ce575a78224ba993c9f31ba94734a8ebc56203f /apps/plugins/puzzles/genhelp.sh
parent6039eb05ba6d82ef56f2868c96654c552d117bf9 (diff)
downloadrockbox-77641d59a7ece60554da6cc1337d885786e5fc3f.tar.gz
rockbox-77641d59a7ece60554da6cc1337d885786e5fc3f.zip
puzzles: add formatting to help viewer
The help text is now processed to generate a style array to pass to the display_text library in addition to the text itself. The help text is still compressed using LZ4, and still fits on the c200v2. Change-Id: I7a3a664f90f67a1a018956c72d2b62d92b8ffd17
Diffstat (limited to 'apps/plugins/puzzles/genhelp.sh')
-rwxr-xr-xapps/plugins/puzzles/genhelp.sh84
1 files changed, 56 insertions, 28 deletions
diff --git a/apps/plugins/puzzles/genhelp.sh b/apps/plugins/puzzles/genhelp.sh
index 1d4dac794b..007cdafd21 100755
--- a/apps/plugins/puzzles/genhelp.sh
+++ b/apps/plugins/puzzles/genhelp.sh
@@ -21,37 +21,65 @@ rm puzzles.txt.tmp
21# now split into different files 21# now split into different files
22mkdir -p help 22mkdir -p help
23 23
24cat puzzles.txt | awk 'BEGIN { file = "none"; } 24cat puzzles.txt | awk '
25 /#Chapter/ { 25BEGIN {
26 if($0 !~ / 1:/ && $0 !~ / 2:/) 26 file = "none";
27 { 27}
28 if(file != "none") 28
29 print ";" > file; 29/#Chapter/ {
30 file = "help/"tolower($3$4)".c"; 30 if($0 !~ / 1:/ && $0 !~ / 2:/)
31 if($3 ~ "Rectangles") 31 {
32 file = "help/rect.c"; 32 if(file != "none")
33 print "/* auto-generated by genhelp.sh */" > file; 33 print ";" > file;
34 print "/* DO NOT EDIT! */" > file; 34 file = "help/"tolower($3$4)".c";
35 print "const char help_text[] = " > file; } 35
36 } 36 if($3 ~ "Rectangles")
37 file != "none" { 37 file = "help/rect.c";
38 gsub(/\\/,"\\\\"); 38
39 if($0 !~ /Chapter/ && substr($0, 1, 1) == "#") 39 print "/* auto-generated by genhelp.sh (intermediate file) */" > file;
40 begin = "\\n"; 40 print "/* DO NOT EDIT! */" > file;
41 else begin = ""; 41 print "const char help_text[] = " > file;
42 last = substr($0, length($0), 1); 42 }
43 if(length($0) == 0 || last == "|" || last == "-" || (term == "\\n" && last == "3")) 43}
44 term="\\n"; 44
45 else term = " "; 45file != "none" {
46 print "\"" begin $0 term "\"" > file; 46 /* escape backslashes */
47 } 47 gsub(/\\/,"\\\\");
48 END { 48
49 print ";" > file; 49 if($0 ~ /\$/)
50 } 50 print("WARNING: text contains dollar sign: change special character!" $0);
51
52 /* replace underscores with dollar signs (not used in any of the puzzles docs) */
53 if($0 ~ /http/)
54 gsub(/_/,"$");
55
56 begin = "";
57
58 last = substr($0, length($0), 1);
59
60 /* hack for chapter titles */
61 if(substr($0, 1, 1) == "#" || length($0) == 0)
62 term=" \\n";
63 else
64 term = " ";
65
66 /* custom code markup (halibut modification required) */
67 if(substr($0, 1, 2) == ">>")
68 {
69 gsub(/>> /,"");
70 term = " \\n";
71 }
72
73 print "\"" begin $0 term "\"" > file;
74}
75
76END {
77 print ";" > file;
78}
51' 79'
52 80
53# now compress 81# now compress
54for f in help/* 82for f in help/*.c
55do 83do
56 echo "Compressing: "$f 84 echo "Compressing: "$f
57 gcc compress.c $f -llz4 -o compress -O0 85 gcc compress.c $f -llz4 -o compress -O0