summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/BuffDoc.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp122
1 files changed, 91 insertions, 31 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,15 +9,26 @@
#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)
+{
+ linkType bRet = eNone;
+ if (exp != NULL)
+ {
+ bRet = exp->hyperlink(n, wrd);
+ if (bRet == eLink)
{
- bool bRet = false;
lastword.empty();
lastsizes[0] = laststartline = n;
+#ifdef NEWLINEBREAK
+ lastispara = true;
+#else
lastispara = false;
- if (exp != NULL)
- {
- bRet = exp->hyperlink(n);
+#endif
lastsizes[0] = laststartline = exp->locate();
}
+ }
return bRet;
@@ -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;
+#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;