forked from len0rd/rockbox
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
This commit is contained in:
parent
6039eb05ba
commit
77641d59a7
44 changed files with 7768 additions and 6979 deletions
|
@ -21,37 +21,65 @@ rm puzzles.txt.tmp
|
|||
# now split into different files
|
||||
mkdir -p help
|
||||
|
||||
cat puzzles.txt | awk 'BEGIN { file = "none"; }
|
||||
/#Chapter/ {
|
||||
if($0 !~ / 1:/ && $0 !~ / 2:/)
|
||||
{
|
||||
if(file != "none")
|
||||
print ";" > file;
|
||||
file = "help/"tolower($3$4)".c";
|
||||
if($3 ~ "Rectangles")
|
||||
file = "help/rect.c";
|
||||
print "/* auto-generated by genhelp.sh */" > file;
|
||||
print "/* DO NOT EDIT! */" > file;
|
||||
print "const char help_text[] = " > file; }
|
||||
}
|
||||
file != "none" {
|
||||
gsub(/\\/,"\\\\");
|
||||
if($0 !~ /Chapter/ && substr($0, 1, 1) == "#")
|
||||
begin = "\\n";
|
||||
else begin = "";
|
||||
last = substr($0, length($0), 1);
|
||||
if(length($0) == 0 || last == "|" || last == "-" || (term == "\\n" && last == "3"))
|
||||
term="\\n";
|
||||
else term = " ";
|
||||
print "\"" begin $0 term "\"" > file;
|
||||
}
|
||||
END {
|
||||
print ";" > file;
|
||||
}
|
||||
cat puzzles.txt | awk '
|
||||
BEGIN {
|
||||
file = "none";
|
||||
}
|
||||
|
||||
/#Chapter/ {
|
||||
if($0 !~ / 1:/ && $0 !~ / 2:/)
|
||||
{
|
||||
if(file != "none")
|
||||
print ";" > file;
|
||||
file = "help/"tolower($3$4)".c";
|
||||
|
||||
if($3 ~ "Rectangles")
|
||||
file = "help/rect.c";
|
||||
|
||||
print "/* auto-generated by genhelp.sh (intermediate file) */" > file;
|
||||
print "/* DO NOT EDIT! */" > file;
|
||||
print "const char help_text[] = " > file;
|
||||
}
|
||||
}
|
||||
|
||||
file != "none" {
|
||||
/* escape backslashes */
|
||||
gsub(/\\/,"\\\\");
|
||||
|
||||
if($0 ~ /\$/)
|
||||
print("WARNING: text contains dollar sign: change special character!" $0);
|
||||
|
||||
/* replace underscores with dollar signs (not used in any of the puzzles docs) */
|
||||
if($0 ~ /http/)
|
||||
gsub(/_/,"$");
|
||||
|
||||
begin = "";
|
||||
|
||||
last = substr($0, length($0), 1);
|
||||
|
||||
/* hack for chapter titles */
|
||||
if(substr($0, 1, 1) == "#" || length($0) == 0)
|
||||
term=" \\n";
|
||||
else
|
||||
term = " ";
|
||||
|
||||
/* custom code markup (halibut modification required) */
|
||||
if(substr($0, 1, 2) == ">>")
|
||||
{
|
||||
gsub(/>> /,"");
|
||||
term = " \\n";
|
||||
}
|
||||
|
||||
print "\"" begin $0 term "\"" > file;
|
||||
}
|
||||
|
||||
END {
|
||||
print ";" > file;
|
||||
}
|
||||
'
|
||||
|
||||
# now compress
|
||||
for f in help/*
|
||||
for f in help/*.c
|
||||
do
|
||||
echo "Compressing: "$f
|
||||
gcc compress.c $f -llz4 -o compress -O0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue