]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Fix #10328.
[lyx.git] / src / Text.cpp
index 7c00a6aabef6c827985f839da1279c235badcf0c..e03c2cb57c630edcafd2288c21c4a7ea07394a86 100644 (file)
@@ -37,7 +37,6 @@
 #include "InsetList.h"
 #include "Language.h"
 #include "Layout.h"
-#include "Length.h"
 #include "Lexer.h"
 #include "lyxfind.h"
 #include "LyXRC.h"
@@ -65,6 +64,7 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Length.h"
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
 #include "support/lyxtime.h"
@@ -113,8 +113,7 @@ void breakParagraphConservative(BufferParams const & bparams,
        ParagraphList & pars, pit_type pit, pos_type pos)
 {
        // create a new paragraph
-       Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), pit + 1),
-                                      Paragraph());
+       Paragraph & tmp = *pars.insert(pars.iterator_at(pit + 1), Paragraph());
        Paragraph & par = pars[pit];
 
        tmp.setInsetOwner(&par.inInset());
@@ -169,7 +168,7 @@ void mergeParagraph(BufferParams const & bparams,
        // move the change of the end-of-paragraph character
        par.setChange(par.size(), change);
 
-       pars.erase(lyx::next(pars.begin(), par_offset + 1));
+       pars.erase(pars.iterator_at(par_offset + 1));
 }
 
 
@@ -620,7 +619,8 @@ void Text::readParagraph(Paragraph & par, Lexer & lex,
                }
        }
        // Final change goes to paragraph break:
-       par.setChange(par.size(), change);
+       if (inset().allowMultiPar())
+               par.setChange(par.size(), change);
 
        // Initialize begin_of_body_ on load; redoParagraph maintains
        par.setBeginOfBody();
@@ -691,8 +691,7 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
        ParagraphList & pars = text.paragraphs();
        // create a new paragraph, and insert into the list
        ParagraphList::iterator tmp =
-               pars.insert(lyx::next(pars.begin(), par_offset + 1),
-                           Paragraph());
+               pars.insert(pars.iterator_at(par_offset + 1), Paragraph());
 
        Paragraph & par = pars[par_offset];
 
@@ -1013,11 +1012,11 @@ void Text::insertChar(Cursor & cur, char_type c)
                static docstring const number_operators = from_ascii("+-/*");
                static docstring const number_unary_operators = from_ascii("+-");
 
-               // European Number Separators: comma, dot etc.
+               // Common Number Separators: comma, dot etc.
                // European Number Terminators: percent, permille, degree, euro etc.
                if (cur.current_font.fontInfo().number() == FONT_ON) {
                        if (!isDigitASCII(c) && !contains(number_operators, c) &&
-                           !(isEuropeanNumberSeparator(c) &&
+                           !(isCommonNumberSeparator(c) &&
                              cur.pos() != 0 &&
                              cur.pos() != cur.lastpos() &&
                              tm.displayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
@@ -1042,7 +1041,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                                  ) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
                                                tm.font_);
-                               } else if (isEuropeanNumberSeparator(ch)
+                               } else if (isCommonNumberSeparator(ch)
                                     && cur.pos() >= 2
                                     && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
@@ -1686,10 +1685,7 @@ bool Text::backspacePos0(Cursor & cur)
        if (cur.pit() == 0)
                return false;
 
-       bool needsUpdate = false;
-
        BufferParams const & bufparams = cur.buffer()->params();
-       DocumentClass const & tclass = bufparams.documentClass();
        ParagraphList & plist = cur.text()->paragraphs();
        Paragraph const & par = cur.paragraph();
        Cursor prevcur = cur;
@@ -1701,15 +1697,13 @@ bool Text::backspacePos0(Cursor & cur)
        if (cur.lastpos() == 0
            || (cur.lastpos() == 1 && par.isSeparator(0))) {
                cur.recordUndo(prevcur.pit());
-               plist.erase(lyx::next(plist.begin(), cur.pit()));
-               needsUpdate = true;
+               plist.erase(plist.iterator_at(cur.pit()));
        }
        // is previous par empty?
        else if (prevcur.lastpos() == 0
                 || (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
                cur.recordUndo(prevcur.pit());
-               plist.erase(lyx::next(plist.begin(), prevcur.pit()));
-               needsUpdate = true;
+               plist.erase(plist.iterator_at(prevcur.pit()));
        }
        // FIXME: Do we really not want to allow this???
        // Pasting is not allowed, if the paragraphs have different
@@ -1717,20 +1711,15 @@ bool Text::backspacePos0(Cursor & cur)
        // word processors to allow it. It confuses the user.
        // Correction: Pasting is always allowed with standard-layout
        // or the empty layout.
-       else if (par.layout() == prevpar.layout()
-                || tclass.isDefaultLayout(par.layout())
-                || tclass.isPlainLayout(par.layout())) {
+       else {
                cur.recordUndo(prevcur.pit());
                mergeParagraph(bufparams, plist, prevcur.pit());
-               needsUpdate = true;
        }
 
-       if (needsUpdate) {
-               cur.forceBufferUpdate();
-               setCursorIntern(cur, prevcur.pit(), prevcur.pos());
-       }
+       cur.forceBufferUpdate();
+       setCursorIntern(cur, prevcur.pit(), prevcur.pos());
 
-       return needsUpdate;
+       return true;
 }