]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
Paragraph:
[lyx.git] / src / LyXFunc.cpp
index 6e9aa55af5a9329ee4e0f7edb13a839e848df3cc..5fb648e05142531e7dd13e86c372a02e6e3c7f01 100644 (file)
@@ -458,7 +458,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
 
        case LFUN_VC_REGISTER:
-               enable = !buf->lyxvc().inUse();
+               enable = !buf->lyxvc().inUse() && !buf->isUnnamed();
                break;
        case LFUN_VC_CHECK_IN:
                enable = buf->lyxvc().checkInEnabled();
@@ -533,6 +533,23 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
        }
 
+       // we want to check if at least one of these is enabled
+       case LFUN_COMMAND_ALTERNATIVES: {
+               // argument contains ';'-terminated commands
+               string arg = to_utf8(cmd.argument());
+               while (!arg.empty()) {
+                       string first;
+                       arg = split(arg, first, ';');
+                       FuncRequest func(lyxaction.lookupFunc(first));
+                       func.origin = cmd.origin;
+                       flag = getStatus(func);
+                       // if this one is enabled, the whole thing is
+                       if (flag.enabled())
+                               break;
+               }
+               break;
+       }
+
        case LFUN_CALL: {
                FuncRequest func;
                string name = to_utf8(cmd.argument());
@@ -731,6 +748,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                       << lyxaction.getActionName(action)
                       << " [" << action << "] is disabled at this location");
                setErrorMessage(flag.message());
+               if (lyx_view_)
+                       lyx_view_->restartCursor();
        } else {
                switch (action) {
 
@@ -1037,7 +1056,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                // --- version control -------------------------------
                case LFUN_VC_REGISTER:
                        LASSERT(lyx_view_ && lyx_view_->buffer(), /**/);
-                       if (!ensureBufferClean(view()))
+                       if (!ensureBufferClean(view()) || lyx_view_->buffer()->isUnnamed())
                                break;
                        if (!lyx_view_->buffer()->lyxvc().inUse()) {
                                lyx_view_->buffer()->lyxvc().registrer();
@@ -1344,6 +1363,23 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
                }
 
+               case LFUN_COMMAND_ALTERNATIVES: {
+                       // argument contains ';'-terminated commands
+                       string arg = argument;
+                       while (!arg.empty()) {
+                               string first;
+                               arg = split(arg, first, ';');
+                               FuncRequest func(lyxaction.lookupFunc(first));
+                               func.origin = cmd.origin;
+                               FuncStatus stat = getStatus(func);
+                               if (stat.enabled()) {
+                                       dispatch(func);
+                                       break;
+                               }
+                       }
+                       break;
+               }
+
                case LFUN_CALL: {
                        FuncRequest func;
                        if (theTopLevelCmdDef().lock(argument, func)) {
@@ -1561,18 +1597,27 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (lyx_view_ == 0)
                                break;
 
+                       // Start an undo group. This may be needed for
+                       // some stuff like inset-apply on labels.
+                       if (lyx_view_->view())
+                               view()->cursor().beginUndoGroup();
+                               
                        // Let the current LyXView dispatch its own actions.
                        if (lyx_view_->dispatch(cmd)) {
-                               if (lyx_view_->view())
+                               if (lyx_view_->view()) {
                                        updateFlags = lyx_view_->view()->cursor().result().update();
+                                       view()->cursor().endUndoGroup();
+                               }
                                break;
                        }
 
                        LASSERT(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;
+                               view()->cursor().endUndoGroup();
                                break;
                        }
 
@@ -1590,6 +1635,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                        view()->cursor().fixIfBroken();
                        }
 
+                       // we assume here that the buffer view has not
+                       // changed since the beginUndoGroup.
+                       view()->cursor().endUndoGroup();
+
                        // update completion. We do it here and not in
                        // processKeySym to avoid another redraw just for a
                        // changed inline completion
@@ -1826,6 +1875,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_FORMAT:
        case LyXRC::RC_GROUP_LAYOUTS:
        case LyXRC::RC_INDEX_COMMAND:
+       case LyXRC::RC_NOMENCL_COMMAND:
        case LyXRC::RC_INPUT:
        case LyXRC::RC_KBMAP:
        case LyXRC::RC_KBMAP_PRIMARY: