]> git.lyx.org Git - features.git/blobdiff - src/Text.cpp
Fix bug #11102.
[features.git] / src / Text.cpp
index e1c37faf3ab2700376d70f2d2f2e0ca2b4e3fc8a..3de796442c285b89255a3428809b0ed0972c7e78 100644 (file)
@@ -933,15 +933,12 @@ bool canInsertChar(Cursor const & cur, char_type c)
                }
        }
 
-       // Prevent to insert uncodable characters in verbatim and ERT
-       // (workaround for bug 9012)
-       // Don't do it for listings inset, since InsetListings::latex() tries
-       // to switch to a usable encoding which works in many cases (bug 9102).
-       if (par.isPassThru() && cur.inset().lyxCode() != LISTINGS_CODE &&
-           cur.current_font.language()) {
-               Encoding const * e = cur.current_font.language()->encoding();
+       // Prevent to insert uncodable characters in verbatim and ERT.
+       // The encoding is inherited from the context here.
+       if (par.isPassThru() && cur.getEncoding()) {
+               Encoding const * e = cur.getEncoding();
                if (!e->encodable(c)) {
-                       cur.message(_("Character is uncodable in verbatim paragraphs."));
+                       cur.message(_("Character is uncodable in this verbatim context."));
                        return false;
                }
        }
@@ -987,8 +984,8 @@ void Text::insertChar(Cursor & cur, char_type c)
                        number(cur); // Set current_font.number to ON
 
                        if (cur.pos() != 0) {
-                               char_type const c = par.getChar(cur.pos() - 1);
-                               if (contains(number_unary_operators, c) &&
+                               char_type const ch = par.getChar(cur.pos() - 1);
+                               if (contains(number_unary_operators, ch) &&
                                    (cur.pos() == 1
                                     || par.isSeparator(cur.pos() - 2)
                                     || par.isEnvSeparator(cur.pos() - 2)
@@ -996,7 +993,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 (contains(number_separators, ch)
                                     && cur.pos() >= 2
                                     && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
@@ -1896,7 +1893,7 @@ bool Text::read(Lexer & lex,
 
 
 // Returns the current font and depth as a message.
-docstring Text::currentState(Cursor const & cur, bool devel_mode) const
+docstring Text::currentState(CursorData const & cur, bool devel_mode) const
 {
        LBUFERR(this == cur.text());
        Buffer & buf = *cur.buffer();
@@ -1955,6 +1952,8 @@ docstring Text::currentState(Cursor const & cur, bool devel_mode) const
 
        if (devel_mode) {
                os << _(", Inset: ") << &cur.inset();
+               if (cur.lastidx() > 0)
+                       os << _(", Cell: ") << cur.idx();
                os << _(", Paragraph: ") << cur.pit();
                os << _(", Id: ") << par.id();
                os << _(", Position: ") << cur.pos();
@@ -1973,14 +1972,14 @@ docstring Text::currentState(Cursor const & cur, bool devel_mode) const
 }
 
 
-docstring Text::getPossibleLabel(Cursor const & cur) const
+docstring Text::getPossibleLabel(DocIterator const & cur) const
 {
        pit_type pit = cur.pit();
 
        Layout const * layout = &(pars_[pit].layout());
 
        docstring text;
-       docstring par_text = pars_[pit].asString();
+       docstring par_text = pars_[pit].asString(AS_STR_SKIPDELETE);
 
        // The return string of math matrices might contain linebreaks
        par_text = subst(par_text, '\n', '-');