]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
LFUN_UNICODE_INSERT - unicode-insert
[lyx.git] / src / CutAndPaste.C
index 54595d67ec33375f2a57ebc8570b127602f9c745..9e0b9c17fd6803609f2775919c5a6ffe6cafa96c 100644 (file)
@@ -147,7 +147,7 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
                        for (pos_type j = 0; j < insertion[i].size(); ++j) {
                                if (insertion[i].isNewline(j)) {
                                        // do not track deletion of newline
-                                       insertion[i].erase(j, false);
+                                       insertion[i].eraseChar(j, false);
                                        breakParagraphConservative(
                                                        buffer.params(),
                                                        insertion, i, j);
@@ -207,7 +207,7 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
                        if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
                            !pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
                                // do not track deletion of invalid insets
-                               tmpbuf->erase(i--, false);
+                               tmpbuf->eraseChar(i--, false);
                }
 
                // FIXME: Change tracking (MG)
@@ -309,7 +309,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
        // Start and end is inside same paragraph
        if (endpit == pit_type(pars.size()) ||
            startpit == endpit) {
-               endpos -= pars[startpit].erase(startpos, endpos);
+               endpos -= pars[startpit].eraseChars(startpos, endpos, false);
                return PitPosPair(endpit, endpos);
        }
 
@@ -325,7 +325,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
                pos_type const right = ( pit == endpit ? endpos :
                                pars[pit].size() + 1 );
                // Logical erase only:
-               pars[pit].erase(left, right);
+               pars[pit].eraseChars(left, right, false);
                // Separate handling of para break:
                if (merge && pit != endpit &&
                   (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
@@ -363,11 +363,13 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
 
        // Cut out the end of the last paragraph.
        Paragraph & back = paragraphs.back();
-       back.erase(end, back.size());
+       // do not track deletion here; it is an internal action not visible to the user
+       back.eraseChars(end, back.size(), false);
 
        // Cut out the begin of the first paragraph
        Paragraph & front = paragraphs.front();
-       front.erase(0, start);
+       // again, do not track deletion
+       front.eraseChars(0, start, false);
 
        theCuts.push(make_pair(paragraphs, tc));
 }
@@ -379,11 +381,11 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
 
 namespace cap {
 
-string grabAndEraseSelection(LCursor & cur)
+docstring grabAndEraseSelection(LCursor & cur)
 {
        if (!cur.selection())
-               return string();
-       string res = grabSelection(cur);
+               return docstring();
+       docstring res = grabSelection(cur);
        eraseSelection(cur);
        return res;
 }
@@ -684,7 +686,7 @@ void replaceSelectionWithString(LCursor & cur, string const & str, bool backward
        // select the replacement
        if (backwards) {
                selbeg.pos() += str.length();
-               cur.setSelection(selbeg, -str.length());
+               cur.setSelection(selbeg, -int(str.length()));
        } else
                cur.setSelection(selbeg, str.length());
 }
@@ -748,10 +750,10 @@ void selClearOrDel(LCursor & cur)
 }
 
 
-string grabSelection(LCursor const & cur)
+docstring grabSelection(LCursor const & cur)
 {
        if (!cur.selection())
-               return string();
+               return docstring();
 
        // FIXME: What is wrong with the following?
 #if 0
@@ -770,7 +772,7 @@ string grabSelection(LCursor const & cur)
                        MathArray::const_iterator it = i1.cell().begin();
                        return asString(MathArray(it + i1.pos(), it + i2.pos()));
                } else {
-                       return "unknown selection 1";
+                       return from_ascii("unknown selection 1");
                }
        }
 
@@ -778,7 +780,7 @@ string grabSelection(LCursor const & cur)
        InsetBase::col_type c1, c2;
        region(i1, i2, r1, r2, c1, c2);
 
-       string data;
+       docstring data;
        if (i1.inset().asInsetMath()) {
                for (InsetBase::row_type row = r1; row <= r2; ++row) {
                        if (row > r1)
@@ -791,7 +793,7 @@ string grabSelection(LCursor const & cur)
                        }
                }
        } else {
-               data = "unknown selection 2";
+               data = from_ascii("unknown selection 2");
        }
        return data;
 }