* LyXFunc::dispatch(): invert BufferView::dispatch() and cursor::dispatch() calling.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22227 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-21 10:42:59 +00:00
parent b8be6be268
commit 96d2d6fc50
4 changed files with 22 additions and 26 deletions

View File

@ -862,7 +862,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
} }
Update::flags BufferView::dispatch(FuncRequest const & cmd) bool BufferView::dispatch(FuncRequest const & cmd)
{ {
//lyxerr << [ cmd = " << cmd << "]" << endl; //lyxerr << [ cmd = " << cmd << "]" << endl;
@ -874,27 +874,21 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
<< " button[" << cmd.button() << ']'); << " button[" << cmd.button() << ']');
Cursor & cur = d->cursor_; Cursor & cur = d->cursor_;
// Default Update flags.
Update::flags updateFlags = Update::Force | Update::FitCursor;
switch (cmd.action) { switch (cmd.action) {
case LFUN_UNDO: case LFUN_UNDO:
cur.message(_("Undo")); cur.message(_("Undo"));
cur.clearSelection(); cur.clearSelection();
if (!cur.textUndo()) { if (!cur.textUndo())
cur.message(_("No further undo information")); cur.message(_("No further undo information"));
updateFlags = Update::None;
}
break; break;
case LFUN_REDO: case LFUN_REDO:
cur.message(_("Redo")); cur.message(_("Redo"));
cur.clearSelection(); cur.clearSelection();
if (!cur.textRedo()) { if (!cur.textRedo())
cur.message(_("No further redo information")); cur.message(_("No further redo information"));
updateFlags = Update::None;
}
break; break;
case LFUN_FONT_STATE: case LFUN_FONT_STATE:
@ -945,7 +939,6 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
theLyXFunc().dispatch(FuncRequest( theLyXFunc().dispatch(FuncRequest(
LFUN_BUFFER_SWITCH, b->absFileName())); LFUN_BUFFER_SWITCH, b->absFileName()));
theLyXFunc().dispatch(cmd); theLyXFunc().dispatch(cmd);
updateFlags = Update::None;
} }
break; break;
} }
@ -1175,13 +1168,14 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_); d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
//FIXME: what to do with cur.x_target()? //FIXME: what to do with cur.x_target()?
cur.finishUndo(); cur.finishUndo();
// The metrics are already up to date. see scroll()
updateFlags = Update::None;
break; break;
} }
case LFUN_SCREEN_UP_SELECT: case LFUN_SCREEN_UP_SELECT:
case LFUN_SCREEN_DOWN_SELECT: { case LFUN_SCREEN_DOWN_SELECT: {
// Those two are not ready yet for consumption.
return false;
cur.selHandle(true); cur.selHandle(true);
size_t initial_depth = cur.depth(); size_t initial_depth = cur.depth();
Point const p = getPos(cur, cur.boundary()); Point const p = getPos(cur, cur.boundary());
@ -1197,15 +1191,14 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
// But no screen update is needed. // But no screen update is needed.
d->update_strategy_ = NoScreenUpdate; d->update_strategy_ = NoScreenUpdate;
buffer_.changed(); buffer_.changed();
updateFlags = Update::Force | Update::FitCursor;
break; break;
} }
default: default:
updateFlags = Update::None; return false;
} }
return updateFlags; return true;
} }

View File

@ -151,8 +151,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.
/// \return the Update::flags for further metrics update. /// \return true if the function has been processed.
Update::flags dispatch(FuncRequest const & argument); bool dispatch(FuncRequest const & argument);
/// request an X11 selection. /// request an X11 selection.
/// \return the selected string. /// \return the selected string.

View File

@ -1744,7 +1744,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
LyX::ref().session().bookmarks().clear(); LyX::ref().session().bookmarks().clear();
break; break;
default: { default:
BOOST_ASSERT(theApp()); BOOST_ASSERT(theApp());
// Let the frontend dispatch its own actions. // Let the frontend dispatch its own actions.
if (theApp()->dispatch(cmd)) if (theApp()->dispatch(cmd))
@ -1759,20 +1759,21 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break; break;
} }
// FIXME: Probably a good idea to inverse the Cursor and BufferView BOOST_ASSERT(lyx_view_->view());
// dispatching. // Let the current BufferView dispatch its own actions.
if (view()->dispatch(cmd)) {
// The BufferView took care of its own updates if needed.
updateFlags = Update::None;
break;
}
// Let the current Cursor dispatch its own actions. // Let the current Cursor dispatch its own actions.
BOOST_ASSERT(lyx_view_->view());
view()->cursor().getPos(cursorPosBeforeDispatchX_, view()->cursor().getPos(cursorPosBeforeDispatchX_,
cursorPosBeforeDispatchY_); cursorPosBeforeDispatchY_);
view()->cursor().dispatch(cmd); view()->cursor().dispatch(cmd);
updateFlags = view()->cursor().result().update(); updateFlags = view()->cursor().result().update();
if (!view()->cursor().result().dispatched()) // Verify that the action has been dispatched.
// Let the current BufferView dispatch its own actions. BOOST_ASSERT(view()->cursor().result().dispatched());
updateFlags = view()->dispatch(cmd);
break;
}
} }
if (lyx_view_ && lyx_view_->buffer()) { if (lyx_view_ && lyx_view_->buffer()) {

View File

@ -486,6 +486,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
} else { } else {
cur.undispatched(); cur.undispatched();
} }
cur.updateFlags(Update::FitCursor);
break; break;
case LFUN_BUFFER_END: case LFUN_BUFFER_END:
@ -496,6 +497,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
} else { } else {
cur.undispatched(); cur.undispatched();
} }
cur.updateFlags(Update::FitCursor);
break; break;
case LFUN_CHAR_FORWARD: case LFUN_CHAR_FORWARD: