* BufferView::scrollDocView(): simplify by using showCursor() and add some comments.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22708 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-01-29 10:17:41 +00:00
parent 81e06f7bc9
commit b78acb0b9d

View File

@ -509,7 +509,7 @@ void BufferView::scrollDocView(int value)
return; return;
} }
// cut off at the top // cut off at the bottom
if (value >= d->scrollbarParameters_.max) { if (value >= d->scrollbarParameters_.max) {
DocIterator dit = doc_iterator_end(buffer_.inset()); DocIterator dit = doc_iterator_end(buffer_.inset());
dit.backwardPos(); dit.backwardPos();
@ -526,31 +526,27 @@ void BufferView::scrollDocView(int value)
return; return;
} }
// find paragraph at target positin // find paragraph at target position
int par_pos = d->scrollbarParameters_.min; int par_pos = d->scrollbarParameters_.min;
for (size_t i = 0; i != d->par_height_.size(); ++i) { pit_type i = 0;
for (; i != d->par_height_.size(); ++i) {
par_pos += d->par_height_[i]; par_pos += d->par_height_[i];
if (par_pos >= value) { if (par_pos >= value)
d->anchor_pit_ = pit_type(i);
break; break;
}
} }
LYXERR(Debug::SCROLLING, "value = " << value if (par_pos < value) {
<< "\tanchor_ref_ = " << d->anchor_pit_ // It seems we didn't find the correct pit so stay on the safe side and
<< "\tpar_pos = " << par_pos); // scroll to bottom.
LYXERR0("scrolling position not found!");
// cut off at the end of the buffer scrollDocView(d->scrollbarParameters_.max);
if (value > par_pos) { return;
value = d->scrollbarParameters_.max;
d->anchor_pit_ = d->par_height_.size() - 1;
} }
// set pixel offset of screen to anchor pit DocIterator dit = doc_iterator_begin(buffer_.inset());
d->anchor_ypos_ = par_pos - value; dit.pit() = i;
LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
updateMetrics(); showCursor(dit);
buffer_.changed();
} }