]> git.lyx.org Git - features.git/commitdiff
Fix Settings entry for space insets.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 13 May 2008 14:44:53 +0000 (14:44 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 13 May 2008 14:44:53 +0000 (14:44 +0000)
* inset/inset.cpp (doDispatch, getStatus): handle LFUN_INSET_TOGGLE.

* BufferView.cpp (getStatus): cleanup
(dispatch): do not call Inset::edit() explicitely.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24752 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/insets/Inset.cpp

index 345d94a830cb532fada2b5f13351edeac3068e3b..4ce8ddb0a2f8e5cff581e2d28807e4ed868aec71 100644 (file)
@@ -870,10 +870,9 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
        case LFUN_NEXT_INSET_TOGGLE: 
        case LFUN_NEXT_INSET_MODIFY: {
                // this is the real function we want to invoke
-               FuncCode const code = 
-                       (cmd.action == LFUN_NEXT_INSET_TOGGLE) 
+               FuncRequest tmpcmd = cmd;
+               tmpcmd.action = (cmd.action == LFUN_NEXT_INSET_TOGGLE) 
                        ? LFUN_INSET_TOGGLE : LFUN_INSET_MODIFY;
-               FuncRequest const tmpcmd = FuncRequest(code, cmd.argument());
                // if there is an inset at cursor, see whether it
                // handles the lfun, other start from scratch
                Inset * inset = cur.nextInset();
@@ -1279,8 +1278,9 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
        
        case LFUN_NEXT_INSET_TOGGLE: {
-               // this is the real function we want to invoke
-               FuncRequest tmpcmd = FuncRequest(LFUN_INSET_TOGGLE, cmd.origin);
+               // create the the real function we want to invoke
+               FuncRequest tmpcmd = cmd;
+               tmpcmd.action = LFUN_INSET_TOGGLE;
                // if there is an inset at cursor, see whether it
                // wants to toggle.
                Inset * inset = cur.nextInset();
@@ -1289,12 +1289,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                                Cursor tmpcur = cur;
                                tmpcur.pushBackward(*inset);
                                inset->dispatch(tmpcur, tmpcmd);
-                               if (tmpcur.result().dispatched()) {
+                               if (tmpcur.result().dispatched())
                                        cur.dispatched();
-                               }
-                       } else if (inset->editable() == Inset::IS_EDITABLE) {
-                               inset->edit(cur, true);
-                       }
+                       } else 
+                               inset->dispatch(cur, tmpcmd);
                }
                // if it did not work, try the underlying inset.
                if (!inset || !cur.result().dispatched())
@@ -1309,8 +1307,9 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_NEXT_INSET_MODIFY: {
-               // this is the real function we want to invoke
-               FuncRequest tmpcmd = FuncRequest(LFUN_INSET_MODIFY, cmd.argument());
+               // create the the real function we want to invoke
+               FuncRequest tmpcmd = cmd;
+               tmpcmd.action = LFUN_INSET_MODIFY;
                // if there is an inset at cursor, see whether it
                // can be modified.
                Inset * inset = cur.nextInset();
index f268735a7e0c0dfcd63b5b4f8a27d39760bb3cbe..b16dfb57acbfd3c28029b2dc28b36c484fd028fb 100644 (file)
@@ -210,10 +210,18 @@ void Inset::dispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
-void Inset::doDispatch(Cursor & cur, FuncRequest &)
+void Inset::doDispatch(Cursor & cur, FuncRequest &cmd)
 {
-       cur.noUpdate();
-       cur.undispatched();
+       switch (cmd.action) {
+       case LFUN_INSET_TOGGLE:
+               edit(cur, true);
+               cur.dispatched();
+               break;
+       default:
+               cur.noUpdate();
+               cur.undispatched();
+               break;
+       }
 }
 
 
@@ -243,9 +251,15 @@ bool Inset::getStatus(Cursor &, FuncRequest const & cmd,
                flag.enabled(false);
                return true;
 
+       case LFUN_INSET_TOGGLE:
+               // remove this if we dissociate toggle from edit.
+               flag.enabled(editable() == IS_EDITABLE);
+               return true;
+
        default:
-               return false;
+               break;
        }
+       return false;
 }