diff options
-rw-r--r-- | default.bld | 2 | ||||
-rw-r--r-- | mingw.bld | 2 | ||||
-rw-r--r-- | src/options.cpp | 15 | ||||
-rw-r--r-- | src/options.h | 1 | ||||
-rw-r--r-- | src/smlrenderervt100.cpp | 74 | ||||
-rw-r--r-- | src/smlrenderervt100.h | 8 |
6 files changed, 91 insertions, 11 deletions
diff --git a/default.bld b/default.bld index 66c3825..b35ee6a 100644 --- a/default.bld +++ b/default.bld | |||
@@ -53,7 +53,7 @@ target "stage" | |||
53 | FLEXFLAGS="-osrc/parser.yy.c --header-file=src/parser.yy.h"; | 53 | FLEXFLAGS="-osrc/parser.yy.c --header-file=src/parser.yy.h"; |
54 | BISONFLAGS="-d"; | 54 | BISONFLAGS="-d"; |
55 | 55 | ||
56 | LDFLAGS += "-Llibgats -lgats -lbu++ -ldl"; | 56 | LDFLAGS += "-Llibgats -lgats -lbu++ -ldl -lz"; |
57 | } | 57 | } |
58 | 58 | ||
59 | /* | 59 | /* |
@@ -58,7 +58,7 @@ target "stage.exe" | |||
58 | 58 | ||
59 | CXXFLAGS += "-O2 -frtti -fexceptions -Wall -Ilibbu++/support/windows -Isrc -Ilibgats"; | 59 | CXXFLAGS += "-O2 -frtti -fexceptions -Wall -Ilibbu++/support/windows -Isrc -Ilibgats"; |
60 | 60 | ||
61 | LDFLAGS += "-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -lmingw32 -Llibbu++ -Llibbu++/support/windows -lbz2 -Wl,-subsystem,console -Llibgats -lgatswin -lbu++win -lwsock32"; | 61 | LDFLAGS += "-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -lmingw32 -Llibbu++ -Llibbu++/support/windows -lbz2 -Wl,-subsystem,console -Llibgats -lgatswin -lbu++win -lwsock32 -lz"; |
62 | 62 | ||
63 | CXXFLAGS += "-Ilibbu++"; | 63 | CXXFLAGS += "-Ilibbu++"; |
64 | } | 64 | } |
diff --git a/src/options.cpp b/src/options.cpp index f8112c4..93a29bc 100644 --- a/src/options.cpp +++ b/src/options.cpp | |||
@@ -12,6 +12,8 @@ | |||
12 | #include <gats/gatsstream.h> | 12 | #include <gats/gatsstream.h> |
13 | #include <gats/types.h> | 13 | #include <gats/types.h> |
14 | 14 | ||
15 | #include <bu/deflate.h> | ||
16 | |||
15 | #include "interfaceplugger.h" | 17 | #include "interfaceplugger.h" |
16 | 18 | ||
17 | using namespace Bu; | 19 | using namespace Bu; |
@@ -48,6 +50,8 @@ void Options::parse( int argc, char *argv[] ) | |||
48 | 50 | ||
49 | opt.addOption( Bu::slot( this, &Options::smlTest ), "sml-test", | 51 | opt.addOption( Bu::slot( this, &Options::smlTest ), "sml-test", |
50 | "Test SML parser." ); | 52 | "Test SML parser." ); |
53 | opt.addOption( Bu::slot( this, &Options::smlHelp ), "sml-help", | ||
54 | "Display SML help." ); | ||
51 | opt.addOption( sCommand, "command", | 55 | opt.addOption( sCommand, "command", |
52 | "Set the command to execute once the game is loaded. " | 56 | "Set the command to execute once the game is loaded. " |
53 | "This does not work with all interfaces."); | 57 | "This does not work with all interfaces."); |
@@ -124,6 +128,17 @@ int Options::smlTest( Bu::Array<Bu::String> aArgs ) | |||
124 | return 0; | 128 | return 0; |
125 | } | 129 | } |
126 | 130 | ||
131 | int Options::smlHelp( Bu::Array<Bu::String> aArgs ) | ||
132 | { | ||
133 | Bu::File fIn("sml-help.sml.gz", Bu::File::Read ); | ||
134 | Bu::Deflate dIn( fIn ); | ||
135 | char buf[4096]; | ||
136 | buf[dIn.read( buf, 4096 )] = '\0'; | ||
137 | printf("%s\n", buf ); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
127 | int Options::nonOption( Bu::Array<Bu::String> aArgs ) | 142 | int Options::nonOption( Bu::Array<Bu::String> aArgs ) |
128 | { | 143 | { |
129 | sFile = aArgs[0]; | 144 | sFile = aArgs[0]; |
diff --git a/src/options.h b/src/options.h index bf9825f..4ac030b 100644 --- a/src/options.h +++ b/src/options.h | |||
@@ -23,6 +23,7 @@ protected: | |||
23 | int version( Bu::Array<Bu::String> aArgs ); | 23 | int version( Bu::Array<Bu::String> aArgs ); |
24 | int builtins( Bu::Array<Bu::String> aArgs ); | 24 | int builtins( Bu::Array<Bu::String> aArgs ); |
25 | int smlTest( Bu::Array<Bu::String> aArgs ); | 25 | int smlTest( Bu::Array<Bu::String> aArgs ); |
26 | int smlHelp( Bu::Array<Bu::String> aArgs ); | ||
26 | int nonOption( Bu::Array<Bu::String> aArgs ); | 27 | int nonOption( Bu::Array<Bu::String> aArgs ); |
27 | int printResult( Bu::Array<Bu::String> aArgs ); | 28 | int printResult( Bu::Array<Bu::String> aArgs ); |
28 | }; | 29 | }; |
diff --git a/src/smlrenderervt100.cpp b/src/smlrenderervt100.cpp index 2b59d5f..5ab3d82 100644 --- a/src/smlrenderervt100.cpp +++ b/src/smlrenderervt100.cpp | |||
@@ -63,11 +63,67 @@ Bu::String SmlRendererVt100::getStyle( const StyleStack &sStyle ) | |||
63 | case stGreen: | 63 | case stGreen: |
64 | sRet += "\x1B[1;32m"; | 64 | sRet += "\x1B[1;32m"; |
65 | break; | 65 | break; |
66 | |||
67 | case stYellow: | ||
68 | sRet += "\x1B[1;33m"; | ||
69 | break; | ||
70 | |||
71 | case stBlue: | ||
72 | sRet += "\x1B[1;34m"; | ||
73 | break; | ||
74 | |||
75 | case stMagenta: | ||
76 | sRet += "\x1B[1;35m"; | ||
77 | break; | ||
78 | |||
79 | case stCyan: | ||
80 | sRet += "\x1B[1;36m"; | ||
81 | break; | ||
82 | |||
83 | case stWhite: | ||
84 | sRet += "\x1B[1;37m"; | ||
85 | break; | ||
66 | } | 86 | } |
67 | 87 | ||
68 | return sRet; | 88 | return sRet; |
69 | } | 89 | } |
70 | 90 | ||
91 | SmlRendererVt100::Style SmlRendererVt100::strToStyle( const Bu::String &sTag ) | ||
92 | { | ||
93 | if( sTag == "green" ) | ||
94 | { | ||
95 | return stGreen; | ||
96 | } | ||
97 | else if( sTag == "red" ) | ||
98 | { | ||
99 | return stRed; | ||
100 | } | ||
101 | else if( sTag == "yellow" ) | ||
102 | { | ||
103 | return stYellow; | ||
104 | } | ||
105 | else if( sTag == "blue" ) | ||
106 | { | ||
107 | return stBlue; | ||
108 | } | ||
109 | else if( sTag == "magenta" ) | ||
110 | { | ||
111 | return stMagenta; | ||
112 | } | ||
113 | else if( sTag == "cyan" ) | ||
114 | { | ||
115 | return stCyan; | ||
116 | } | ||
117 | else if( sTag == "white" ) | ||
118 | { | ||
119 | return stWhite; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | return stNone; | ||
124 | } | ||
125 | } | ||
126 | |||
71 | void SmlRendererVt100::render( Bu::Formatter &f, const SmlNode *pNode ) | 127 | void SmlRendererVt100::render( Bu::Formatter &f, const SmlNode *pNode ) |
72 | { | 128 | { |
73 | Bu::String sCurLine; | 129 | Bu::String sCurLine; |
@@ -93,11 +149,16 @@ void SmlRendererVt100::render( Bu::Formatter &f, const SmlNode *pNode ) | |||
93 | { | 149 | { |
94 | // f << "Pop'd: " << (*sNode.peek())->getText() << f.nl; | 150 | // f << "Pop'd: " << (*sNode.peek())->getText() << f.nl; |
95 | Bu::String sTag = (*sNode.peek())->getText(); | 151 | Bu::String sTag = (*sNode.peek())->getText(); |
96 | if( sTag == "green" || sTag == "red" ) | 152 | Style s = strToStyle( sTag ); |
153 | if( sStyle.peek() == s ) | ||
97 | { | 154 | { |
98 | sStyle.pop(); | 155 | sStyle.pop(); |
99 | sNextToken += getStyle( sStyle ); | 156 | sNextToken += getStyle( sStyle ); |
100 | } | 157 | } |
158 | else | ||
159 | { | ||
160 | throw Bu::ExceptionBase("Close tag doesn't match open tag."); | ||
161 | } | ||
101 | sNode.peek()++; | 162 | sNode.peek()++; |
102 | continue; | 163 | continue; |
103 | } | 164 | } |
@@ -199,14 +260,9 @@ void SmlRendererVt100::render( Bu::Formatter &f, const SmlNode *pNode ) | |||
199 | { | 260 | { |
200 | // f << "Push'd: " << pNode->getText() << f.nl; | 261 | // f << "Push'd: " << pNode->getText() << f.nl; |
201 | Bu::String sTag = pNode->getText(); | 262 | Bu::String sTag = pNode->getText(); |
202 | if( sTag == "green" ) | 263 | Style s = strToStyle( sTag ); |
203 | { | 264 | if( s != 0 ) |
204 | sStyle.push( stGreen ); | 265 | sStyle.push( s ); |
205 | } | ||
206 | else if( sTag == "red" ) | ||
207 | { | ||
208 | sStyle.push( stRed ); | ||
209 | } | ||
210 | sNextToken += getStyle( sStyle ); | 266 | sNextToken += getStyle( sStyle ); |
211 | sNode.push( pNode->getChildren().begin() ); | 267 | sNode.push( pNode->getChildren().begin() ); |
212 | continue; | 268 | continue; |
diff --git a/src/smlrenderervt100.h b/src/smlrenderervt100.h index ed5dd42..0f82ca9 100644 --- a/src/smlrenderervt100.h +++ b/src/smlrenderervt100.h | |||
@@ -14,8 +14,15 @@ public: | |||
14 | private: | 14 | private: |
15 | enum Style | 15 | enum Style |
16 | { | 16 | { |
17 | stNone = 0x000000, | ||
18 | |||
17 | stRed = 0x010001, | 19 | stRed = 0x010001, |
18 | stGreen = 0x010002, | 20 | stGreen = 0x010002, |
21 | stYellow = 0x010003, | ||
22 | stBlue = 0x010004, | ||
23 | stMagenta = 0x010005, | ||
24 | stCyan = 0x010006, | ||
25 | stWhite = 0x010007, | ||
19 | 26 | ||
20 | stColor = 0x01000f, | 27 | stColor = 0x01000f, |
21 | 28 | ||
@@ -27,6 +34,7 @@ private: | |||
27 | void appendToken( Bu::Formatter &f, Bu::String &sCurLine, | 34 | void appendToken( Bu::Formatter &f, Bu::String &sCurLine, |
28 | Bu::String &sNextToken, int &iLineLen, int &iNextLen ); | 35 | Bu::String &sNextToken, int &iLineLen, int &iNextLen ); |
29 | Bu::String getStyle( const StyleStack &sStyle ); | 36 | Bu::String getStyle( const StyleStack &sStyle ); |
37 | Style strToStyle( const Bu::String &sStyle ); | ||
30 | }; | 38 | }; |
31 | 39 | ||
32 | #endif | 40 | #endif |