author | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
commit | 118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (side-by-side diff) | |
tree | 356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/BuffDoc.cpp | |
parent | 00894537decf01c5a5cdc565b2740b5e67a2e90f (diff) | |
download | opie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2 |
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.cpp | 128 |
1 files changed, 94 insertions, 34 deletions
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 1123960..2402904 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp @@ -1,2 +1,4 @@ -#include "name.h" +#include "names.h" + +#define NEWLINEBREAK @@ -7,14 +9,25 @@ #include "plucker.h" +#include "usenef.h" +#ifdef USENEF +#include "nef.h" +#include "arrierego.h" +#endif - -bool BuffDoc::hyperlink(unsigned int n) +linkType BuffDoc::hyperlink(unsigned int n, QString& wrd) { - bool bRet = false; - lastword.empty(); - lastsizes[0] = laststartline = n; - lastispara = false; + linkType bRet = eNone; if (exp != NULL) { - bRet = exp->hyperlink(n); - lastsizes[0] = laststartline = exp->locate(); + bRet = exp->hyperlink(n, wrd); + if (bRet == eLink) + { + lastword.empty(); + lastsizes[0] = laststartline = n; +#ifdef NEWLINEBREAK + lastispara = true; +#else + lastispara = false; +#endif + lastsizes[0] = laststartline = exp->locate(); + } } @@ -25,14 +38,17 @@ void BuffDoc::locate(unsigned int n) { - // qDebug("BuffDoc:locating:%u",n); + // //qDebug("BuffDoc:locating:%u",n); lastword.empty(); lastsizes[0] = laststartline = n; - lastispara = false; +#ifdef NEWLINEBREAK + lastispara = true; +#else + lastispara = false; +#endif // tchar linebuf[1024]; if (exp != NULL) exp->locate(n); - // qDebug("BuffDoc:Located"); + // //qDebug("BuffDoc:Located"); } -#define NEWLINEBREAK #ifdef NEWLINEBREAK -bool BuffDoc::getline(CDrawBuffer* buff, int wth) +bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) { @@ -40,3 +56,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) bool margindone = false; - int w = wth-2*BORDER; + int w = wth-2*_border; tchar ch = 32; @@ -62,3 +78,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) unsigned int slen = buff->width(len); - lastispara = false; + if (lastispara) buff->setstartpara(); while (1) @@ -67,5 +83,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) getch(ch, cs); + if (ch == 10 && len == 0 && !lastispara) + { + lastsizes[len] = exp->locate(); + getch(ch, cs); + } if (ch == UEOF) { - lastword.empty(); if (len == 0) @@ -80,3 +100,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) { - lastword.empty(); + buff->setendpara(); lastispara = true; @@ -85,2 +105,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) } + lastispara = false; buff->addch(ch, cs); @@ -96,3 +117,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) { - lastword.empty(); + if (ch == ' ') buff->truncate(len-1); laststartline = exp->locate(); @@ -102,3 +123,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) { - for (int i = len-1; i > 0; i--) + for (int i = len-2; i > 0; i--) { @@ -118,4 +139,19 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) } + if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) + { + (*buff)[len] = 0; + lastword.setright(*buff, i+1); + buff->truncate(i+1); + (*buff)[i+1] = '\0'; + laststartline = lastsizes[i+1]; + buff->resize(); + for (int j = 0; j < lastword.length(); j++) + { + lastsizes[j] = lastsizes[j+i+1]; + } + return true; + } } laststartline = lastsizes[len-1]; + (*buff)[len] = 0; lastword.setright(*buff, len - 1); @@ -136,6 +172,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) #else -bool BuffDoc::getline(CDrawBuffer* buff, int wth) +bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) { bool margindone = false; - int w = wth-2*BORDER; + int w = wth-2*_border; tchar ch = 32; @@ -158,3 +194,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) else buff->empty(); -// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); +// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); lastcheck = len = buff->length(); @@ -233,3 +269,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) // lastword = buff->data()+lastcheck; -#ifdef WINDOWS +#ifdef _WINDOWS lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); @@ -266,5 +302,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth) -bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw) +bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border) { - int w = wth-2*BORDER; + int w = wth-2*_border; buff->empty(); @@ -276,4 +312,4 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw) CStyle cs; - int i = 0; - while (i*cw < w) + int i = 1; + while (i*cw < w-buff->offset(w,0)) { @@ -292,4 +328,4 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) { - // qDebug("BuffDoc:Openfile:%s", src); - // qDebug("Trying aportis %x",exp); + // //qDebug("BuffDoc:Openfile:%s", src); + // //qDebug("Trying aportis %x",exp); if (exp != NULL) delete exp; @@ -297,3 +333,7 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) lastsizes[0] = laststartline = 0; +#ifdef NEWLINEBREAK + lastispara = true; +#else lastispara = false; +#endif /* @@ -318,2 +358,18 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) } +#ifdef USENEF + if (ret != 0) + { + + delete exp; + exp = new CArriere; + ret = exp->openfile(src); + } + if (ret != 0) + { + + delete exp; + exp = new CNEF; + ret = exp->openfile(src); + } +#endif if (ret != 0) @@ -328,3 +384,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) delete exp; - qDebug("Trying ppms"); + //qDebug("Trying ppms"); exp = new ppm_expander; @@ -336,3 +392,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) exp = new Text; -// qDebug("Trying text"); +// //qDebug("Trying text"); ret = exp->openfile(src); @@ -346,3 +402,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) } - // qDebug("Doing final open:%x:%x",exp,filt); + // //qDebug("Doing final open:%x:%x",exp,filt); @@ -350,6 +406,10 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) lastsizes[0] = laststartline = 0; +#ifdef NEWLINEBREAK + lastispara = true; +#else lastispara = false; +#endif exp->locate(0); filt->setsource(exp); - // qDebug("BuffDoc:file opened"); + // //qDebug("BuffDoc:file opened"); return 0; |