Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CFilter.h | 273 |
1 files changed, 94 insertions, 179 deletions
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index 4f609dc..8cfd7eb 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -17,17 +17,2 @@ public: | |||
17 | 17 | ||
18 | class vanilla : public CFilter | ||
19 | { | ||
20 | public: | ||
21 | vanilla() {} | ||
22 | virtual ~vanilla() {} | ||
23 | #ifdef _UNICODE | ||
24 | virtual tchar getch() | ||
25 | #else | ||
26 | virtual int getch() | ||
27 | #endif | ||
28 | { | ||
29 | return parent->getch(); | ||
30 | } | ||
31 | }; | ||
32 | |||
33 | class CFilterChain | 18 | class CFilterChain |
@@ -51,3 +36,6 @@ class CFilterChain | |||
51 | } | 36 | } |
52 | int getch() { return front->getch(); } | 37 | void getch(tchar& ch, CStyle& sty) |
38 | { | ||
39 | front->getch(ch, sty); | ||
40 | } | ||
53 | void addfilter(CFilter* p) | 41 | void addfilter(CFilter* p) |
@@ -84,25 +72,10 @@ public: | |||
84 | virtual ~stripcr() {} | 72 | virtual ~stripcr() {} |
85 | #ifdef _UNICODE | 73 | virtual void getch(tchar& ch, CStyle& sty) |
86 | virtual tchar getch() | ||
87 | { | ||
88 | tchar ch; | ||
89 | do | ||
90 | { | ||
91 | ch = parent->getch(); | ||
92 | } | ||
93 | while (ch == 13); | ||
94 | return ch; | ||
95 | } | ||
96 | #else | ||
97 | virtual int getch() | ||
98 | { | 74 | { |
99 | int ch; | ||
100 | do | 75 | do |
101 | { | 76 | { |
102 | ch = parent->getch(); | 77 | parent->getch(ch, sty); |
103 | } | 78 | } |
104 | while (ch == 13); | 79 | while (ch == 13); |
105 | return ch; | ||
106 | } | 80 | } |
107 | #endif | ||
108 | }; | 81 | }; |
@@ -113,2 +86,3 @@ class dehyphen : public CFilter | |||
113 | tchar m_nextChar; | 86 | tchar m_nextChar; |
87 | CStyle m_nextSty; | ||
114 | public: | 88 | public: |
@@ -116,3 +90,3 @@ class dehyphen : public CFilter | |||
116 | virtual ~dehyphen() {} | 90 | virtual ~dehyphen() {} |
117 | virtual tchar getch() | 91 | virtual void getch(tchar& ch, CStyle& sty) |
118 | { | 92 | { |
@@ -121,7 +95,9 @@ class dehyphen : public CFilter | |||
121 | m_bCharWaiting = false; | 95 | m_bCharWaiting = false; |
122 | return m_nextChar; | 96 | ch = m_nextChar; |
97 | sty = m_nextSty; | ||
98 | return; | ||
123 | } | 99 | } |
124 | tchar ch = parent->getch(); | 100 | parent->getch(ch, sty); |
125 | if (ch != '-') return ch; | 101 | if (ch != '-') return; |
126 | m_nextChar = parent->getch(); | 102 | parent->getch(m_nextChar, m_nextSty); |
127 | if (m_nextChar != 10) | 103 | if (m_nextChar != 10) |
@@ -129,5 +105,6 @@ class dehyphen : public CFilter | |||
129 | m_bCharWaiting = true; | 105 | m_bCharWaiting = true; |
130 | return '-'; | 106 | ch = '-'; |
107 | return; | ||
131 | } | 108 | } |
132 | return parent->getch(); | 109 | parent->getch(ch, sty); |
133 | } | 110 | } |
@@ -137,2 +114,7 @@ class striphtml : public CFilter | |||
137 | { | 114 | { |
115 | CStyle currentstyle; | ||
116 | unsigned short skip_ws(); | ||
117 | unsigned short skip_ws_end(); | ||
118 | unsigned short parse_m(); | ||
119 | void mygetch(tchar& ch, CStyle& sty); | ||
138 | public: | 120 | public: |
@@ -140,53 +122,3 @@ public: | |||
140 | virtual ~striphtml() {} | 122 | virtual ~striphtml() {} |
141 | #ifdef _UNICODE | 123 | virtual void getch(tchar& ch, CStyle& sty); |
142 | virtual tchar getch() | ||
143 | { | ||
144 | tchar ch; | ||
145 | ch = parent->getch(); | ||
146 | while (ch == '<') | ||
147 | { | ||
148 | while (ch != '>') | ||
149 | { | ||
150 | ch = parent->getch(); | ||
151 | } | ||
152 | ch = parent->getch(); | ||
153 | } | ||
154 | if (ch == '&') | ||
155 | { | ||
156 | ch = parent->getch(); | ||
157 | if (ch == '#') | ||
158 | { | ||
159 | int id = 0; | ||
160 | while ((ch = parent->getch()) != ';') id = 10*id+ch-'0'; | ||
161 | ch = id; | ||
162 | } | ||
163 | } | ||
164 | return ch; | ||
165 | } | ||
166 | #else | ||
167 | virtual int getch() | ||
168 | { | ||
169 | int ch; | ||
170 | ch = parent->getch(); | ||
171 | while (ch == '<') | ||
172 | { | ||
173 | while (ch != '>') | ||
174 | { | ||
175 | ch = parent->getch(); | ||
176 | } | ||
177 | ch = parent->getch(); | ||
178 | } | ||
179 | if (ch == '&') | ||
180 | { | ||
181 | ch = parent->getch(); | ||
182 | if (ch == '#') | ||
183 | { | ||
184 | int id = 0; | ||
185 | while ((ch = parent->getch()) != ';') id = 10*id+ch-'0'; | ||
186 | ch = id; | ||
187 | } | ||
188 | } | ||
189 | return ch; | ||
190 | } | ||
191 | #endif | ||
192 | }; | 124 | }; |
@@ -199,30 +131,18 @@ public: | |||
199 | virtual ~unindent() {} | 131 | virtual ~unindent() {} |
200 | #ifdef _UNICODE | 132 | virtual void getch(tchar& ch, CStyle& sty) |
201 | virtual tchar getch() | ||
202 | { | 133 | { |
203 | tchar ch; | ||
204 | if (lc == 10) | 134 | if (lc == 10) |
205 | { | 135 | { |
206 | while ((ch = parent->getch()) == ' '); | 136 | do |
207 | } | ||
208 | else ch = parent->getch(); | ||
209 | lc = ch; | ||
210 | return ch; | ||
211 | } | ||
212 | #else | ||
213 | virtual int getch() | ||
214 | { | ||
215 | int ch; | ||
216 | if (lc == 10) | ||
217 | { | 137 | { |
218 | while ((ch = parent->getch()) == ' '); | 138 | parent->getch(ch, sty); |
139 | } | ||
140 | while (ch == ' '); | ||
219 | } | 141 | } |
220 | else ch = parent->getch(); | 142 | else parent->getch(ch, sty); |
221 | lc = ch; | 143 | lc = ch; |
222 | return ch; | 144 | return; |
223 | } | 145 | } |
224 | #endif | ||
225 | }; | 146 | }; |
226 | 147 | ||
227 | #ifdef _UNICODE | ||
228 | class repara : public CFilter | 148 | class repara : public CFilter |
@@ -233,31 +153,5 @@ public: | |||
233 | virtual ~repara() {} | 153 | virtual ~repara() {} |
234 | virtual tchar getch() | 154 | virtual void getch(tchar& ch, CStyle& sty) |
235 | { | ||
236 | tchar ch = parent->getch(); | ||
237 | if (ch == 10) | ||
238 | { | ||
239 | if (tch == 10) | ||
240 | { | ||
241 | return ch; | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | tch = ch; | ||
246 | return ' '; | ||
247 | } | ||
248 | } | ||
249 | tch = ch; | ||
250 | return ch; | ||
251 | } | ||
252 | }; | ||
253 | #else | ||
254 | class repara : public CFilter | ||
255 | { | ||
256 | int tch; | ||
257 | public: | ||
258 | repara() : tch(0) {} | ||
259 | virtual ~repara() {} | ||
260 | virtual int getch() | ||
261 | { | 155 | { |
262 | int ch = parent->getch(); | 156 | parent->getch(ch, sty); |
263 | if (ch == 10) | 157 | if (ch == 10) |
@@ -266,3 +160,3 @@ public: | |||
266 | { | 160 | { |
267 | return ch; | 161 | return; |
268 | } | 162 | } |
@@ -271,3 +165,4 @@ public: | |||
271 | tch = ch; | 165 | tch = ch; |
272 | return ' '; | 166 | ch = ' '; |
167 | return; | ||
273 | } | 168 | } |
@@ -275,6 +170,5 @@ public: | |||
275 | tch = ch; | 170 | tch = ch; |
276 | return ch; | 171 | return; |
277 | } | 172 | } |
278 | }; | 173 | }; |
279 | #endif | ||
280 | 174 | ||
@@ -284,2 +178,3 @@ class indenter : public CFilter | |||
284 | int indent; | 178 | int indent; |
179 | CStyle lsty; | ||
285 | public: | 180 | public: |
@@ -287,19 +182,3 @@ public: | |||
287 | virtual ~indenter() {} | 182 | virtual ~indenter() {} |
288 | #ifdef _UNICODE | 183 | virtual void getch(tchar& ch, CStyle& sty) |
289 | virtual tchar getch() | ||
290 | { | ||
291 | if (indent > 0) | ||
292 | { | ||
293 | indent--; | ||
294 | return ' '; | ||
295 | } | ||
296 | tchar ch = parent->getch(); | ||
297 | if (ch == 10) | ||
298 | { | ||
299 | indent = amnt; | ||
300 | } | ||
301 | return ch; | ||
302 | } | ||
303 | #else | ||
304 | virtual int getch() | ||
305 | { | 184 | { |
@@ -308,5 +187,7 @@ public: | |||
308 | indent--; | 187 | indent--; |
309 | return ' '; | 188 | ch = ' '; |
189 | sty = lsty; | ||
190 | return; | ||
310 | } | 191 | } |
311 | int ch = parent->getch(); | 192 | parent->getch(ch, sty); |
312 | if (ch == 10) | 193 | if (ch == 10) |
@@ -314,6 +195,6 @@ public: | |||
314 | indent = amnt; | 195 | indent = amnt; |
196 | lsty = sty; | ||
315 | } | 197 | } |
316 | return ch; | 198 | return; |
317 | } | 199 | } |
318 | #endif | ||
319 | }; | 200 | }; |
@@ -323,2 +204,3 @@ class dblspce : public CFilter | |||
323 | bool lastlf; | 204 | bool lastlf; |
205 | CStyle lsty; | ||
324 | public: | 206 | public: |
@@ -326,4 +208,3 @@ public: | |||
326 | virtual ~dblspce() {} | 208 | virtual ~dblspce() {} |
327 | #ifdef _UNICODE | 209 | virtual void getch(tchar& ch, CStyle& sty) |
328 | virtual tchar getch() | ||
329 | { | 210 | { |
@@ -332,23 +213,57 @@ public: | |||
332 | lastlf = false; | 213 | lastlf = false; |
333 | return 10; | 214 | ch = 10; |
215 | sty = lsty; | ||
216 | return; | ||
217 | } | ||
218 | parent->getch(ch, sty); | ||
219 | if (lastlf = (ch == 10)) | ||
220 | { | ||
221 | lsty = sty; | ||
334 | } | 222 | } |
335 | tchar ch = parent->getch(); | 223 | return; |
336 | lastlf = (ch == 10); | ||
337 | return ch; | ||
338 | } | 224 | } |
339 | #else | 225 | }; |
340 | virtual int getch() | 226 | |
227 | class textfmt : public CFilter | ||
341 | { | 228 | { |
342 | if (lastlf) | 229 | CStyle currentstyle; |
230 | tchar lastchar; | ||
231 | bool uselast; | ||
232 | void mygetch(tchar&, CStyle&); | ||
233 | public: | ||
234 | textfmt() : lastchar(0), uselast(false) {} | ||
235 | virtual ~textfmt() {} | ||
236 | virtual void getch(tchar& ch, CStyle& sty); | ||
237 | }; | ||
238 | |||
239 | class embolden : public CFilter | ||
343 | { | 240 | { |
344 | lastlf = false; | 241 | public: |
345 | return 10; | 242 | embolden() {} |
346 | } | 243 | virtual ~embolden() {} |
347 | int ch = parent->getch(); | 244 | virtual void getch(tchar& ch, CStyle& sty) |
348 | lastlf = (ch == 10); | 245 | { |
349 | return ch; | 246 | parent->getch(ch, sty); |
247 | sty.setBold(); | ||
350 | } | 248 | } |
351 | #endif | ||
352 | }; | 249 | }; |
353 | 250 | ||
251 | class remap : public CFilter | ||
252 | { | ||
253 | tchar q[3]; | ||
254 | int offset; | ||
255 | CStyle currentstyle; | ||
256 | public: | ||
257 | remap() : offset(0) { q[0] = 0; } | ||
258 | virtual ~remap() {} | ||
259 | virtual void getch(tchar& ch, CStyle& sty); | ||
260 | }; | ||
261 | |||
262 | class PeanutFormatter : public CFilter | ||
263 | { | ||
264 | CStyle currentstyle; | ||
265 | public: | ||
266 | virtual ~PeanutFormatter() {} | ||
267 | virtual void getch(tchar& ch, CStyle& sty); | ||
268 | }; | ||
354 | #endif | 269 | #endif |