]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
Properly restore the file encoding after a LaTeX environment with local scope.
[lyx.git] / src / LyXFunc.cpp
index 905eed98d2559feb14498d0b8832ca6c3b760cd0..0c985b35ec603b3da7ab50e81597fd360f9b921b 100644 (file)
@@ -398,7 +398,22 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
        FuncStatus flag;
 
-       Buffer * buf = lyx_view_ ? lyx_view_->buffer() : 0;
+       /* In LyX/Mac, when a dialog is open, the menus of the
+          application can still be accessed without giving focus to
+          the main window. In this case, we want to disable the menu
+          entries that are buffer or view-related.
+
+          If this code is moved somewhere else (like in
+          GuiView::getStatus), then several functions will not be
+          handled correctly.
+       */
+       frontend::LyXView * lv = 0;
+       Buffer * buf = 0;
+       if (lyx_view_ 
+           && (cmd.origin != FuncRequest::MENU || lyx_view_->hasFocus())) {
+               lv = lyx_view_;
+               buf = lyx_view_->buffer();
+       }
 
        if (cmd.action == LFUN_NOACTION) {
                flag.message(from_utf8(N_("Nothing to do")));
@@ -471,6 +486,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_VC_CHECK_OUT:
                enable = buf->lyxvc().checkOutEnabled();
                break;
+       case LFUN_VC_LOCKING_TOGGLE:
+               enable = !buf->isReadonly() && buf->lyxvc().lockingToggleEnabled();
+               flag.setOnOff(enable && !buf->lyxvc().locker().empty());
+               break;
        case LFUN_VC_REVERT:
                enable = buf->lyxvc().inUse();
                break;
@@ -659,11 +678,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        break;
 
                // Does the view know something?
-               if (!lyx_view_) {
+               if (!lv) {
                        enable = false;
                        break;
                }
-               if (lyx_view_->getStatus(cmd, flag))
+               if (lv->getStatus(cmd, flag))
                        break;
 
                // If we do not have a BufferView, then other functions are disabled
@@ -1045,6 +1064,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
                        break;
 
+               case LFUN_VC_LOCKING_TOGGLE:
+                       LASSERT(lyx_view_ && buffer, /**/);
+                       if (!ensureBufferClean(view()) || buffer->isReadonly())
+                               break;
+                       if (buffer->lyxvc().inUse()) {
+                               string res = buffer->lyxvc().lockingToggle();
+                               if (res.empty())
+                                       frontend::Alert::error(_("Revision control error."),
+                                               _("Error when setting the locking property."));
+                               else {
+                                       setMessage(from_utf8(res));
+                                       reloadBuffer();
+                               }
+                       }
+                       break;
+
                case LFUN_VC_REVERT:
                        LASSERT(lyx_view_ && buffer, /**/);
                        buffer->lyxvc().revert();
@@ -1532,6 +1567,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
 
                case LFUN_LYXRC_APPLY: {
+                       // reset active key sequences, since the bindings
+                       // are updated (bug 6064)
+                       keyseq.reset();
                        LyXRC const lyxrc_orig = lyxrc;
 
                        istringstream ss(argument);
@@ -1688,7 +1726,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        // processKeySym to avoid another redraw just for a
                        // changed inline completion
                        if (cmd.origin == FuncRequest::KEYBOARD) {
-                               if (cmd.action == LFUN_SELF_INSERT)
+                               if (cmd.action == LFUN_SELF_INSERT
+                                   || (cmd.action == LFUN_ERT_INSERT && view()->cursor().inMathed()))
                                        lyx_view_->updateCompletion(view()->cursor(), true, true);
                                else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
                                        lyx_view_->updateCompletion(view()->cursor(), false, true);