author | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
commit | 876e1a4724a7bd75dc642e295de354241096e028 (patch) (side-by-side diff) | |
tree | a37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/QTReader.cpp | |
parent | 5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff) | |
download | opie-876e1a4724a7bd75dc642e295de354241096e028.zip opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2 |
update - sorry it took so long. hope this works correctly
Diffstat (limited to 'noncore/apps/opie-reader/QTReader.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 540 |
1 files changed, 379 insertions, 161 deletions
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 7cf08e5..3995ee7 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp @@ -17,43 +17,46 @@ #include <math.h> #include <ctype.h> #include <stdio.h> //for sprintf #include <qpe/config.h> #include <qpe/applnk.h> #include <qfontdatabase.h> #include <qpe/global.h> #include <qpe/qcopenvelope_qws.h> +#include "StateData.h" #ifdef _UNICODE const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; #else const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; #endif //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; //const int QTReader::fontsizes[] = {10,16,17,22,0}; //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; -QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : +QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : QWidget(parent, name, f), m_delay(100), m_scrolldy1(0), m_scrolldy2(0), m_autoScroll(false), //textarray(NULL), //locnarray(NULL), numlines(0), m_fontname("unifont"), m_fm(NULL), mouseUpOn(true), m_twotouch(true), - m_touchone(true) + m_touchone(true), + bDoUpdates(false), + m_navkeys(true) { m_overlap = 1; // init(); } /* QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : QWidget(parent, name, f), m_textfont(0), @@ -76,88 +79,160 @@ QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *nam long QTReader::real_delay() { return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); } void QTReader::mousePressEvent( QMouseEvent* _e ) { + buffdoc.unsuspend(); if (_e->button() == RightButton) { mouseUpOn = false; - if (_e->y() > height()/2) + if (buffdoc.hasnavigation()) { - goDown(); + if (_e->y() > (2*height())/3) + { + goDown(); + } + else if (_e->y() < height()/3) + { + goUp(); + } + else + { + if (_e->x() < width()/3) + { + size_t target = pagelocate(); + if (buffdoc.back(target)) + { + locate(target); + } + } + else if (_e->x() > (2*width())/3) + { + size_t target = pagelocate(); + if (buffdoc.forward(target)) + { + locate(target); + } + } + else + { + buffdoc.saveposn(pagelocate()); + locate(buffdoc.getHome()); + } + } } else { - goUp(); + if (_e->y() > height()/2) + { + goDown(); + } + else + { + goUp(); + } } } } -bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) +linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) { int lineno = 0; int ht = textarray[0]->lineSpacing(); while ((ht < y) && (lineno < numlines)) { ht += textarray[++lineno]->lineSpacing(); } start = locnarray[lineno]; if (m_bMonoSpaced) { offset = x/m_charWidth; } else { int i; CDrawBuffer* t = textarray[lineno]; - for (i = t->length(); t->width(i) > x; i--); + x = x - t->offset(width()); + for (i = t->length(); i >= 0 && t->width(i) > x; i--); offset = i; } - return textarray[lineno]->isLink(offset, tgt); + return textarray[lineno]->getLinkType(offset, tgt); } void QTReader::setTwoTouch(bool _b) { setBackgroundColor( white ); m_twotouch = m_touchone = _b; } +void QTReader::setContinuous(bool _b) +{ + buffdoc.unsuspend(); + buffdoc.setContinuous(m_continuousDocument = _b); +} + void QTReader::mouseReleaseEvent( QMouseEvent* _e ) { + buffdoc.unsuspend(); if (_e->button() == LeftButton) { if (mouseUpOn) { if (textarray[0] != NULL) { QString wrd, line; // int lineno = _e->y()/m_linespacing; int lineno = 0; int ht = textarray[0]->lineSpacing(); while ((ht < _e->y()) && (lineno < numlines)) { ht += textarray[++lineno]->lineSpacing(); } size_t startpos, startoffset, tgt; - if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) + switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) { - if (buffdoc.hyperlink(tgt)) + case eLink: { - fillbuffer(); - update(); + size_t saveposn = pagelocate(); + if (buffdoc.hyperlink(tgt)) + { + buffdoc.saveposn(saveposn); + fillbuffer(); + update(); + } + else + { + locate(pagelocate()); + } + return; } - else + case ePicture: { - locate(pagelocate()); + qDebug("Picture:%x", tgt); + QPixmap* pm = buffdoc.getPicture(tgt); + if (pm != NULL) + { + emit OnShowPicture(*pm); + delete pm; + } + else + { + locate(pagelocate()); + } + return; } - return; + case eNone: + break; + default: + qDebug("Unknown linktype"); + return; } if (m_twotouch) { if (m_touchone) { m_touchone = false; m_startpos = startpos; m_startoffset = startoffset; @@ -207,21 +282,22 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) { wrd[0] = textarray[lineno]->data()[chno]; } } else { CDrawBuffer* t = textarray[lineno]; int first = 0; + int tgt = _e->x() - t->offset(width()); while (1) { int i = first+1; while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; - if (t->width(i) > _e->x()) + if (t->width(i) > tgt) { wrd = toQString(t->data()+first, i - first); break; } while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; if ((*t)[i] == 0) break; first = i; } @@ -277,18 +353,87 @@ void QTReader::goUp() dopageup(); } else { lineUp(); } } +void QTReader::NavUp() +{ + buffdoc.unsuspend(); + if (buffdoc.hasnavigation()) + { +/* + size_t target = pagelocate(); + if (buffdoc.back(target)) + { + locate(target); + } +*/ + locate(buffdoc.startSection()); + } + else + { + goUp(); + } +} + +void QTReader::NavDown() +{ + buffdoc.unsuspend(); + if (buffdoc.hasnavigation()) + { +/* + size_t target = pagelocate(); + if (buffdoc.forward(target)) + { + locate(target); + } +*/ + dopageup(buffdoc.endSection()); + } + else + { + goDown(); + } +} + +void QTReader::zoomin() +{ + if (m_fontControl.increasesize()) + { + bool sc = m_autoScroll; + setfont(); + m_autoScroll = false; + locate(pagelocate()); + update(); + m_autoScroll = sc; + if (m_autoScroll) autoscroll(); + } +} + +void QTReader::zoomout() +{ + if (m_fontControl.decreasesize()) + { + bool sc = m_autoScroll; + m_autoScroll = false; + setfont(); + locate(pagelocate()); + update(); + m_autoScroll = sc; + if (m_autoScroll) autoscroll(); + } +} + void QTReader::keyPressEvent(QKeyEvent* e) { + buffdoc.unsuspend(); switch (e->key()) { case Key_Down: { e->accept(); if (m_autoScroll) { if (m_delay < 59049) @@ -352,46 +497,44 @@ void QTReader::keyPressEvent(QKeyEvent* e) { setfont(NULL); locate(pagelocate()); update(); } } break; */ - case Key_Right: + case Key_Right: { - e->accept(); - if (m_fontControl.increasesize()) - { - bool sc = m_autoScroll; - setfont(); - m_autoScroll = false; - locate(pagelocate()); - update(); - m_autoScroll = sc; - if (m_autoScroll) autoscroll(); - } + e->accept(); + if (m_navkeys && buffdoc.hasnavigation()) + { + size_t target = pagelocate(); + if (buffdoc.forward(target)) + { + locate(target); + } + } + else zoomin(); } - break; - case Key_Left: + break; + case Key_Left: { - e->accept(); - if (m_fontControl.decreasesize()) - { - bool sc = m_autoScroll; - m_autoScroll = false; - setfont(); - locate(pagelocate()); - update(); - m_autoScroll = sc; - if (m_autoScroll) autoscroll(); - } + e->accept(); + if (m_navkeys && buffdoc.hasnavigation()) + { + size_t target = pagelocate(); + if (buffdoc.back(target)) + { + locate(target); + } + } + else zoomout(); } - break; + break; case Key_Space: case Key_Return: { e->accept(); emit OnActionPressed(); } break; default: @@ -404,24 +547,27 @@ void QTReader::setautoscroll(bool _sc) if (_sc == m_autoScroll) return; if (m_autoScroll) { m_autoScroll = false; QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } else { + CDrawBuffer* reusebuffer = textarray[numlines]; + if (reusebuffer == NULL || reusebuffer->eof()) return; m_autoScroll = true; autoscroll(); QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed } } bool QTReader::getline(CDrawBuffer *buff) { + buffdoc.unsuspend(); if (m_bMonoSpaced) { return buffdoc.getline(buff ,width(), m_charWidth); } else { return buffdoc.getline(buff, width()); } @@ -454,27 +600,26 @@ void QTReader::doscroll() } if (++m_scrolldy2 == textarray[numlines]->lineSpacing()) { m_scrolldy2 = 0; numlines++; if (textarray[numlines] == NULL) { - textarray[numlines] = new CDrawBuffer; + textarray[numlines] = new CDrawBuffer(&m_fontControl); } locnarray[numlines] = locate(); int ch = getline(textarray[numlines]); - textarray[numlines-1]->render(&p, height() - textarray[numlines]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); + textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); mylastpos = locate(); if (!ch) { m_autoScroll = false; ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); - emit OnRedraw(); } emit OnRedraw(); } } void QTReader::autoscroll() { timer->start(real_delay(), false); @@ -487,88 +632,80 @@ void QTReader::setfont() if (m_charWidth <= 0) m_charWidth = 1; m_ascent = m_fontControl.ascent(); m_descent = m_fontControl.descent(); m_linespacing = m_fontControl.lineSpacing(); } void QTReader::drawFonts( QPainter *p ) { - setfont(); - if (m_lastwidth != width() || m_lastheight != height()) - { - m_lastwidth = width(); - m_lastheight = height(); - locate(pagelocate()); - } - else - { - -/* - int sl = screenlines(); - if (sl < numlines) - { -// qDebug("df:<%u,%u>",sl,numlines); - - size_t newpos = locnarray[sl]; - CDrawBuffer** nta = new CDrawBuffer*[sl]; - size_t* nla = new size_t[sl]; - for (int i = 0; i < sl; i++) - { - nta[i] = textarray[i]; - nla[i] = locnarray[i]; - } - for (int i = sl; i < numlines; i++) delete textarray[i]; - delete [] locnarray; - delete [] textarray; - textarray = nta; - locnarray = nla; - numlines = sl; - jumpto(mylastpos = newpos); - } - if (sl > numlines) - { -// qDebug("df:<%u,%u>",sl,numlines); - CDrawBuffer** nta = new CDrawBuffer*[sl]; - size_t* nla = new size_t[sl]; - for (int i = 0; i < numlines; i++) - { - nta[i] = textarray[i]; - nla[i] = locnarray[i]; - } - if (locate() != mylastpos) jumpto(mylastpos); - for (int i = numlines; i < sl; i++) - { - nta[i] = new CDrawBuffer(&m_fontControl); - nla[i] = locate(); - getline(nta[i]); - } - mylastpos = locate(); - delete [] locnarray; - delete [] textarray; - textarray = nta; - locnarray = nla; - numlines = sl; - } -*/ - if (numlines > 0) - { - int ypos = textarray[0]->ascent(); - textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); - for (int i = 1; i < numlines; i++) - { - ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; - textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); - - } + if (bDoUpdates) + { + qDebug("How refreshing..."); + if (buffdoc.empty()) return; + setfont(); + if (m_lastwidth != width()) + { + qDebug("Not Optimised %d", m_lastwidth); + m_lastwidth = width(); + m_lastheight = height(); + locate(pagelocate()); + qDebug("Not Optimised %d", m_lastwidth); + } + else + { + if (m_lastheight > height()) + { + qDebug("Optimised < %d", numlines); + int ypos = 0; + for (int i = 0; i < numlines; i++) + { + if ((ypos += textarray[i]->lineSpacing()) > height()) + { + numlines = i; + jumpto(locnarray[i+1]); + break; + } + } + qDebug("Optimised < %d", numlines); + m_lastheight = height(); + } + else if (m_lastheight < height()) + { + qDebug("Optimised > %d", numlines); + int ypos = 0; + for (int i = 0; i <= numlines; i++) + { + ypos += textarray[i]->lineSpacing(); + } + fillbuffer(numlines+1, ypos); + qDebug("Optimised > %d", numlines); + m_lastheight = height(); + } + if (numlines > 0) + { + int ypos = textarray[0]->ascent(); + textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); + for (int i = 1; i < numlines; i++) + { +// ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; + ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ + (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; + textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); + } // mylastpos = locate(); - } - } - m_scrolldy1 = m_scrolldy2 = 0; - emit OnRedraw(); + } + } + m_scrolldy1 = m_scrolldy2 = 0; + emit OnRedraw(); + } + else + { + qDebug("Not so refreshing..."); + } } QString QTReader::firstword() { if (m_bMonoSpaced) { return toQString(textarray[0]->data()); } @@ -602,35 +739,36 @@ bool QTReader::ChangeFont(int tgt) { return m_fontControl.ChangeFont(m_fontname, tgt); } void QTReader::init() { // setCaption( "Qt Draw Demo Application" ); + buffdoc.unsuspend(); setBackgroundColor( white ); // QPainter p(this); // p.setBackgroundMode( Qt::OpaqueMode ); buffdoc.setfilter(getfilter()); ChangeFont(m_textsize); setFocusPolicy(QWidget::StrongFocus); // resize( 240, 320 ); //setFocus(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); // QMessageBox::information(this, "init", m_lastfile, 1); - m_lastwidth = width(); - m_lastheight = height(); setfont(); +/* if (!m_lastfile.isEmpty()) { m_string = DocLnk(m_lastfile).name(); load_file(m_lastfile); } +*/ } // // Clean up // QTReader::~QTReader() { } @@ -696,16 +834,17 @@ int main( int argc, tchar **argv ) draw.show(); return app.exec(); } */ bool QTReader::locate(unsigned long n) { //printf("Locate\n"); + buffdoc.unsuspend(); buffdoc.locate(n); // qDebug("&buffdoc.located"); fillbuffer(); // qDebug("&Buffer filled"); update(); // qDebug("&Located"); return true; } @@ -714,36 +853,37 @@ unsigned int QTReader::screenlines() { // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; // return (height()-m_descent)/(m_linespacing); return (height()-2)/(m_linespacing); }; bool QTReader::fillbuffer(int reuse, int ht) { + buffdoc.unsuspend(); if (buffdoc.empty()) return false; m_scrolldy1 = m_scrolldy2 = 0; int ch; bool ret = false; unsigned int oldpagepos = locnarray[reuse]; int ypos = ht; numlines = reuse; - while (ypos < height()) + while (ypos < height() || numlines < 2) { if (textarray[numlines] == NULL) { textarray[numlines] = new CDrawBuffer(&m_fontControl); } locnarray[numlines] = locate(); int ch = getline(textarray[numlines]); ypos += textarray[numlines]->lineSpacing(); numlines++; if (!ch) { - if (numlines - reuse == 1/* && locnarray[0] == buffdoc.locate()*/) + if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) { locate(oldpagepos); return false; } else { --numlines; mylastpos = locate(); @@ -756,120 +896,156 @@ bool QTReader::fillbuffer(int reuse, int ht) mylastpos = locate(); return true; } void QTReader::dopagedn() { + buffdoc.unsuspend(); int skip = 0, ypos = 0; if (locate() != mylastpos) { // qDebug("Jumping to %u", mylastpos); jumpto(mylastpos); } CDrawBuffer* reusebuffer = textarray[numlines]; + if (reusebuffer != NULL && reusebuffer->eof()) return; if (reusebuffer != NULL) { for (int i = 0; i <= m_overlap; i++) { int offset = numlines - m_overlap + i; reusebuffer = textarray[offset]; size_t reuselocn = locnarray[offset]; textarray[offset] = textarray[i]; textarray[i] = reusebuffer; +// reusebuffer->empty(); locnarray[offset] = locnarray[i]; locnarray[i] = reuselocn; ypos += textarray[i]->lineSpacing(); skip++; } } if (fillbuffer(skip, ypos)) { update(); } } void QTReader::dopageup() { + buffdoc.unsuspend(); + dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); +} + +void QTReader::dopageup(unsigned int target) +{ + buffdoc.unsuspend(); CBufferFace<CDrawBuffer*> buff; CBufferFace<size_t> loc; - unsigned int target = locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]; - size_t delta; - if (target < 2048) - { - delta = target; - jumpto(0); - } - else - { - delta = 2048; + size_t delta, guess = 2048; + bool ch = true; + int nbfl, ypos = 0; - jumpto(target - delta); - - buff[0] = new CDrawBuffer(&m_fontControl); - - do + while (1) + { + ch = true; + nbfl = 0; + if (target < guess) + { + delta = 0; // 0 is a flag to say don't guess any more + jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); + } + else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) + { + delta = 0; // 0 is a flag to say don't guess any more + jumpto(buffdoc.startSection()); + } + else { + delta = guess; - if (!getline(buff[0])) break; + jumpto(target - delta); - if (locate() > target) continue; + buff[0] = new CDrawBuffer(&m_fontControl); + + do + { + + if (!getline(buff[0])) break; + + if (locate() > target) break; + } + while (!buffdoc.iseol()); } - while (!buffdoc.iseol()); - } - int nbfl = 0; - - bool ch = true; - int ypos = 0; - while (locate() < target) - { - if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); - loc[nbfl] = locate(); - ch = getline(buff[nbfl]); - ypos += buff[nbfl]->lineSpacing(); - nbfl++; - if (!ch) break; - } - if (ypos < height()) - { - locate(0); - return; + + ypos = 0; + while (locate() < target) + { + if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); + loc[nbfl] = locate(); + ch = getline(buff[nbfl]); + ypos += buff[nbfl]->lineSpacing(); + nbfl++; + if (!ch) break; + } + if (ypos < height() && (delta != 0)) + { + for (int i = 0; i < nbfl; i++) + { + delete buff[i]; + buff[i] = NULL; + } + guess <<= 1; + continue; + } + break; } if (ch) { if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); loc[nbfl] = locate(); int ch = getline(buff[nbfl]); nbfl++; } ypos = 0; numlines = 0; - while (ypos < height() && numlines <= nbfl-2) + while (ypos < height() && numlines <= nbfl-1) { - ypos += buff[nbfl - numlines - 2]->lineSpacing(); + ypos += buff[nbfl - numlines - 1]->lineSpacing(); numlines++; } --numlines; - int offset = nbfl; - offset -= numlines+1; + int offset = nbfl-1; + offset -= numlines; + ypos = 0; for (int i = 0; i <= numlines; i++) { delete textarray[i]; textarray[i] = buff[offset+i]; locnarray[i] = loc[offset + i]; + ypos += textarray[i]->lineSpacing(); } for (int i = 0; i < nbfl - numlines - 1; i++) { delete buff[i]; } -// --numlines; + while (ypos < height()) + { + numlines++; + locnarray[numlines] = locate(); + if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); + if (!getline(textarray[numlines])) break; + ypos += textarray[numlines]->lineSpacing(); + } + mylastpos = locate(); update(); } bool QTReader::load_file(const char *newfile, unsigned int _lcn) { // QMessageBox::information(this, "Name", name, 1); @@ -878,19 +1054,22 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) bool bRC = false; unsigned int lcn = _lcn; if (m_lastfile == newfile) { lcn = m_lastposn; } m_lastfile = newfile; // QMessageBox::information(0, "Opening...", newfile); + m_lastwidth = width(); + m_lastheight = height(); if (buffdoc.openfile(this,newfile) == 0) { bRC = true; + buffdoc.setContinuous(m_continuousDocument); // qDebug("buffdoc.openfile done"); locate(lcn); // qDebug("buffdoc.locate done"); } setfilter(getfilter()); update(); // qDebug("Updated"); return bRC; @@ -1007,38 +1186,48 @@ void QTReader::lineUp() delete [] buff; delete [] loc; mylastpos = locate(); update(); } */ void QTReader::lineUp() { + buffdoc.unsuspend(); CDrawBuffer* buff = textarray[numlines]; unsigned int loc; unsigned int end = locnarray[numlines]; int cbptr = 0; if (locate() != mylastpos) jumpto(mylastpos); unsigned int target = locnarray[0]; if (target == 0) return; + if (!m_continuousDocument && (target == buffdoc.startSection())) return; if (buffdoc.hasrandomaccess()) { unsigned int delta = locate()-pagelocate(); if (delta < 64) delta = 64; do { delta <<= 1; if (delta >= target) { delta = target; jumpto(0); loc = locate(); getline(buff); break; } + else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) + { + delta = target-buffdoc.startSection(); + jumpto(buffdoc.startSection()); + loc = locate(); + getline(buff); + break; + } jumpto(target-delta); do { getline(buff); #ifdef WS //printf("Trying:%s\n",buff[0]); #endif if (locate() > target) continue; @@ -1102,8 +1291,37 @@ MarkupType QTReader::PreferredMarkup() if (ft.left(3) == "HTM") { m = cHTML; } } } return m; } + +void QTReader::setstate(const statedata& sd) +{ + bstripcr = sd.bstripcr; + btextfmt = sd.btextfmt; + bautofmt = sd.bautofmt; + bstriphtml = sd.bstriphtml; + bpeanut = sd.bpeanut; + bdehyphen = sd.bdehyphen; + bonespace = sd.bonespace; + bunindent = sd.bunindent; + brepara = sd.brepara; + bdblspce = sd.bdblspce; + m_bpagemode = sd.m_bpagemode; + m_navkeys = sd.m_navkeys; + m_bMonoSpaced = sd.m_bMonoSpaced; + bremap = sd.bremap; + bmakebold = sd.bmakebold; + m_continuousDocument = sd.Continuous; +#ifdef REPALM + brepalm = sd.brepalm; +#endif + bindenter = sd.bindenter; + m_encd = sd.m_charpc; + m_fontname = sd.m_fontname; + setContinuous(sd.Continuous); + ChangeFont(sd.m_textsize); + refresh(); +} |