Remove buggy and redundant BufferView::update() calls.

* BufferView::dispatch() now returns an Update::flags.

* lyx_cb.C::insertPlaintextFile(): delete redundant BufferView::update() call.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16844 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-01-24 23:10:03 +00:00
parent e4c489376c
commit c347f0467b
4 changed files with 26 additions and 25 deletions

View File

@ -690,7 +690,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
}
bool BufferView::dispatch(FuncRequest const & cmd)
Update::flags BufferView::dispatch(FuncRequest const & cmd)
{
//lyxerr << BOOST_CURRENT_FUNCTION
// << [ cmd = " << cmd << "]" << endl;
@ -704,30 +704,34 @@ bool BufferView::dispatch(FuncRequest const & cmd)
<< " button[" << cmd.button() << ']'
<< endl;
// FIXME: this should not be possible.
if (!buffer_)
return Update::None;
LCursor & cur = cursor_;
// Default Update flags.
Update::flags updateFlags = Update::Force | Update::FitCursor;
switch (cmd.action) {
case LFUN_UNDO:
if (buffer_) {
cur.message(_("Undo"));
cur.clearSelection();
if (!textUndo(*this))
cur.message(_("No further undo information"));
update();
switchKeyMap();
cur.message(_("Undo"));
cur.clearSelection();
if (!textUndo(*this)) {
cur.message(_("No further undo information"));
updateFlags = Update::None;
}
switchKeyMap();
break;
case LFUN_REDO:
if (buffer_) {
cur.message(_("Redo"));
cur.clearSelection();
if (!textRedo(*this))
cur.message(_("No further redo information"));
update();
switchKeyMap();
cur.message(_("Redo"));
cur.clearSelection();
if (!textRedo(*this)) {
cur.message(_("No further redo information"));
updateFlags = Update::None;
}
switchKeyMap();
break;
case LFUN_FILE_INSERT:
@ -789,13 +793,13 @@ bool BufferView::dispatch(FuncRequest const & cmd)
if (b == buffer_) {
// Set the cursor
setCursor(makeDocIterator(par, 0));
update();
switchKeyMap();
} else {
// Switch to other buffer view and resend cmd
theLyXFunc().dispatch(FuncRequest(
LFUN_BUFFER_SWITCH, b->fileName()));
theLyXFunc().dispatch(cmd);
updateFlags = Update::None;
}
break;
}
@ -839,10 +843,9 @@ bool BufferView::dispatch(FuncRequest const & cmd)
buffer_->params().trackChanges = !buffer_->params().trackChanges;
break;
case LFUN_CHANGES_OUTPUT: {
case LFUN_CHANGES_OUTPUT:
buffer_->params().outputChanges = !buffer_->params().outputChanges;
break;
}
case LFUN_CHANGE_NEXT:
findNextChange(this);
@ -860,7 +863,6 @@ bool BufferView::dispatch(FuncRequest const & cmd)
#endif
while (findNextChange(this))
getLyXText()->acceptOrRejectChange(cursor_, true);
update();
break;
}
@ -995,10 +997,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
}
default:
return false;
updateFlags = Update::None;
}
return true;
return updateFlags;
}

View File

@ -157,7 +157,8 @@ public:
/// return true for events that will handle.
FuncStatus getStatus(FuncRequest const & cmd);
/// execute the given function.
bool dispatch(FuncRequest const & argument);
/// \return the Update::flags for further metrics update.
Update::flags dispatch(FuncRequest const & argument);
/// request an X11 selection.
/// \return the selected string.

View File

@ -337,7 +337,6 @@ void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
bv->getLyXText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
else
bv->getLyXText()->insertStringAsLines(bv->cursor(), tmpstr);
bv->update();
}

View File

@ -1739,8 +1739,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
view()->cursor().dispatch(cmd);
updateFlags = view()->cursor().result().update();
if (!view()->cursor().result().dispatched())
if (view()->dispatch(cmd))
updateFlags = Update::Force | Update::FitCursor;
updateFlags = view()->dispatch(cmd);
break;
}
}