]> git.lyx.org Git - features.git/commitdiff
* LyXFunc::dispatch(): invert BufferView::dispatch() and cursor::dispatch() calling.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 21 Dec 2007 10:42:59 +0000 (10:42 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 21 Dec 2007 10:42:59 +0000 (10:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22227 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/LyXFunc.cpp
src/Text3.cpp

index 31486b3ab9775f7760f66ed978f6664dd437b262..ab48279daf02a4ffdff624ff775627707fde5664 100644 (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;
 
@@ -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;
 }
 
 
index c6c045a0082384c85bafd991015b99e5c6261b9b..f518f0026ad99f4660288c281a3122b4a1238aa3 100644 (file)
@@ -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.
index d4536dbc7065328a164e4777258619e426e7fc17..bc3bd66ea3a10b769f4109450fc3376021af797e 100644 (file)
@@ -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()) {
index 5e7bf51c7f9eb63584f914304b1de7ec2204c15c..58aaddad90ba04b2058866223d93fce152cd3df2 100644 (file)
@@ -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: