]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Provide proper fallback if a bibliography processor is not found
[lyx.git] / src / Text.cpp
index b38620545d4754dab88ec681be892e2137b8ea65..8337e6db4f9bacf13809d626aed7aa90bd9c23d8 100644 (file)
@@ -693,6 +693,7 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
 
                tmp->params().depth(par.params().depth());
                tmp->params().noindent(par.params().noindent());
+               tmp->params().spacing(par.params().spacing());
 
                // move everything behind the break position
                // to the new paragraph
@@ -866,8 +867,8 @@ void Text::insertStringAsLines(Cursor & cur, docstring const & str,
                                ++pos;
                                space_inserted = true;
                        }
-               } else if (!isPrintable(*cit)) {
-                       // Ignore unprintables
+               } else if (!isPrintable(*cit) && *cit != 0x200c) {
+                       // Ignore unprintables, except for ZWNJ (0x200c)
                        continue;
                } else {
                        // just insert the character
@@ -968,14 +969,19 @@ void Text::insertChar(Cursor & cur, char_type c)
        if (lyxrc.auto_number) {
                static docstring const number_operators = from_ascii("+-/*");
                static docstring const number_unary_operators = from_ascii("+-");
-               static docstring const number_separators = from_ascii(".,:");
 
+               // 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) &&
-                           !(contains(number_separators, c) &&
+                           !(isCommonNumberSeparator(c) &&
                              cur.pos() != 0 &&
                              cur.pos() != cur.lastpos() &&
                              tm.displayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
+                             tm.displayFont(pit, cur.pos() - 1).fontInfo().number() == FONT_ON) &&
+                           !(isEuropeanNumberTerminator(c) &&
+                             cur.pos() != 0 &&
+                             tm.displayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
                              tm.displayFont(pit, cur.pos() - 1).fontInfo().number() == FONT_ON)
                           )
                                number(cur); // Set current_font.number to OFF
@@ -993,7 +999,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                                  ) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
                                                tm.font_);
-                               } else if (contains(number_separators, c)
+                               } else if (isCommonNumberSeparator(c)
                                     && cur.pos() >= 2
                                     && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
@@ -1476,7 +1482,7 @@ void Text::deleteWordForward(Cursor & cur, bool const force)
                cursorForwardOneWord(cur);
                cur.setSelection();
                if (force || !cur.confirmDeletion()) {
-                       cutSelection(cur, true, false);
+                       cutSelection(cur, false);
                        cur.checkBufferStructure();
                }
        }
@@ -1494,7 +1500,7 @@ void Text::deleteWordBackward(Cursor & cur, bool const force)
                cursorBackwardOneWord(cur);
                cur.setSelection();
                if (force || !cur.confirmDeletion()) {
-                       cutSelection(cur, true, false);
+                       cutSelection(cur, false);
                        cur.checkBufferStructure();
                }
        }
@@ -1892,7 +1898,7 @@ bool Text::read(Lexer & lex,
 }
 
 
-// Returns the current font and depth as a message.
+// Returns the current state (font, depth etc.) as a message for status bar.
 docstring Text::currentState(Cursor const & cur, bool devel_mode) const
 {
        LBUFERR(this == cur.text());
@@ -1922,7 +1928,7 @@ docstring Text::currentState(Cursor const & cur, bool devel_mode) const
        os << bformat(_("Font: %1$s"), font.stateText(&buf.params()));
 
        // The paragraph depth
-       int depth = cur.paragraph().getDepth();
+       int depth = par.getDepth();
        if (depth > 0)
                os << bformat(_(", Depth: %1$d"), depth);
 
@@ -1950,6 +1956,11 @@ docstring Text::currentState(Cursor const & cur, bool devel_mode) const
                }
        }
 
+       // Custom text style
+       InsetLayout const & layout = cur.inset().getLayout();
+       if (layout.lyxtype() == InsetLayout::CHARSTYLE)
+               os << _(", Style: ") << translateIfPossible(layout.labelstring());
+
        if (devel_mode) {
                os << _(", Inset: ") << &cur.inset();
                os << _(", Paragraph: ") << cur.pit();
@@ -2036,7 +2047,7 @@ docstring Text::getPossibleLabel(Cursor const & cur) const
        // We need a unique label
        docstring label = text;
        int i = 1;
-       while (cur.buffer()->insetLabel(label)) {
+       while (cur.buffer()->activeLabel(label)) {
                        label = text + '-' + convert<docstring>(i);
                        ++i;
                }