<< ", singlepar = " << (flags & Update::SinglePar)
<< "] buffer: " << &buffer_);
- // Update macro store
- if (!(cursor().inMathed() && cursor().inMacroMode()))
- buffer_.updateMacros();
+ buffer_.updateMacros();
// Now do the first drawing step if needed. This consists on updating
// the CoordCache in updateMetrics().
int const parsize = int(t.paragraphs().size());
if (d->par_height_.size() != parsize) {
d->par_height_.clear();
- // FIXME: We assume a default paragraph height of 4 rows. This
+ // FIXME: We assume a default paragraph height of 2 rows. This
// should probably be pondered with the screen width.
- d->par_height_.resize(parsize, defaultRowHeight() * 4);
+ d->par_height_.resize(parsize, defaultRowHeight() * 2);
}
// It would be better to fix the scrollbar to understand
for (pit_type pit = first.first; pit <= last.first; ++pit) {
ParagraphMetrics const & pm = tm.parMetrics(pit);
d->par_height_[pit] = pm.height();
- if (first_visible_pit < 0 && pm.position() + pm.descent() > 0)
- first_visible_pit = pit;
+ if (first_visible_pit >= 0 || pm.position() + pm.descent() <= 0)
+ continue;
+ first_visible_pit = pit;
+ LYXERR(Debug::SCROLLING, "first visible pit " << first_visible_pit);
+ // FIXME: we should look for the first visible row within
+ // the deepest inset!
+ int row_pos = pm.position();
+ size_t const nrows = pm.rows().size();
+ for (size_t i = 0; i != nrows; ++i) {
+ Row const & row = pm.rows()[i];
+ if (row_pos >= 0) {
+ LYXERR(Debug::SCROLLING, "first visible row " << i
+ << "(row pos = " << row_pos << ");");
+ break;
+ }
+ row_pos += row.height();
+ }
+ d->scrollbarParameters_.position = row_pos;
}
- LYXERR(Debug::SCROLLING, "first_visible_pit " << first_visible_pit);
-
d->scrollbarParameters_.height = 0;
for (size_t i = 0; i != d->par_height_.size(); ++i) {
+ if (i == first_visible_pit)
+ d->scrollbarParameters_.position += d->scrollbarParameters_.height;
d->scrollbarParameters_.height += d->par_height_[i];
- if (i != first_visible_pit)
- continue;
- // FIXME: we should look for the first visible row within
- // the deepest inset!
- d->scrollbarParameters_.position = d->scrollbarParameters_.height;
}
- d->scrollbarParameters_.lineScrollHeight =
- tm.parMetrics(first_visible_pit).rows()[0].height();
+ // We prefer fixed size line scrolling.
+ d->scrollbarParameters_.lineScrollHeight = defaultRowHeight();
}
void BufferView::scrollDocView(int value)
{
int const offset = value - d->scrollbarParameters_.position;
- //TextMetrics & tm = d->text_metrics_[&buffer_.text()];
- if (abs(offset) <= 3*height_) {
+ // If the offset is less than 2 screen height, prefer to scroll instead.
+ if (abs(offset) <= 2 * height_) {
scroll(offset);
return;
}
}
-Update::flags BufferView::dispatch(FuncRequest const & cmd)
+bool BufferView::dispatch(FuncRequest const & cmd)
{
//lyxerr << [ cmd = " << cmd << "]" << endl;
<< " button[" << cmd.button() << ']');
Cursor & cur = d->cursor_;
- // Default Update flags.
- Update::flags updateFlags = Update::Force | Update::FitCursor;
switch (cmd.action) {
case LFUN_UNDO:
cur.message(_("Undo"));
cur.clearSelection();
- if (!cur.textUndo()) {
+ if (!cur.textUndo())
cur.message(_("No further undo information"));
- updateFlags = Update::None;
- }
break;
case LFUN_REDO:
cur.message(_("Redo"));
cur.clearSelection();
- if (!cur.textRedo()) {
+ if (!cur.textRedo())
cur.message(_("No further redo information"));
- updateFlags = Update::None;
- }
break;
case LFUN_FONT_STATE:
theLyXFunc().dispatch(FuncRequest(
LFUN_BUFFER_SWITCH, b->absFileName()));
theLyXFunc().dispatch(cmd);
- updateFlags = Update::None;
}
break;
}
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
//FIXME: what to do with cur.x_target()?
cur.finishUndo();
- // The metrics are already up to date. see scroll()
- updateFlags = Update::None;
break;
}
case LFUN_SCREEN_UP_SELECT:
case LFUN_SCREEN_DOWN_SELECT: {
+ // Those two are not ready yet for consumption.
+ return false;
+
cur.selHandle(true);
size_t initial_depth = cur.depth();
Point const p = getPos(cur, cur.boundary());
// But no screen update is needed.
d->update_strategy_ = NoScreenUpdate;
buffer_.changed();
- updateFlags = Update::Force | Update::FitCursor;
break;
}
default:
- updateFlags = Update::None;
+ return false;
}
- return updateFlags;
+ return true;
}