From: Abdelrazak Younes Date: Fri, 21 Dec 2007 10:42:59 +0000 (+0000) Subject: * LyXFunc::dispatch(): invert BufferView::dispatch() and cursor::dispatch() calling. X-Git-Tag: 1.6.10~6865 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=96d2d6fc50c6efc735650839bbe41f12e10b49cc;p=features.git * 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 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 31486b3ab9..ab48279daf 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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; @@ -874,27 +874,21 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) << " 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: @@ -945,7 +939,6 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) theLyXFunc().dispatch(FuncRequest( LFUN_BUFFER_SWITCH, b->absFileName())); theLyXFunc().dispatch(cmd); - updateFlags = Update::None; } break; } @@ -1175,13 +1168,14 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) 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()); @@ -1197,15 +1191,14 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) // 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; } diff --git a/src/BufferView.h b/src/BufferView.h index c6c045a008..f518f0026a 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -151,8 +151,8 @@ public: /// return true for events that will handle. FuncStatus getStatus(FuncRequest const & cmd); /// execute the given function. - /// \return the Update::flags for further metrics update. - Update::flags dispatch(FuncRequest const & argument); + /// \return true if the function has been processed. + bool dispatch(FuncRequest const & argument); /// request an X11 selection. /// \return the selected string. diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index d4536dbc70..bc3bd66ea3 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1744,7 +1744,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) LyX::ref().session().bookmarks().clear(); break; - default: { + default: BOOST_ASSERT(theApp()); // Let the frontend dispatch its own actions. if (theApp()->dispatch(cmd)) @@ -1759,20 +1759,21 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - // FIXME: Probably a good idea to inverse the Cursor and BufferView - // dispatching. + BOOST_ASSERT(lyx_view_->view()); + // 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. - BOOST_ASSERT(lyx_view_->view()); view()->cursor().getPos(cursorPosBeforeDispatchX_, cursorPosBeforeDispatchY_); view()->cursor().dispatch(cmd); updateFlags = view()->cursor().result().update(); - if (!view()->cursor().result().dispatched()) - // Let the current BufferView dispatch its own actions. - updateFlags = view()->dispatch(cmd); - break; - } + // Verify that the action has been dispatched. + BOOST_ASSERT(view()->cursor().result().dispatched()); } if (lyx_view_ && lyx_view_->buffer()) { diff --git a/src/Text3.cpp b/src/Text3.cpp index 5e7bf51c7f..58aaddad90 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -486,6 +486,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } else { cur.undispatched(); } + cur.updateFlags(Update::FitCursor); break; case LFUN_BUFFER_END: @@ -496,6 +497,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } else { cur.undispatched(); } + cur.updateFlags(Update::FitCursor); break; case LFUN_CHAR_FORWARD: