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

View File

@ -157,7 +157,8 @@ public:
/// return true for events that will handle. /// return true for events that will handle.
FuncStatus getStatus(FuncRequest const & cmd); FuncStatus getStatus(FuncRequest const & cmd);
/// execute the given function. /// 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. /// request an X11 selection.
/// \return the selected string. /// \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); bv->getLyXText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
else else
bv->getLyXText()->insertStringAsLines(bv->cursor(), tmpstr); bv->getLyXText()->insertStringAsLines(bv->cursor(), tmpstr);
bv->update();
} }

View File

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