]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
* GuiDocument.cpp:
[lyx.git] / src / BufferView.cpp
index e646e2265aa8a4683eb00e799b46536f1c209f2e..936dcffc9af6abe4442a3c424506bd7030a23eef 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;
 
@@ -1411,8 +1412,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                        p = getPos(cur, cur.boundary());
                }*/
                int const scrolled = scroll(cmd.action == LFUN_SCREEN_UP
-                       ? - height_ : height_);
-               if (cmd.action == LFUN_SCREEN_UP && scrolled > - height_)
+                       ? -height_ : height_);
                if (cmd.action == LFUN_SCREEN_UP && scrolled > -height_)
                        p = Point(0, 0);
                if (cmd.action == LFUN_SCREEN_DOWN && scrolled < height_)
@@ -1422,7 +1422,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                cur.reset(buffer_.inset());
                updateMetrics();
                buffer_.changed();
-               d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
+               d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
+                       true, cmd.action == LFUN_SCREEN_UP); 
                //FIXME: what to do with cur.x_target()?
                bool update = in_texted && cur.bv().checkDepm(cur, old);
                cur.finishUndo();
@@ -1504,6 +1505,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 +1944,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)