]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
fix crash in mathhullinset
[lyx.git] / src / text.C
index 5d9aa6f0578d9087a255eb7dd7959b52f1770024..6e0d6ceaee49cf995a902559ce34da6570206d54 100644 (file)
@@ -324,14 +324,14 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                        par.cleanChanges();
                change = Change(Change::UNCHANGED);
        } else if (token == "\\change_inserted") {
-               lex.nextToken();
+               lex.eatLine();
                std::istringstream is(lex.getString());
                int aid;
                lyx::time_type ct;
                is >> aid >> ct;
                change = Change(Change::INSERTED, bp.author_map[aid], ct);
        } else if (token == "\\change_deleted") {
-               lex.nextToken();
+               lex.eatLine();
                std::istringstream is(lex.getString());
                int aid;
                lyx::time_type ct;
@@ -378,7 +378,6 @@ void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
                               << "Missing \\end_layout.\n";
                        break;
                }
-               lyxerr << "Paragraph token unknown: `" << token << '\'' << endl;
        }
 }
 
@@ -610,9 +609,10 @@ int LyXText::leftMargin(par_type const pit, pos_type const pos) const
                   && !isFirstInSequence(pit, pars_)))
            && align == LYX_ALIGN_BLOCK
            && !par.params().noindent()
-           // in tabulars and ert paragraphs are never indented!
+           // in charstyles, tabulars and ert paragraphs are never indented!
            && (par.ownerCode() != InsetBase::TEXT_CODE
-                   && par.ownerCode() != InsetBase::ERT_CODE)
+                   && par.ownerCode() != InsetBase::ERT_CODE
+                   && par.ownerCode() != InsetBase::CHARSTYLE_CODE)
            && (par.layout() != tclass.defaultLayout()
                || bv()->buffer()->params().paragraph_separation ==
                   BufferParams::PARSEP_INDENT))
@@ -626,12 +626,11 @@ int LyXText::leftMargin(par_type const pit, pos_type const pos) const
 
 int LyXText::rightMargin(Paragraph const & par) const
 {
-       LyXTextClass const & tclass = bv()->buffer()->params().getLyXTextClass();
-
        // We do not want rightmargins on inner texts.
        if (bv()->text() != this)
                return 0;
 
+       LyXTextClass const & tclass = bv()->buffer()->params().getLyXTextClass();
        int const r_margin =
                ::rightMargin()
                + font_metrics::signedWidth(tclass.rightmargin(),
@@ -641,7 +640,6 @@ int LyXText::rightMargin(Paragraph const & par) const
                * 4 / (par.getDepth() + 4);
 
        return r_margin;
-
 }
 
 
@@ -1357,10 +1355,10 @@ void LyXText::cursorRightOneWord(LCursor & cur)
        } else {
                // Skip through initial nonword stuff.
                // Treat floats and insets as words.
-               while (cur.pos() != cur.lastpos() && !cur.paragraph().isWord(cur.pos()))
+               while (cur.pos() != cur.lastpos() && !cur.paragraph().isLetter(cur.pos()))
                        ++cur.pos();
                // Advance through word.
-               while (cur.pos() != cur.lastpos() && cur.paragraph().isWord(cur.pos()))
+               while (cur.pos() != cur.lastpos() && cur.paragraph().isLetter(cur.pos()))
                        ++cur.pos();
        }
        setCursor(cur, cur.par(), cur.pos());
@@ -1376,10 +1374,10 @@ void LyXText::cursorLeftOneWord(LCursor & cur)
        } else {
                // Skip through initial nonword stuff.
                // Treat floats and insets as words.
-               while (cur.pos() != 0 && !cur.paragraph().isWord(cur.pos() - 1))
+               while (cur.pos() != 0 && !cur.paragraph().isLetter(cur.pos() - 1))
                        --cur.pos();
                // Advance through word.
-               while (cur.pos() != 0 && cur.paragraph().isWord(cur.pos() - 1))
+               while (cur.pos() != 0 && cur.paragraph().isLetter(cur.pos() - 1))
                        --cur.pos();
        }
        setCursor(cur, cur.par(), cur.pos());
@@ -1633,7 +1631,7 @@ void LyXText::backspace(LCursor & cur)
                    && (pars_[cpit].layout() == pars_[tmppit].layout()
                        || pars_[tmppit].layout() == tclass.defaultLayout())
                    && pars_[cpit].getAlign() == pars_[tmppit].getAlign()) {
-                       mergeParagraph(bufparams, buf.paragraphs(), cpit);
+                       mergeParagraph(bufparams, pars_, cpit);
 
                        if (cur.pos() != 0 && pars_[cpit].isSeparator(cur.pos() - 1))
                                --cur.pos();
@@ -1799,8 +1797,8 @@ void LyXText::getWord(CursorSlice & from, CursorSlice & to,
        switch (loc) {
        case lyx::WHOLE_WORD_STRICT:
                if (from.pos() == 0 || from.pos() == from_par.size()
-                   || !from_par.isWord(from.pos())
-                   || !from_par.isWord(from.pos() - 1)) {
+                   || !from_par.isLetter(from.pos())
+                   || !from_par.isLetter(from.pos() - 1)) {
                        to = from;
                        return;
                }
@@ -1808,13 +1806,13 @@ void LyXText::getWord(CursorSlice & from, CursorSlice & to,
 
        case lyx::WHOLE_WORD:
                // If we are already at the beginning of a word, do nothing
-               if (!from.pos() || !from_par.isWord(from.pos() - 1))
+               if (!from.pos() || !from_par.isLetter(from.pos() - 1))
                        break;
                // no break here, we go to the next
 
        case lyx::PREVIOUS_WORD:
                // always move the cursor to the beginning of previous word
-               while (from.pos() && from_par.isWord(from.pos() - 1))
+               while (from.pos() && from_par.isLetter(from.pos() - 1))
                        --from.pos();
                break;
        case lyx::NEXT_WORD:
@@ -1827,7 +1825,7 @@ void LyXText::getWord(CursorSlice & from, CursorSlice & to,
        }
        to = from;
        Paragraph & to_par = pars_[to.par()];
-       while (to.pos() < to_par.size() && to_par.isWord(to.pos()))
+       while (to.pos() < to_par.size() && to_par.isLetter(to.pos()))
                ++to.pos();
 }
 
@@ -2114,9 +2112,9 @@ int LyXText::dist(int x, int y) const
        else if (y > yo_ + descent())
                yy = y - yo_ - descent();
 
-       lyxerr << " xo_=" << xo_ << "  yo_=" << yo_ 
+       lyxerr << " xo_=" << xo_ << "  yo_=" << yo_
               << " width_=" << width_ << " ascent=" << ascent()
-              << " descent=" << descent() 
+              << " descent=" << descent()
               << " dist=" << xx+yy <<endl;
        return xx + yy;
 }