From 2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975 Mon Sep 17 00:00:00 2001 From: llornkcor Date: Sat, 14 Sep 2002 02:19:09 +0000 Subject: update by Tim --- (limited to 'noncore/apps/opie-reader/CExpander.h') diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 07c14fa..b1147a6 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h @@ -1,132 +1,19 @@ #ifndef __CExpander_h #define __CExpander_h -#include "my_list.h" #include "config.h" +#include "StyleConsts.h" +#include "Markups.h" -class Bkmk -{ - friend class BkmkFile; - tchar* m_name; - unsigned int m_position; - public: - Bkmk() : m_name(NULL), m_position(0) {}; - Bkmk(const tchar* _nm, unsigned int _p) : m_position(_p) - { - int len = ustrlen(_nm)+1; - m_name = new tchar[len]; - for (int i = 0; i < len; i++) m_name[i] = _nm[i]; - } - Bkmk(const Bkmk& rhs) : m_name(NULL) - { - *this = rhs; - } - ~Bkmk() { if (m_name != NULL) delete [] m_name; } - unsigned int value() const { return m_position; } - tchar *name() const { return m_name; } - bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } - Bkmk& operator=(const Bkmk& rhs) - { - if (m_name != NULL) delete [] m_name; - if (rhs.m_name != NULL) - { - int len = ustrlen(rhs.m_name)+1; - m_name = new tchar[len]; - for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; - } - else - m_name = NULL; - m_position = rhs.m_position; - return *this; - } - bool operator==(const Bkmk& rhs) - { - return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); - } -}; +class Bkmk; -class BkmkFile -{ - FILE* f; - bool wt; -public: - BkmkFile(const char *fnm, bool w = false) - : - wt(w) - { - if (w) - f = fopen(fnm, "wb"); - else - f = fopen(fnm, "rb"); - } - ~BkmkFile() - { - if (f != NULL) fclose(f); - } - void write(tchar* nm, const unsigned int& pos) - { - if (f != NULL) - { - unsigned short ln = ustrlen(nm); - fwrite(&ln,sizeof(ln),1,f); - fwrite(nm,sizeof(tchar),ln,f); - fwrite(&pos,sizeof(pos),1,f); - } - } - void write(const Bkmk& b) { write(b.name(), b.value()); } - void write(CList& bl) - { - if (f != NULL) - { - for (CList::iterator i = bl.begin(); i != bl.end(); i++) - { - write(*i); - } - } - } - Bkmk* read() - { - Bkmk* b = NULL; - if (f != NULL) - { - unsigned short ln; - if (fread(&ln,sizeof(ln),1,f) == 1) - { - b = new Bkmk; - b->m_name = new tchar[ln+1]; - fread(b->m_name,sizeof(tchar),ln,f); - b->m_name[ln] = 0; - fread(&b->m_position,sizeof(b->m_position),1,f); - } - } - return b; - } - CList* readall() - { - CList* bl = NULL; - if (f != NULL) - { - bl = new CList; - while (1) - { - Bkmk* b = read(); - if (b == NULL) break; - bl->push_back(*b); - delete b; - } - } - return bl; - } -}; +template +class CList; class CCharacterSource { public: -#ifdef _UNICODE - virtual tchar getch() = 0; -#else - virtual int getch() = 0; -#endif + virtual void getch(tchar&, CStyle&) = 0; }; class CExpander @@ -140,6 +27,17 @@ class CExpander virtual bool hasrandomaccess() = 0; virtual void sizes(unsigned long& file, unsigned long& text) = 0; virtual CList* getbkmklist() { return NULL; } + virtual void getch(int& ch, CStyle& sty) + { + ch = getch(); + sty.unset(); + } virtual int getch() = 0; + virtual bool hyperlink(unsigned int n) + { + locate(n); + return true; + } + virtual MarkupType PreferredMarkup() = 0; }; #endif -- cgit v0.9.0.2