]> git.lyx.org Git - features.git/commitdiff
GuiView::dispatchToBufferView(): simplify code and move some to Cursor::dispatch().
authorAbdelrazak Younes <younes@lyx.org>
Sun, 5 Dec 2010 00:57:04 +0000 (00:57 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 5 Dec 2010 00:57:04 +0000 (00:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36733 a592a061-630c-0410-9148-cb99ea01b6c8

src/Cursor.cpp
src/frontends/qt4/GuiView.cpp

index c96762d5f774e79e9c11ffecac87b1bf5d5a61c6..d504670fa7fedb726d98df8b6ad5f57fc7bf0ac6 100644 (file)
@@ -333,6 +333,7 @@ void Cursor::dispatch(FuncRequest const & cmd0)
        fixIfBroken();
        FuncRequest cmd = cmd0;
        Cursor safe = *this;
+       Cursor old = *this;
        disp_ = DispatchResult();
 
        buffer()->undo().beginUndoGroup();
@@ -393,6 +394,18 @@ void Cursor::dispatch(FuncRequest const & cmd0)
                beforeDispatchCursor_ = safe.beforeDispatchCursor_;
        }
        buffer()->undo().endUndoGroup();
+
+       // notify insets we just left
+       if (*this != old) {
+               old.beginUndoGroup();
+               old.fixIfBroken();
+               bool badcursor = notifyCursorLeavesOrEnters(old, *this);
+               if (badcursor) {
+                       fixIfBroken();
+                       bv().fixInlineCompletionPos();
+               }
+               old.endUndoGroup();
+       }
 }
 
 
index a2626a2f0ffae77e3e1cd01cdec7978cf69cd2dd..d2fc7b04fabf4c233a62e14471bf048d242aed41 100644 (file)
@@ -3026,53 +3026,46 @@ void GuiView::dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr)
 
        // Let the current BufferView dispatch its own actions.
        bv->dispatch(cmd, dr);
+       if (dr.dispatched())
+               return;
 
        // Try with the document BufferView dispatch if any.
        BufferView * doc_bv = documentBufferView();
-       if (doc_bv && !dr.dispatched())
-                       doc_bv->dispatch(cmd, dr);
+       if (doc_bv) {
+               doc_bv->dispatch(cmd, dr);
+               if (dr.dispatched())
+                       return;
+       }
 
        // OK, so try the current Buffer itself...
-       if (!dr.dispatched())
-               bv->buffer().dispatch(cmd, dr);
+       bv->buffer().dispatch(cmd, dr);
+       if (dr.dispatched())
+               return;
 
        // and with the document Buffer.
-       if (doc_bv && !dr.dispatched())
+       if (doc_bv) {
                doc_bv->buffer().dispatch(cmd, dr);
+               if (dr.dispatched())
+                       return;
+       }
 
        // Then let the current Cursor dispatch its own actions.
-       if (!dr.dispatched()) {
-               Cursor old = bv->cursor();
-               bv->cursor().dispatch(cmd);
-
-               // notify insets we just left
-               // FIXME: move this code to Cursor::dispatch
-               if (bv->cursor() != old) {
-                       old.beginUndoGroup();
-                       old.fixIfBroken();
-                       bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
-                       if (badcursor) {
-                               bv->cursor().fixIfBroken();
-                               bv->fixInlineCompletionPos();
-                       }
-                       old.endUndoGroup();
-               }
-
-               // update completion. We do it here and not in
-               // processKeySym to avoid another redraw just for a
-               // changed inline completion
-               if (cmd.origin() == FuncRequest::KEYBOARD) {
-                       if (cmd.action() == LFUN_SELF_INSERT
-                               || (cmd.action() == LFUN_ERT_INSERT && bv->cursor().inMathed()))
-                               updateCompletion(bv->cursor(), true, true);
-                       else if (cmd.action() == LFUN_CHAR_DELETE_BACKWARD)
-                               updateCompletion(bv->cursor(), false, true);
-                       else
-                               updateCompletion(bv->cursor(), false, false);
-               }
-
-               dr = bv->cursor().result();
+       bv->cursor().dispatch(cmd);
+
+       // update completion. We do it here and not in
+       // processKeySym to avoid another redraw just for a
+       // changed inline completion
+       if (cmd.origin() == FuncRequest::KEYBOARD) {
+               if (cmd.action() == LFUN_SELF_INSERT
+                       || (cmd.action() == LFUN_ERT_INSERT && bv->cursor().inMathed()))
+                       updateCompletion(bv->cursor(), true, true);
+               else if (cmd.action() == LFUN_CHAR_DELETE_BACKWARD)
+                       updateCompletion(bv->cursor(), false, true);
+               else
+                       updateCompletion(bv->cursor(), false, false);
        }
+
+       dr = bv->cursor().result();
 }