std::vector<size_t>::const_iterator ZLTextView::nextBreakIterator() const { ZLTextWordCursor cursor = endCursor(); if (cursor.isNull()) { cursor = startCursor(); } if (cursor.isNull()) { return myTextBreaks.begin(); } return std::lower_bound(myTextBreaks.begin(), myTextBreaks.end(), cursor.paragraphCursor().index()); }
bool ScrollToHomeAction::isEnabled() const { if (!isVisible()) { return false; } ZLTextWordCursor cursor = FBReader::Instance().bookTextView().textArea().startCursor(); return cursor.isNull() || !cursor.isStartOfParagraph() || !cursor.paragraphCursor().isFirst(); }
size_t ZLTextView::PositionIndicator::sizeOfTextBeforeParagraph(size_t paragraphIndex) const { if (myTextView.myModel->kind() == ZLTextModel::TREE_MODEL) { ZLTextWordCursor cursor = myTextView.startCursor(); if (cursor.isNull()) { cursor = myTextView.endCursor(); } if (!cursor.isNull()) { const ZLTextTreeModel &treeModel = (const ZLTextTreeModel&)*myTextView.myModel; size_t sum = 0; for (size_t i = 0; i < paragraphIndex; ++i) { const ZLTextTreeParagraph *para = (const ZLTextTreeParagraph*)treeModel[i]; if (para->parent()->isOpen()) { sum += sizeOfParagraph(i); } } return sum; } } return myTextView.myTextSize[paragraphIndex] - myTextView.myTextSize[startTextIndex()]; }
void IfEmptyWordList() { if (acwlistcount == 0) { ZLTextWordCursor cr = is_footnote_mode() ? footview->textArea().startCursor() : bookview->textArea().startCursor(); int paragraph = !cr.isNull() ? cr.paragraphCursor().index() : 0; if (acwlistcount + 3 >= acwlistsize) { acwlistsize = acwlistsize + (acwlistsize >> 1) + 64; acwordlist = (SynWordList *)realloc(acwordlist, acwlistsize * sizeof(SynWordList)); }
bool ZLTextAreaController::preparePaintInfo() { if ((myPaintState == NOTHING_TO_PAINT) || (myPaintState == READY)) { return false; } myArea.myLineInfoCache.insert(myArea.myLineInfos.begin(), myArea.myLineInfos.end()); switch (myPaintState) { default: break; case TO_SCROLL_FORWARD: if (!myArea.myEndCursor.paragraphCursor().isLast() || !myArea.myEndCursor.isEndOfParagraph()) { ZLTextWordCursor startCursor; switch (myScrollingMode) { case NO_OVERLAPPING: break; case KEEP_LINES: startCursor = findLineFromEnd(myOverlappingValue); break; case SCROLL_LINES: startCursor = findLineFromStart(myOverlappingValue); if (startCursor.isEndOfParagraph()) { startCursor.nextParagraph(); } break; case SCROLL_PERCENTAGE: startCursor = findPercentFromStart(myOverlappingValue); break; } if (!startCursor.isNull() && (startCursor == myArea.myStartCursor)) { startCursor = findLineFromStart(1); } if (!startCursor.isNull()) { ZLTextWordCursor endCursor = buildInfos(startCursor); if (!visiblePageIsEmpty() && ((myScrollingMode != KEEP_LINES) || (endCursor != myArea.myEndCursor))) { myArea.myStartCursor = startCursor; myArea.myEndCursor = endCursor; break; } } myArea.myStartCursor = myArea.myEndCursor; myArea.myEndCursor = buildInfos(myArea.myStartCursor); } break; case TO_SCROLL_BACKWARD: if (!myArea.myStartCursor.paragraphCursor().isFirst() || !myArea.myStartCursor.isStartOfParagraph()) { switch (myScrollingMode) { case NO_OVERLAPPING: myArea.myStartCursor = findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height()); break; case KEEP_LINES: { ZLTextWordCursor endCursor = findLineFromStart(myOverlappingValue); if (!endCursor.isNull() && (endCursor == myArea.myEndCursor)) { endCursor = findLineFromEnd(1); } if (!endCursor.isNull()) { ZLTextWordCursor startCursor = findStart(endCursor, PIXEL_UNIT, myArea.height()); myArea.myStartCursor = (startCursor != myArea.myStartCursor) ? startCursor : findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height()); } else { myArea.myStartCursor = findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height()); } break; } case SCROLL_LINES: myArea.myStartCursor = findStart(myArea.myStartCursor, LINE_UNIT, myOverlappingValue); break; case SCROLL_PERCENTAGE: myArea.myStartCursor = findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height() * myOverlappingValue / 100); break; } myArea.myEndCursor = buildInfos(myArea.myStartCursor); if (visiblePageIsEmpty()) { myArea.myStartCursor = findStart(myArea.myStartCursor, LINE_UNIT, 1); myArea.myEndCursor = buildInfos(myArea.myStartCursor); } } break; case START_IS_KNOWN: myArea.myEndCursor = buildInfos(myArea.myStartCursor); if (visiblePageIsEmpty()) { ZLTextWordCursor startCursor = findLineFromStart(1); if (!startCursor.isNull()) { myArea.myStartCursor = startCursor; if (myArea.myStartCursor.isEndOfParagraph()) { myArea.myStartCursor.nextParagraph(); } myArea.myEndCursor = buildInfos(myArea.myStartCursor); } } break; case END_IS_KNOWN: myArea.myStartCursor = findStart(myArea.myEndCursor, PIXEL_UNIT, myArea.height()); myArea.myEndCursor = buildInfos(myArea.myStartCursor); break; } myPaintState = READY; myArea.myLineInfoCache.clear(); return true; }