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