]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Fix broken layout file syntax
[lyx.git] / src / BufferView.cpp
index ff8482d81a42ea33fda8761082198df940fa65df..31c95cf764e0803ebe061c6e840bb37c6226e35e 100644 (file)
@@ -105,6 +105,7 @@ T * getInsetByCode(Cursor const & cur, InsetCode code)
        return 0;
 }
 
+
 /// Note that comparing contents can only be used for InsetCommand
 bool findNextInset(DocIterator & dit, vector<InsetCode> const & codes,
        docstring const & contents)
@@ -1188,8 +1189,13 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        // handle their dispatch here, for reasons explained there, so we'll
        // handle this here, too, for consistency.
        case LFUN_BRANCH_ACTIVATE:
-       case LFUN_BRANCH_DEACTIVATE: {
-               BranchList const & branchList = buffer().params().branchlist();
+       case LFUN_BRANCH_DEACTIVATE:
+       case LFUN_BRANCH_MASTER_ACTIVATE:
+       case LFUN_BRANCH_MASTER_DEACTIVATE: {
+               bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
+                                   || cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+               BranchList const & branchList = master ? buffer().masterBuffer()->params().branchlist()
+                                                      : buffer().params().branchlist();
                docstring const branchName = cmd.argument();
                flag.setEnabled(!branchName.empty() && branchList.find(branchName));
                break;
@@ -1218,14 +1224,7 @@ void BufferView::editInset(string const & name, Inset * inset)
 
 void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 {
-       //lyxerr << [ cmd = " << cmd << "]" << endl;
-
-       // Make sure that the cached BufferView is correct.
-       LYXERR(Debug::ACTION, " action[" << cmd.action() << ']'
-               << " arg[" << to_utf8(cmd.argument()) << ']'
-               << " x[" << cmd.x() << ']'
-               << " y[" << cmd.y() << ']'
-               << " button[" << cmd.button() << ']');
+       LYXERR(Debug::ACTION, "BufferView::dispatch: cmd: " << cmd);
 
        string const argument = to_utf8(cmd.argument());
        Cursor & cur = d->cursor_;
@@ -1243,7 +1242,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        switch (act) {
 
        case LFUN_BUFFER_PARAMS_APPLY: {
-               DocumentClassConstPtr oldClass = buffer_.params().documentClassPtr();
+               DocumentClassConstPtr olddc = buffer_.params().documentClassPtr();
                cur.recordUndoFullDocument();
                istringstream ss(to_utf8(cmd.argument()));
                Lexer lex;
@@ -1254,7 +1253,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                                << unknown_tokens << " unknown token"
                                                << (unknown_tokens == 1 ? "" : "s"));
                }
-               updateDocumentClass(oldClass);
+               updateDocumentClass(olddc);
                        
                // We are most certainly here because of a change in the document
                // It is then better to make sure that all dialogs are in sync with
@@ -1976,15 +1975,21 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        // So, if this does get fixed, this code can be moved back to Buffer.cpp,
        // and the corresponding code in getStatus() should be moved back, too.
        case LFUN_BRANCH_ACTIVATE:
-       case LFUN_BRANCH_DEACTIVATE: {
-               BranchList & branch_list = buffer().params().branchlist();
+       case LFUN_BRANCH_DEACTIVATE:
+       case LFUN_BRANCH_MASTER_ACTIVATE:
+       case LFUN_BRANCH_MASTER_DEACTIVATE: {
+               bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
+                                    || cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+               Buffer * buf = master ? const_cast<Buffer *>(buffer().masterBuffer())
+                                     : &buffer();
+
                docstring const branch_name = cmd.argument();
                // the case without a branch name is handled elsewhere
                if (branch_name.empty()) {
                        dispatched = false;
                        break;
                }
-               Branch * branch = branch_list.find(branch_name);
+               Branch * branch = buf->params().branchlist().find(branch_name);
                if (!branch) {
                        LYXERR0("Branch " << branch_name << " does not exist.");
                        dr.setError(true);
@@ -1993,7 +1998,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        dr.setMessage(msg);
                        break;
                }
-               bool activate = cmd.action() == LFUN_BRANCH_ACTIVATE;
+               bool activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
+                                || cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE);
                if (branch->isSelected() != activate) {
                        branch->setSelected(activate);
                        cur.recordUndoFullDocument();
@@ -2449,6 +2455,8 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
                cap::saveSelection(cursor());
 
        d->cursor_.macroModeClose();
+       // If a macro has been finalized, the cursor might have been broken
+       cur.fixIfBroken();
 
        // Has the cursor just left the inset?
        bool const leftinset = (&d->cursor_.inset() != &cur.inset());