summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CFilter.h
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CFilter.h273
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:
-class vanilla : public CFilter
-{
-public:
- vanilla() {}
- virtual ~vanilla() {}
-#ifdef _UNICODE
- virtual tchar getch()
-#else
- virtual int getch()
-#endif
- {
- return parent->getch();
- }
-};
-
class CFilterChain
@@ -51,3 +36,6 @@ class CFilterChain
}
- int getch() { return front->getch(); }
+ void getch(tchar& ch, CStyle& sty)
+ {
+ front->getch(ch, sty);
+ }
void addfilter(CFilter* p)
@@ -84,25 +72,10 @@ public:
virtual ~stripcr() {}
-#ifdef _UNICODE
- virtual tchar getch()
- {
- tchar ch;
- do
- {
- ch = parent->getch();
- }
- while (ch == 13);
- return ch;
- }
-#else
- virtual int getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
- int ch;
do
{
- ch = parent->getch();
+ parent->getch(ch, sty);
}
while (ch == 13);
- return ch;
}
-#endif
};
@@ -113,2 +86,3 @@ class dehyphen : public CFilter
tchar m_nextChar;
+ CStyle m_nextSty;
public:
@@ -116,3 +90,3 @@ class dehyphen : public CFilter
virtual ~dehyphen() {}
- virtual tchar getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
@@ -121,7 +95,9 @@ class dehyphen : public CFilter
m_bCharWaiting = false;
- return m_nextChar;
+ ch = m_nextChar;
+ sty = m_nextSty;
+ return;
}
- tchar ch = parent->getch();
- if (ch != '-') return ch;
- m_nextChar = parent->getch();
+ parent->getch(ch, sty);
+ if (ch != '-') return;
+ parent->getch(m_nextChar, m_nextSty);
if (m_nextChar != 10)
@@ -129,5 +105,6 @@ class dehyphen : public CFilter
m_bCharWaiting = true;
- return '-';
+ ch = '-';
+ return;
}
- return parent->getch();
+ parent->getch(ch, sty);
}
@@ -137,2 +114,7 @@ class striphtml : public CFilter
{
+ CStyle currentstyle;
+ unsigned short skip_ws();
+ unsigned short skip_ws_end();
+ unsigned short parse_m();
+ void mygetch(tchar& ch, CStyle& sty);
public:
@@ -140,53 +122,3 @@ public:
virtual ~striphtml() {}
-#ifdef _UNICODE
- virtual tchar getch()
- {
- tchar ch;
- ch = parent->getch();
- while (ch == '<')
- {
- while (ch != '>')
- {
- ch = parent->getch();
- }
- ch = parent->getch();
- }
- if (ch == '&')
- {
- ch = parent->getch();
- if (ch == '#')
- {
- int id = 0;
- while ((ch = parent->getch()) != ';') id = 10*id+ch-'0';
- ch = id;
- }
- }
- return ch;
- }
-#else
- virtual int getch()
- {
- int ch;
- ch = parent->getch();
- while (ch == '<')
- {
- while (ch != '>')
- {
- ch = parent->getch();
- }
- ch = parent->getch();
- }
- if (ch == '&')
- {
- ch = parent->getch();
- if (ch == '#')
- {
- int id = 0;
- while ((ch = parent->getch()) != ';') id = 10*id+ch-'0';
- ch = id;
- }
- }
- return ch;
- }
-#endif
+ virtual void getch(tchar& ch, CStyle& sty);
};
@@ -199,30 +131,18 @@ public:
virtual ~unindent() {}
-#ifdef _UNICODE
- virtual tchar getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
- tchar ch;
if (lc == 10)
{
- while ((ch = parent->getch()) == ' ');
- }
- else ch = parent->getch();
- lc = ch;
- return ch;
- }
-#else
- virtual int getch()
- {
- int ch;
- if (lc == 10)
+ do
{
- while ((ch = parent->getch()) == ' ');
+ parent->getch(ch, sty);
+ }
+ while (ch == ' ');
}
- else ch = parent->getch();
+ else parent->getch(ch, sty);
lc = ch;
- return ch;
+ return;
}
-#endif
};
-#ifdef _UNICODE
class repara : public CFilter
@@ -233,31 +153,5 @@ public:
virtual ~repara() {}
- virtual tchar getch()
- {
- tchar ch = parent->getch();
- if (ch == 10)
- {
- if (tch == 10)
- {
- return ch;
- }
- else
- {
- tch = ch;
- return ' ';
- }
- }
- tch = ch;
- return ch;
- }
-};
-#else
-class repara : public CFilter
-{
- int tch;
-public:
- repara() : tch(0) {}
- virtual ~repara() {}
- virtual int getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
- int ch = parent->getch();
+ parent->getch(ch, sty);
if (ch == 10)
@@ -266,3 +160,3 @@ public:
{
- return ch;
+ return;
}
@@ -271,3 +165,4 @@ public:
tch = ch;
- return ' ';
+ ch = ' ';
+ return;
}
@@ -275,6 +170,5 @@ public:
tch = ch;
- return ch;
+ return;
}
};
-#endif
@@ -284,2 +178,3 @@ class indenter : public CFilter
int indent;
+ CStyle lsty;
public:
@@ -287,19 +182,3 @@ public:
virtual ~indenter() {}
-#ifdef _UNICODE
- virtual tchar getch()
- {
- if (indent > 0)
- {
- indent--;
- return ' ';
- }
- tchar ch = parent->getch();
- if (ch == 10)
- {
- indent = amnt;
- }
- return ch;
- }
-#else
- virtual int getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
@@ -308,5 +187,7 @@ public:
indent--;
- return ' ';
+ ch = ' ';
+ sty = lsty;
+ return;
}
- int ch = parent->getch();
+ parent->getch(ch, sty);
if (ch == 10)
@@ -314,6 +195,6 @@ public:
indent = amnt;
+ lsty = sty;
}
- return ch;
+ return;
}
-#endif
};
@@ -323,2 +204,3 @@ class dblspce : public CFilter
bool lastlf;
+ CStyle lsty;
public:
@@ -326,4 +208,3 @@ public:
virtual ~dblspce() {}
-#ifdef _UNICODE
- virtual tchar getch()
+ virtual void getch(tchar& ch, CStyle& sty)
{
@@ -332,23 +213,57 @@ public:
lastlf = false;
- return 10;
+ ch = 10;
+ sty = lsty;
+ return;
+ }
+ parent->getch(ch, sty);
+ if (lastlf = (ch == 10))
+ {
+ lsty = sty;
}
- tchar ch = parent->getch();
- lastlf = (ch == 10);
- return ch;
+ return;
}
-#else
- virtual int getch()
+};
+
+class textfmt : public CFilter
{
- if (lastlf)
+ CStyle currentstyle;
+ tchar lastchar;
+ bool uselast;
+ void mygetch(tchar&, CStyle&);
+ public:
+ textfmt() : lastchar(0), uselast(false) {}
+ virtual ~textfmt() {}
+ virtual void getch(tchar& ch, CStyle& sty);
+};
+
+class embolden : public CFilter
{
- lastlf = false;
- return 10;
- }
- int ch = parent->getch();
- lastlf = (ch == 10);
- return ch;
+ public:
+ embolden() {}
+ virtual ~embolden() {}
+ virtual void getch(tchar& ch, CStyle& sty)
+ {
+ parent->getch(ch, sty);
+ sty.setBold();
}
-#endif
};
+class remap : public CFilter
+{
+ tchar q[3];
+ int offset;
+ CStyle currentstyle;
+ public:
+ remap() : offset(0) { q[0] = 0; }
+ virtual ~remap() {}
+ virtual void getch(tchar& ch, CStyle& sty);
+};
+
+class PeanutFormatter : public CFilter
+{
+ CStyle currentstyle;
+ public:
+ virtual ~PeanutFormatter() {}
+ virtual void getch(tchar& ch, CStyle& sty);
+};
#endif