* BufferView::workAreaDispatch(): prepare for finer grained updates.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15889 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-11-12 16:14:45 +00:00
parent 92d47b0246
commit a1d0ad06df

View File

@ -1001,19 +1001,16 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
// LFUN_FILE_OPEN generated by drag-and-drop.
FuncRequest cmd = cmd0;
// E.g. Qt mouse press when no buffer
if (!buffer_)
return false;
bool needRedraw = false;
LCursor cur(*this);
cur.push(buffer_->inset());
cur.selection() = cursor_.selection();
// Doesn't go through lyxfunc, so we need to update
// the layout choice etc. ourselves
// E.g. Qt mouse press when no buffer
if (!buffer_)
return false;
needRedraw |= cur.selection();
// Either the inset under the cursor or the
// surrounding LyXText will handle this event.
@ -1021,6 +1018,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
// Build temporary cursor.
cmd.y = min(max(cmd.y, -1), height_);
InsetBase * inset = buffer_->text().editXY(cur, cmd.x, cmd.y);
//lyxerr << BOOST_CURRENT_FUNCTION
// << " * hit inset at tip: " << inset << endl;
//lyxerr << BOOST_CURRENT_FUNCTION
@ -1033,8 +1031,10 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
// via the temp cursor. If the inset wishes to change the real
// cursor it has to do so explicitly by using
// cur.bv().cursor() = cur; (or similar)
if (inset)
if (inset) {
inset->dispatch(cur, cmd);
needRedraw = true;
}
// Now dispatch to the temporary cursor. If the real cursor should
// be modified, the inset's dispatch has to do so explicitly.
@ -1044,11 +1044,13 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
if (cur.result().dispatched()) {
// Redraw if requested or necessary.
if (cur.result().update())
update(Update::FitCursor | Update::Force);
needRedraw |= update(Update::FitCursor | Update::Force);
else
update(Update::FitCursor | Update::MultiParSel);
needRedraw |= update(Update::FitCursor | Update::MultiParSel);
}
// When the above and the inner function are fixed, we can do this:
//return needRedraw;
return true;
}
@ -1201,14 +1203,9 @@ ViewMetricsInfo const & BufferView::viewMetricsInfo()
void BufferView::updateMetrics(bool singlepar)
{
// FIXME (Abdel 19/10/2006):
// There's something fishy in tabular. The coord_cache_ is not
// correctly reconstructed when a character is trying to be inserted.
// Not clearing out the coord_cache_ fixes the crash but there is a
// bad side effect: buffer-begin and buffer-end do not update the screen.
//
// Remove old position cache
coord_cache_.clear();
// Clear out the position cache in case of full screen redraw.
//if (!singlepar)
coord_cache_.clear();
LyXText & buftext = buffer_->text();
pit_type size = int(buftext.paragraphs().size());