]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
char * for string literals is deprecated...
[lyx.git] / src / BufferView.cpp
index 2620dd65f730ee44aace1187eaf4a8165c609707..b2e21ba79d2e47f8f6a3b0c839214596863423d3 100644 (file)
@@ -1432,7 +1432,6 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        case LFUN_GRAPHICS_GROUPS_UNIFY: {
                if (cmd.argument().empty())
                        break;
-               //view()->cursor().recordUndoFullDocument(); let inset-apply do that job
                graphics::unifyGraphicsGroups(cur.buffer(), to_utf8(cmd.argument()));
                processUpdateFlags(Update::Force | Update::FitCursor);
                break;
@@ -1441,7 +1440,6 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        case LFUN_NOTES_MUTATE: {
                if (cmd.argument().empty())
                        break;
-               cur.recordUndoFullDocument();
 
                if (mutateNotes(cur, cmd.getArg(0), cmd.getArg(1))) {
                        processUpdateFlags(Update::Force);
@@ -1619,6 +1617,8 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
        // Put anchor at the same position.
        cur.resetAnchor();
 
+       cur.beginUndoGroup();
+
        // Try to dispatch to an non-editable inset near this position
        // via the temp cursor. If the inset wishes to change the real
        // cursor it has to do so explicitly by using
@@ -1631,6 +1631,8 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
        if (!inset || !cur.result().dispatched())
                cur.dispatch(cmd);
 
+       cur.endUndoGroup();
+
        // Notify left insets
        if (cur != old) {
                old.fixIfBroken();
@@ -1742,6 +1744,27 @@ void BufferView::setCursorFromRow(int row)
 }
 
 
+bool BufferView::setCursorFromInset(Inset const * inset)
+{
+       // are we already there?
+       if (cursor().nextInset() == inset)
+               return true;
+
+       // Inset is not at cursor position. Find it in the document.
+       Cursor cur(*this);
+       cur.reset(buffer().inset());
+       do 
+               cur.forwardInset();
+       while (cur && cur.nextInset() != inset);
+
+       if (cur) {
+               setCursor(cur);
+               return true;
+       }
+       return false;
+}
+
+
 void BufferView::gotoLabel(docstring const & label)
 {
        Toc & toc = buffer().tocBackend().toc("label");