summaryrefslogtreecommitdiff
authorpohly <pohly>2004-10-01 08:17:11 (UTC)
committer pohly <pohly>2004-10-01 08:17:11 (UTC)
commit63d9478584fd80902dcef17244e4415f096d76db (patch) (unidiff)
tree32d084308d0dca463a0b5205acfd10b91a10a54b
parent83d2361ccae308696694ab65f69ba8aa999f6696 (diff)
downloadopie-63d9478584fd80902dcef17244e4415f096d76db.zip
opie-63d9478584fd80902dcef17244e4415f096d76db.tar.gz
opie-63d9478584fd80902dcef17244e4415f096d76db.tar.bz2
fixed searching for input filters, following Tim's suggestion
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp
index 6d94d70..ab98829 100644
--- a/noncore/apps/opie-reader/CFilter.cpp
+++ b/noncore/apps/opie-reader/CFilter.cpp
@@ -1,814 +1,815 @@
1#include <qmap.h> 1#include <qmap.h>
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qdir.h> 4#include <qdir.h>
5#ifdef USEQPE 5#ifdef USEQPE
6#include <qpe/global.h> 6#include <qpe/global.h>
7#endif 7#endif
8#include "CDrawBuffer.h" 8#include "CDrawBuffer.h"
9#include "CFilter.h" 9#include "CFilter.h"
10#include "hrule.h" 10#include "hrule.h"
11#include "util.h" 11#include "util.h"
12 12
13#include <qregexp.h> 13#include <qregexp.h>
14#include <qimage.h> 14#include <qimage.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16//#include <qprogressdialog.h> 16//#include <qprogressdialog.h>
17//#include <qapplication.h> 17//#include <qapplication.h>
18 18
19void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) 19void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos)
20{ 20{
21 if (uselast) 21 if (uselast)
22 { 22 {
23 ch = lastchar; 23 ch = lastchar;
24 uselast = false; 24 uselast = false;
25 } 25 }
26 else 26 else
27 { 27 {
28 parent->getch(ch, sty, pos); 28 parent->getch(ch, sty, pos);
29 } 29 }
30} 30}
31 31
32void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) 32void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos)
33{ 33{
34 mygetch(ch, sty, pos); 34 mygetch(ch, sty, pos);
35 do 35 do
36 { 36 {
37 sty = currentstyle; 37 sty = currentstyle;
38 switch (ch) 38 switch (ch)
39 { 39 {
40 case 10: 40 case 10:
41 currentstyle.unset(); 41 currentstyle.unset();
42 sty = currentstyle; 42 sty = currentstyle;
43 break; 43 break;
44// Use this if you want to replace -- by em-dash 44// Use this if you want to replace -- by em-dash
45 case '-': 45 case '-':
46 // parent->getch(ch, sty); 46 // parent->getch(ch, sty);
47 mygetch(ch, sty, pos); 47 mygetch(ch, sty, pos);
48 if (ch == '-') 48 if (ch == '-')
49 { 49 {
50 ch = 0x2014; 50 ch = 0x2014;
51 } 51 }
52 else 52 else
53 { 53 {
54 lastchar = ch; 54 lastchar = ch;
55 uselast = true; 55 uselast = true;
56 ch = '-'; 56 ch = '-';
57 } 57 }
58 break; 58 break;
59 case '*': 59 case '*':
60 if (currentstyle.isBold()) 60 if (currentstyle.isBold())
61 { 61 {
62// Already bold - time to turn it off? 62// Already bold - time to turn it off?
63// The next two lines ensure that * follows a character but it works better without 63// The next two lines ensure that * follows a character but it works better without
64 // QChar c(lastchar); 64 // QChar c(lastchar);
65 // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) 65 // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber()))
66 if (lastchar != '*') 66 if (lastchar != '*')
67 { 67 {
68 currentstyle.unsetBold(); 68 currentstyle.unsetBold();
69 CStyle dummy; 69 CStyle dummy;
70 // parent->getch(ch, dummy); 70 // parent->getch(ch, dummy);
71 mygetch(ch, dummy, pos); 71 mygetch(ch, dummy, pos);
72 } 72 }
73 } 73 }
74 else 74 else
75 { 75 {
76// not bold - time to turn it on? 76// not bold - time to turn it on?
77 CStyle dummy; 77 CStyle dummy;
78 // parent->getch(ch, dummy); 78 // parent->getch(ch, dummy);
79 mygetch(ch, dummy, pos); 79 mygetch(ch, dummy, pos);
80 QChar c(ch); 80 QChar c(ch);
81 if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) 81 if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber()))
82 { 82 {
83 currentstyle.setBold(); 83 currentstyle.setBold();
84 } 84 }
85 else 85 else
86 { 86 {
87 lastchar = ch; 87 lastchar = ch;
88 uselast = true; 88 uselast = true;
89 ch = '*'; 89 ch = '*';
90 } 90 }
91 91
92 } 92 }
93 break; 93 break;
94 case '_': 94 case '_':
95 if (currentstyle.isItalic()) 95 if (currentstyle.isItalic())
96 { 96 {
97// Already bold - time to turn it off? 97// Already bold - time to turn it off?
98// The next two lines ensure that * follows a character but it works better without 98// The next two lines ensure that * follows a character but it works better without
99 // QChar c(lastchar); 99 // QChar c(lastchar);
100 // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) 100 // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber()))
101 if (lastchar != '_') 101 if (lastchar != '_')
102 { 102 {
103 currentstyle.unsetItalic(); 103 currentstyle.unsetItalic();
104 CStyle dummy; 104 CStyle dummy;
105 // parent->getch(ch, dummy); 105 // parent->getch(ch, dummy);
106 mygetch(ch, dummy, pos); 106 mygetch(ch, dummy, pos);
107 } 107 }
108 } 108 }
109 else 109 else
110 { 110 {
111// not bold - time to turn it on? 111// not bold - time to turn it on?
112 CStyle dummy; 112 CStyle dummy;
113 // parent->getch(ch, dummy); 113 // parent->getch(ch, dummy);
114 mygetch(ch, dummy, pos); 114 mygetch(ch, dummy, pos);
115 QChar c(ch); 115 QChar c(ch);
116 if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) 116 if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber()))
117 { 117 {
118 currentstyle.setItalic(); 118 currentstyle.setItalic();
119 } 119 }
120 else 120 else
121 { 121 {
122 lastchar = ch; 122 lastchar = ch;
123 uselast = true; 123 uselast = true;
124 ch = '_'; 124 ch = '_';
125 } 125 }
126 126
127 } 127 }
128 break; 128 break;
129 } 129 }
130 } 130 }
131 while (sty != currentstyle); 131 while (sty != currentstyle);
132 if (!uselast) lastchar = ch; 132 if (!uselast) lastchar = ch;
133 return; 133 return;
134} 134}
135 135
136void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) 136void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos)
137{ 137{
138 if (q[offset] != 0) 138 if (q[offset] != 0)
139 { 139 {
140 q[offset++]; 140 q[offset++];
141 sty = currentstyle; 141 sty = currentstyle;
142 return; 142 return;
143 } 143 }
144 parent->getch(ch, sty, pos); 144 parent->getch(ch, sty, pos);
145 switch (ch) 145 switch (ch)
146 { 146 {
147 case 0x201a: 147 case 0x201a:
148 ch = '\''; 148 ch = '\'';
149 break; 149 break;
150 case 0x0192: 150 case 0x0192:
151 ch = 'f'; 151 ch = 'f';
152 break; 152 break;
153 case 0x201e: 153 case 0x201e:
154 ch = '"'; 154 ch = '"';
155 break; 155 break;
156 case 0x2026: 156 case 0x2026:
157 offset = 0; 157 offset = 0;
158 q[0] = '.'; 158 q[0] = '.';
159 q[1] = '.'; 159 q[1] = '.';
160 q[2] = 0; 160 q[2] = 0;
161 ch = '.'; // should be ... 161 ch = '.'; // should be ...
162 break; 162 break;
163 case 0x0160: 163 case 0x0160:
164 ch = 'S'; 164 ch = 'S';
165 break; 165 break;
166 case 0x2039: 166 case 0x2039:
167 ch = '<'; 167 ch = '<';
168 break; 168 break;
169 case 0x0152: 169 case 0x0152:
170 offset = 0; 170 offset = 0;
171 q[0] = 'E'; 171 q[0] = 'E';
172 q[1] = 0; 172 q[1] = 0;
173 ch = 'O'; 173 ch = 'O';
174 break; 174 break;
175 case 0x017d: 175 case 0x017d:
176 ch = 'Z'; 176 ch = 'Z';
177 break; 177 break;
178 case 0x2018: 178 case 0x2018:
179 ch = '\''; 179 ch = '\'';
180 break; 180 break;
181 case 0x2019: 181 case 0x2019:
182 ch = '\''; 182 ch = '\'';
183 break; 183 break;
184 case 0x201c: 184 case 0x201c:
185 ch = '"'; 185 ch = '"';
186 break; 186 break;
187 case 0x201d: 187 case 0x201d:
188 ch = '"'; 188 ch = '"';
189 break; 189 break;
190 case 0x2022: 190 case 0x2022:
191 ch = '>'; 191 ch = '>';
192 break; 192 break;
193 case 0x2013: 193 case 0x2013:
194 ch = '-'; 194 ch = '-';
195 break; 195 break;
196 case 0x2014: 196 case 0x2014:
197 offset = 0; 197 offset = 0;
198 q[0] = '-'; 198 q[0] = '-';
199 q[1] = 0; 199 q[1] = 0;
200 ch = '-'; // should be -- 200 ch = '-'; // should be --
201 break; 201 break;
202 case 0x02dc: 202 case 0x02dc:
203 ch = '~'; 203 ch = '~';
204 break; 204 break;
205 case 0x0161: 205 case 0x0161:
206 ch = 's'; 206 ch = 's';
207 break; 207 break;
208 case 0x203a: 208 case 0x203a:
209 ch = '>'; 209 ch = '>';
210 break; 210 break;
211 case 0x0153: 211 case 0x0153:
212 offset = 0; 212 offset = 0;
213 q[0] = 'e'; 213 q[0] = 'e';
214 q[1] = 0; 214 q[1] = 0;
215 ch = 'o';// should be oe 215 ch = 'o';// should be oe
216 break; 216 break;
217 /* 217 /*
218 case 0x0009: // tab 218 case 0x0009: // tab
219 offset = 0; 219 offset = 0;
220 q[0] = ' '; 220 q[0] = ' ';
221 q[1] = 0; 221 q[1] = 0;
222 ch = ' '; 222 ch = ' ';
223 break; 223 break;
224 */ 224 */
225 case 0x017e: 225 case 0x017e:
226 ch = 'z'; 226 ch = 'z';
227 break; 227 break;
228 case 0x0178: 228 case 0x0178:
229 ch = 'Y'; 229 ch = 'Y';
230 break; 230 break;
231 } 231 }
232 currentstyle = sty; 232 currentstyle = sty;
233} 233}
234 234
235void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) 235void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos)
236{ 236{
237 CStyle dummy; 237 CStyle dummy;
238 currentstyle.setColour(0,0,0); 238 currentstyle.setColour(0,0,0);
239 parent->getch(ch, dummy, pos); 239 parent->getch(ch, dummy, pos);
240 while (ch == '\\') 240 while (ch == '\\')
241 { 241 {
242 parent->getch(ch, dummy, pos); 242 parent->getch(ch, dummy, pos);
243 if (ch == '\\') break; 243 if (ch == '\\') break;
244 switch(ch) 244 switch(ch)
245 { 245 {
246 case 'a': 246 case 'a':
247 { 247 {
248 int code = 0; 248 int code = 0;
249 for (int i = 0; i < 3; i++) 249 for (int i = 0; i < 3; i++)
250 { 250 {
251 parent->getch(ch, dummy, pos); 251 parent->getch(ch, dummy, pos);
252 code = 10*code + ch - '0'; 252 code = 10*code + ch - '0';
253 } 253 }
254 ch = code; 254 ch = code;
255 } 255 }
256 break; 256 break;
257 case 'v': 257 case 'v':
258 { 258 {
259 while (1) 259 while (1)
260 { 260 {
261 parent->getch(ch, dummy, pos); 261 parent->getch(ch, dummy, pos);
262 if (ch == '\\') 262 if (ch == '\\')
263 { 263 {
264 parent->getch(ch, dummy, pos); 264 parent->getch(ch, dummy, pos);
265 if (ch == 'v') 265 if (ch == 'v')
266 { 266 {
267 parent->getch(ch, dummy, pos); 267 parent->getch(ch, dummy, pos);
268 break; 268 break;
269 } 269 }
270 } 270 }
271 } 271 }
272 } 272 }
273 break; 273 break;
274 case 's': 274 case 's':
275 case 'n': 275 case 'n':
276 currentstyle.setFontSize(0); 276 currentstyle.setFontSize(0);
277 parent->getch(ch,dummy, pos); 277 parent->getch(ch,dummy, pos);
278 break; 278 break;
279 case 'p': 279 case 'p':
280 currentstyle.unset(); 280 currentstyle.unset();
281 // parent->getch(ch,dummy); 281 // parent->getch(ch,dummy);
282 ch = 10; 282 ch = 10;
283 break; 283 break;
284 case 'l': 284 case 'l':
285 if (currentstyle.getFontSize() == 1) 285 if (currentstyle.getFontSize() == 1)
286 { 286 {
287 currentstyle.setFontSize(0); 287 currentstyle.setFontSize(0);
288 } 288 }
289 else 289 else
290 { 290 {
291 currentstyle.setFontSize(1); 291 currentstyle.setFontSize(1);
292 } 292 }
293 parent->getch(ch, dummy, pos); 293 parent->getch(ch, dummy, pos);
294 break; 294 break;
295 case 'x': 295 case 'x':
296 if (currentstyle.getFontSize() == 0) 296 if (currentstyle.getFontSize() == 0)
297 { 297 {
298 // currentstyle.unset(); 298 // currentstyle.unset();
299 // currentstyle.setBold(); 299 // currentstyle.setBold();
300 currentstyle.setFontSize(1); 300 currentstyle.setFontSize(1);
301 } 301 }
302 else 302 else
303 { 303 {
304 currentstyle.unset(); 304 currentstyle.unset();
305 } 305 }
306 // parent->getch(ch, dummy); 306 // parent->getch(ch, dummy);
307 ch = 10; 307 ch = 10;
308 break; 308 break;
309 case 'i': 309 case 'i':
310 if (currentstyle.isItalic()) 310 if (currentstyle.isItalic())
311 { 311 {
312 currentstyle.unsetItalic(); 312 currentstyle.unsetItalic();
313 } 313 }
314 else 314 else
315 { 315 {
316 currentstyle.setItalic(); 316 currentstyle.setItalic();
317 } 317 }
318 parent->getch(ch, dummy, pos); 318 parent->getch(ch, dummy, pos);
319 break; 319 break;
320 case 'b': 320 case 'b':
321 case 'B': 321 case 'B':
322 if (currentstyle.isBold()) 322 if (currentstyle.isBold())
323 { 323 {
324 currentstyle.unsetBold(); 324 currentstyle.unsetBold();
325 } 325 }
326 else 326 else
327 { 327 {
328 currentstyle.setBold(); 328 currentstyle.setBold();
329 } 329 }
330 parent->getch(ch, dummy, pos); 330 parent->getch(ch, dummy, pos);
331 break; 331 break;
332 case 'c': 332 case 'c':
333 if (currentstyle.getJustify() == m_AlignCentre) 333 if (currentstyle.getJustify() == m_AlignCentre)
334 { 334 {
335 currentstyle.setLeftJustify(); 335 currentstyle.setLeftJustify();
336 } 336 }
337 else 337 else
338 { 338 {
339 currentstyle.setCentreJustify(); 339 currentstyle.setCentreJustify();
340 } 340 }
341 parent->getch(ch, dummy, pos); 341 parent->getch(ch, dummy, pos);
342 break; 342 break;
343 case 'r': 343 case 'r':
344 if (currentstyle.getJustify() == m_AlignRight) 344 if (currentstyle.getJustify() == m_AlignRight)
345 { 345 {
346 currentstyle.setLeftJustify(); 346 currentstyle.setLeftJustify();
347 } 347 }
348 else 348 else
349 { 349 {
350 currentstyle.setRightJustify(); 350 currentstyle.setRightJustify();
351 } 351 }
352 parent->getch(ch, dummy, pos); 352 parent->getch(ch, dummy, pos);
353 break; 353 break;
354 default: 354 default:
355 currentstyle.setColour(255,0,0); 355 currentstyle.setColour(255,0,0);
356 } 356 }
357 } 357 }
358 sty = currentstyle; 358 sty = currentstyle;
359} 359}
360 360
361void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) 361void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
362{ 362{
363 parent->getch(ch, sty, pos); 363 parent->getch(ch, sty, pos);
364 if (m_lastchar == 10) 364 if (m_lastchar == 10)
365 { 365 {
366 while (ch == 10) parent->getch(ch, sty, pos); 366 while (ch == 10) parent->getch(ch, sty, pos);
367 } 367 }
368 m_lastchar = ch; 368 m_lastchar = ch;
369} 369}
370 370
371void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) 371void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos)
372{ 372{
373 parent->getch(ch, sty, pos); 373 parent->getch(ch, sty, pos);
374 switch (ch) 374 switch (ch)
375 { 375 {
376 case 0x80: 376 case 0x80:
377 ch = 0x20ac; 377 ch = 0x20ac;
378 break; 378 break;
379 case 0x82: 379 case 0x82:
380 ch = 0x201a; 380 ch = 0x201a;
381 break; 381 break;
382 case 0x83: 382 case 0x83:
383 ch = 0x0192; 383 ch = 0x0192;
384 break; 384 break;
385 case 0x84: 385 case 0x84:
386 ch = 0x201e; 386 ch = 0x201e;
387 break; 387 break;
388 case 0x85: 388 case 0x85:
389 ch = 0x2026; 389 ch = 0x2026;
390 break; 390 break;
391 case 0x86: 391 case 0x86:
392 ch = 0x2020; 392 ch = 0x2020;
393 break; 393 break;
394 case 0x87: 394 case 0x87:
395 ch = 0x2021; 395 ch = 0x2021;
396 break; 396 break;
397 case 0x88: 397 case 0x88:
398 ch = 0x02c6; 398 ch = 0x02c6;
399 break; 399 break;
400 case 0x89: 400 case 0x89:
401 ch = 0x2030; 401 ch = 0x2030;
402 break; 402 break;
403 case 0x8a: 403 case 0x8a:
404 ch = 0x0160; 404 ch = 0x0160;
405 break; 405 break;
406 case 0x8b: 406 case 0x8b:
407 ch = 0x2039; 407 ch = 0x2039;
408 break; 408 break;
409 case 0x8c: 409 case 0x8c:
410 ch = 0x0152; 410 ch = 0x0152;
411 break; 411 break;
412/* 412/*
413 case 0x8e: 413 case 0x8e:
414 ch = 0x017d; 414 ch = 0x017d;
415 break; 415 break;
416*/ 416*/
417 case 0x91: 417 case 0x91:
418 ch = 0x2018; 418 ch = 0x2018;
419 break; 419 break;
420 case 0x92: 420 case 0x92:
421 ch = 0x2019; 421 ch = 0x2019;
422 break; 422 break;
423 case 0x93: 423 case 0x93:
424 ch = 0x201c; 424 ch = 0x201c;
425 break; 425 break;
426 case 0x94: 426 case 0x94:
427 ch = 0x201d; 427 ch = 0x201d;
428 break; 428 break;
429 case 0x95: 429 case 0x95:
430 ch = 0x2022; 430 ch = 0x2022;
431 break; 431 break;
432 case 0x96: 432 case 0x96:
433 ch = 0x2013; 433 ch = 0x2013;
434 break; 434 break;
435 case 0x97: 435 case 0x97:
436 ch = 0x2014; 436 ch = 0x2014;
437 break; 437 break;
438 case 0x98: 438 case 0x98:
439 ch = 0x02dc; 439 ch = 0x02dc;
440 break; 440 break;
441 case 0x99: 441 case 0x99:
442 ch = 0x2122; 442 ch = 0x2122;
443 break; 443 break;
444 case 0x9a: 444 case 0x9a:
445 ch = 0x0161; 445 ch = 0x0161;
446 break; 446 break;
447 case 0x9b: 447 case 0x9b:
448 ch = 0x203a; 448 ch = 0x203a;
449 break; 449 break;
450 case 0x9c: 450 case 0x9c:
451 ch = 0x0153; 451 ch = 0x0153;
452 break; 452 break;
453 case 0x9e: 453 case 0x9e:
454 ch = 0x017e; 454 ch = 0x017e;
455 break; 455 break;
456 case 0x9f: 456 case 0x9f:
457 ch = 0x0178; 457 ch = 0x0178;
458 break; 458 break;
459 case 0x18: 459 case 0x18:
460 ch = 0x2026; 460 ch = 0x2026;
461 break; 461 break;
462 case 0x19: 462 case 0x19:
463 ch = 0x2007; 463 ch = 0x2007;
464 break; 464 break;
465 case 0x8d: 465 case 0x8d:
466 ch = 0x2662; 466 ch = 0x2662;
467 break; 467 break;
468 case 0x8e: 468 case 0x8e:
469 ch = 0x2663; 469 ch = 0x2663;
470 break; 470 break;
471 case 0x8f: 471 case 0x8f:
472 ch = 0x2661; 472 ch = 0x2661;
473 break; 473 break;
474 case 0x90: 474 case 0x90:
475 ch = 0x2660; 475 ch = 0x2660;
476 break; 476 break;
477 default: 477 default:
478 break; 478 break;
479 } 479 }
480} 480}
481 481
482//static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; 482//static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 };
483//static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; 483//static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 };
484 484
485void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) 485void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos)
486{ 486{
487 if (m_buffed > 0) 487 if (m_buffed > 0)
488 { 488 {
489 sty = m_laststyle; 489 sty = m_laststyle;
490 ch = nextpart[m_current++]; 490 ch = nextpart[m_current++];
491 if (m_current == m_buffed) 491 if (m_current == m_buffed)
492 { 492 {
493 m_current = m_buffed = 0; 493 m_current = m_buffed = 0;
494 } 494 }
495 } 495 }
496 else 496 else
497 { 497 {
498 if (m_buffer != 0) 498 if (m_buffer != 0)
499 { 499 {
500 ch = m_buffer; 500 ch = m_buffer;
501 m_buffer = 0; 501 m_buffer = 0;
502 return; 502 return;
503 } 503 }
504 unsigned long lnk, lnkoff; 504 unsigned long lnk, lnkoff;
505 do 505 do
506 { 506 {
507 if (nextpart[m_buffed] == 0) break; 507 if (nextpart[m_buffed] == 0) break;
508 parent->getch(ch, sty, pos); 508 parent->getch(ch, sty, pos);
509 m_laststyle = sty; 509 m_laststyle = sty;
510 if (sty.getLink()) 510 if (sty.getLink())
511 { 511 {
512 lnk = sty.getData(); 512 lnk = sty.getData();
513 lnkoff = sty.getOffset(); 513 lnkoff = sty.getOffset();
514 } 514 }
515 } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); 515 } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed);
516 m_current = 0; 516 m_current = 0;
517 if (nextpart[m_buffed] == 0) 517 if (nextpart[m_buffed] == 0)
518 { 518 {
519 m_buffed = 0; 519 m_buffed = 0;
520 QString dmy, dmy2; 520 QString dmy, dmy2;
521 parent->hyperlink(lnk, lnkoff, dmy, dmy2); 521 parent->hyperlink(lnk, lnkoff, dmy, dmy2);
522 do 522 do
523 { 523 {
524 parent->getch(ch, sty, pos); 524 parent->getch(ch, sty, pos);
525 } 525 }
526 while (ch != 10); 526 while (ch != 10);
527 parent->getch(ch, sty, pos); 527 parent->getch(ch, sty, pos);
528 } 528 }
529 else if (m_buffed > 0) 529 else if (m_buffed > 0)
530 { 530 {
531 m_buffer = ch; 531 m_buffer = ch;
532 ch = nextpart[0]; 532 ch = nextpart[0];
533 if (m_buffed == 1) 533 if (m_buffed == 1)
534 { 534 {
535 m_buffed = 0; 535 m_buffed = 0;
536 } 536 }
537 else m_current = 1; 537 else m_current = 1;
538 } 538 }
539 } 539 }
540 540
541 return; 541 return;
542} 542}
543 543
544HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) 544HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255)
545{ 545{
546} 546}
547 547
548#include "Bkmks.h" 548#include "Bkmks.h"
549#include "QTReader.h" 549#include "QTReader.h"
550 550
551void HighlightFilter::refresh(unsigned long pos) 551void HighlightFilter::refresh(unsigned long pos)
552{ 552{
553 bkmks = pReader->Bkmklist(); 553 bkmks = pReader->Bkmklist();
554 554
555 red = green = blue = 255; 555 red = green = blue = 255;
556 556
557 if (bkmks == NULL) 557 if (bkmks == NULL)
558 { 558 {
559 lastpos = 0; 559 lastpos = 0;
560 nextpos = 0xffffffff; 560 nextpos = 0xffffffff;
561 } 561 }
562 else 562 else
563 { 563 {
564 lastpos = 0; 564 lastpos = 0;
565 nextpos = 0xffffffff; 565 nextpos = 0xffffffff;
566 for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) 566 for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++)
567 { 567 {
568 if ((*i).value() <= pos && pos < (*i).value2()) 568 if ((*i).value() <= pos && pos < (*i).value2())
569 { 569 {
570 red = i->red(); 570 red = i->red();
571 green = i->green(); 571 green = i->green();
572 blue = i->blue(); 572 blue = i->blue();
573 lastpos = (*i).value(); 573 lastpos = (*i).value();
574 nextpos = (*i).value2(); 574 nextpos = (*i).value2();
575 break; 575 break;
576 } 576 }
577 if ((*i).value() > pos) 577 if ((*i).value() > pos)
578 { 578 {
579 nextpos = (*i).value(); 579 nextpos = (*i).value();
580 break; 580 break;
581 } 581 }
582 lastpos = (*i).value(); 582 lastpos = (*i).value();
583 } 583 }
584 } 584 }
585} 585}
586 586
587void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) 587void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos)
588{ 588{
589 parent->getch(ch, sty, pos); 589 parent->getch(ch, sty, pos);
590 if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) 590 if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos)
591 { 591 {
592 // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); 592 // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos);
593 refresh(pos); 593 refresh(pos);
594 // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); 594 // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos);
595 } 595 }
596 int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); 596 int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue();
597 if (r == 255 && g == 255 && b == 255) 597 if (r == 255 && g == 255 && b == 255)
598 { 598 {
599 sty.setBackground(red, green, blue); 599 sty.setBackground(red, green, blue);
600 } 600 }
601} 601}
602 602
603void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) 603void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos)
604{ 604{
605 if (uselast) 605 if (uselast)
606 { 606 {
607 ch = lastchar; 607 ch = lastchar;
608 sty = laststy; 608 sty = laststy;
609 uselast = false; 609 uselast = false;
610 return; 610 return;
611 } 611 }
612 else 612 else
613 { 613 {
614 parent->getch(ch, sty, pos); 614 parent->getch(ch, sty, pos);
615 } 615 }
616 switch (ch) 616 switch (ch)
617 { 617 {
618 case 'f': 618 case 'f':
619 { 619 {
620 tchar savedchar = 'f'; 620 tchar savedchar = 'f';
621 parent->getch(ch, sty, pos); 621 parent->getch(ch, sty, pos);
622 switch (ch) 622 switch (ch)
623 { 623 {
624 case 'i': 624 case 'i':
625 ch = (251 << 8) + 1; 625 ch = (251 << 8) + 1;
626 break; 626 break;
627 case 'l': 627 case 'l':
628 ch = (251 << 8) + 2; 628 ch = (251 << 8) + 2;
629 break; 629 break;
630 default: 630 default:
631 lastchar = ch; 631 lastchar = ch;
632 uselast = true; 632 uselast = true;
633 laststy = sty; 633 laststy = sty;
634 ch = savedchar; 634 ch = savedchar;
635 } 635 }
636 } 636 }
637 break; 637 break;
638 default: 638 default:
639 break; 639 break;
640 } 640 }
641} 641}
642 642
643class ErrorFilter : public CFilter 643class ErrorFilter : public CFilter
644{ 644{
645 QString error; 645 QString error;
646 int currentpos; 646 int currentpos;
647 public: 647 public:
648 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} 648 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {}
649 ~ErrorFilter() {} 649 ~ErrorFilter() {}
650 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 650 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
651 { 651 {
652 if (currentpos == error.length()) 652 if (currentpos == error.length())
653 { 653 {
654 ch = UEOF; 654 ch = UEOF;
655 currentpos = 0; 655 currentpos = 0;
656 } 656 }
657 else 657 else
658 { 658 {
659 ch = error[currentpos++].unicode(); 659 ch = error[currentpos++].unicode();
660 } 660 }
661 } 661 }
662 QString about() { return parent->about(); } 662 QString about() { return parent->about(); }
663}; 663};
664 664
665#ifndef __STATIC 665#ifndef __STATIC
666ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) 666ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL)
667{ 667{
668 QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); 668 QString filterpath(QTReaderUtil::getPluginPath("filters"));
669 filterpath += "/lib";
669 filterpath += nm; 670 filterpath += nm;
670 filterpath += ".so"; 671 filterpath += ".so";
671 if (QFile::exists(filterpath)) 672 if (QFile::exists(filterpath))
672 { 673 {
673 qDebug("Filter:%s", (const char*)filterpath); 674 qDebug("Filter:%s", (const char*)filterpath);
674 handle = dlopen(filterpath, RTLD_LAZY); 675 handle = dlopen(filterpath, RTLD_LAZY);
675 if (handle == 0) 676 if (handle == 0)
676 { 677 {
677 qDebug("Can't find filter:%s", dlerror()); 678 qDebug("Can't find filter:%s", dlerror());
678 // status = -10; 679 // status = -10;
679 filt = new ErrorFilter(QString("Can't find plugin:")+nm); 680 filt = new ErrorFilter(QString("Can't find plugin:")+nm);
680 return; 681 return;
681 } 682 }
682 CFilter* (*newfilter)(const QString&); 683 CFilter* (*newfilter)(const QString&);
683 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); 684 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter");
684 if (newfilter == NULL) 685 if (newfilter == NULL)
685 { 686 {
686 qDebug("Can't find newfilter"); 687 qDebug("Can't find newfilter");
687 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); 688 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm);
688 return; 689 return;
689 } 690 }
690 filt = (*newfilter)(optional); 691 filt = (*newfilter)(optional);
691 } 692 }
692 else 693 else
693 { 694 {
694 qDebug("No filter path"); 695 qDebug("No filter path");
695 filt = new ErrorFilter(QString("No filter plugins installed:")+nm); 696 filt = new ErrorFilter(QString("No filter plugins installed:")+nm);
696 } 697 }
697 if (filt == NULL) 698 if (filt == NULL)
698 { 699 {
699 qDebug("Can't do newfilter"); 700 qDebug("Can't do newfilter");
700 filt = new ErrorFilter(QString("Filter creation failed:")+nm); 701 filt = new ErrorFilter(QString("Filter creation failed:")+nm);
701 return; 702 return;
702 } 703 }
703} 704}
704#endif 705#endif
705 706
706void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) 707void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos)
707{ 708{
708 parent->getch(ch, sty, pos); 709 parent->getch(ch, sty, pos);
709 int r,g,b; 710 int r,g,b;
710 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); 711 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue();
711 sty.setColour(r,g,b); 712 sty.setColour(r,g,b);
712 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); 713 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue();
713 sty.setBackground(r,g,b); 714 sty.setBackground(r,g,b);
714 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); 715 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue();
715 sty.setPaper(r,g,b); 716 sty.setPaper(r,g,b);
716} 717}
717/* 718/*
718void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) 719void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos)
719{ 720{
720 parent->getch(ch, sty, pos); 721 parent->getch(ch, sty, pos);
721 QColor fg(sty.Red(), sty.Green(), sty.Blue()); 722 QColor fg(sty.Red(), sty.Green(), sty.Blue());
722 int h,s,v; 723 int h,s,v;
723 fg.hsv(&h,&s,&v); 724 fg.hsv(&h,&s,&v);
724 fg.setHsv(h,s,255-v); 725 fg.setHsv(h,s,255-v);
725 int r,g,b; 726 int r,g,b;
726 fg.rgb(&r,&g,&b); 727 fg.rgb(&r,&g,&b);
727 sty.setColour(r,g,b); 728 sty.setColour(r,g,b);
728 729
729 fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); 730 fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue());
730 fg.hsv(&h,&s,&v); 731 fg.hsv(&h,&s,&v);
731 fg.setHsv(h,s,255-v); 732 fg.setHsv(h,s,255-v);
732 fg.rgb(&r,&g,&b); 733 fg.rgb(&r,&g,&b);
733 sty.setBackground(r,g,b); 734 sty.setBackground(r,g,b);
734} 735}
735*/ 736*/
736void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) 737void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos)
737{ 738{
738 parent->getch(ch, sty, pos); 739 parent->getch(ch, sty, pos);
739 int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); 740 int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue();
740 if (r == 255 && g == 255 && b == 255) 741 if (r == 255 && g == 255 && b == 255)
741 { 742 {
742 sty.setPaper(m_r,m_g,m_b); 743 sty.setPaper(m_r,m_g,m_b);
743 } 744 }
744 else 745 else
745 { 746 {
746 qDebug("We have background [%x%x%x]", r, g, b); 747 qDebug("We have background [%x%x%x]", r, g, b);
747 } 748 }
748 r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); 749 r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue();
749 if (r == 255 && g == 255 && b == 255) 750 if (r == 255 && g == 255 && b == 255)
750 { 751 {
751 sty.setBackground(m_r,m_g,m_b); 752 sty.setBackground(m_r,m_g,m_b);
752 } 753 }
753 else 754 else
754 { 755 {
755 qDebug("We have background [%x%x%x]", r, g, b); 756 qDebug("We have background [%x%x%x]", r, g, b);
756 } 757 }
757} 758}
758 759
759void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) 760void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos)
760{ 761{
761 parent->getch(ch, sty, pos); 762 parent->getch(ch, sty, pos);
762 int r = sty.Red(), g = sty.Green(), b = sty.Blue(); 763 int r = sty.Red(), g = sty.Green(), b = sty.Blue();
763 if (r == 0 && g == 0 && b == 0) 764 if (r == 0 && g == 0 && b == 0)
764 { 765 {
765 sty.setColour(m_r,m_g,m_b); 766 sty.setColour(m_r,m_g,m_b);
766 } 767 }
767} 768}
768 769
769#include "CRegExp.h" 770#include "CRegExp.h"
770 771
771repara::repara(const QString& pat) : tch(0) 772repara::repara(const QString& pat) : tch(0)
772{ 773{
773 // QString pat("{\\n[A-Z\"]}"); 774 // QString pat("{\\n[A-Z\"]}");
774 flt = new CRegExpFilt(pat, false); 775 flt = new CRegExpFilt(pat, false);
775 qDebug("Construction done"); 776 qDebug("Construction done");
776} 777}
777 778
778repara::~repara() 779repara::~repara()
779{ 780{
780 delete flt; 781 delete flt;
781} 782}
782 783
783void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) 784void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
784{ 785{
785 if (flt->empty()) 786 if (flt->empty())
786 { 787 {
787 while (flt->empty()) 788 while (flt->empty())
788 { 789 {
789 parent->getch(ch, sty, pos); 790 parent->getch(ch, sty, pos);
790 flt->addch(ch); 791 flt->addch(ch);
791 } 792 }
792 } 793 }
793 ch = flt->pop(); 794 ch = flt->pop();
794 /* 795 /*
795 parent->getch(ch, sty, pos); 796 parent->getch(ch, sty, pos);
796 if (ch == 10 || ch == ' ') 797 if (ch == 10 || ch == ' ')
797 { 798 {
798 if (tch == 10) 799 if (tch == 10)
799 { 800 {
800 tch = ch; 801 tch = ch;
801 ch = 10; 802 ch = 10;
802 return; 803 return;
803 } 804 }
804 else 805 else
805 { 806 {
806 tch = ch; 807 tch = ch;
807 ch = ' '; 808 ch = ' ';
808 return; 809 return;
809 } 810 }
810 } 811 }
811 tch = ch; 812 tch = ch;
812 */ 813 */
813 return; 814 return;
814} 815}