]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Fix typo for r30882.
[lyx.git] / src / BufferView.cpp
index 3be5cf7cf283969c8408786d61bc1f72416c5880..8b720ba6df2aa0be781832831bb2e47f2ecf7142 100644 (file)
@@ -935,6 +935,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        case LFUN_NOTES_MUTATE:
        case LFUN_ALL_INSETS_TOGGLE:
        case LFUN_STATISTICS:
+       case LFUN_BRANCH_ADD_INSERT:
                flag.setEnabled(true);
                break;
 
@@ -1018,10 +1019,12 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
 
        case LFUN_DIALOG_SHOW_NEW_INSET:
+               // FIXME: this is wrong, but I do not understand the
+               // intent (JMarc)
                if (cur.inset().lyxCode() == CAPTION_CODE)
                        return cur.inset().getStatus(cur, cmd, flag);
-               flag.setEnabled(cur.inset().lyxCode() != ERT_CODE &&
-                       cur.inset().lyxCode() != LISTINGS_CODE);
+               // FIXME we should consider passthru paragraphs too.
+               flag.setEnabled(!cur.inset().getLayout().isPassThru());
                break;
 
        default:
@@ -1504,6 +1507,29 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
        }
 
+       case LFUN_BRANCH_ADD_INSERT: {
+               docstring branch_name = from_utf8(cmd.getArg(0));
+               if (branch_name.empty())
+                       if (!Alert::askForText(branch_name, _("Branch name")) ||
+                                               branch_name.empty())
+                               break;
+
+               DispatchResult drtmp;
+               buffer_.dispatch(FuncRequest(LFUN_BRANCH_ADD, branch_name), drtmp);
+               if (drtmp.error()) {
+                       Alert::warning(_("Branch already exists"), drtmp.message());
+                       break;
+               }
+               BranchList & branch_list = buffer_.params().branchlist();
+               Branch const * branch = branch_list.find(branch_name);
+               string const x11hexname = X11hexname(branch->color());
+               docstring const str = branch_name + ' ' + from_ascii(x11hexname);
+               lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
+               lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
+               break;
+       }
+
+
        default:
                return false;
        }
@@ -1920,6 +1946,7 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
                update |= checkDepm(cur, d->cursor_);
        d->cursor_.macroModeClose();
 
+       d->cursor_.resetAnchor();
        d->cursor_.setCursor(cur);
        d->cursor_.boundary(cur.boundary());
        if (do_selection)