X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText.cpp;h=98cedccf9c93d213532b2387c72a739c08153e72;hb=1e519d1115f41f71c253cb9e2fbb7803e9a583a9;hp=301cd5f2e3fa75978b0989e07471d2b9d92e4dce;hpb=ea9fe523361a1a52fc9e5c6f635c4f2888187fc5;p=lyx.git diff --git a/src/Text.cpp b/src/Text.cpp index 301cd5f2e3..98cedccf9c 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -288,6 +288,35 @@ Font const Text::outerFont(pit_type par_offset) const } +int Text::getEndLabel(pit_type p) const +{ + pit_type pit = p; + depth_type par_depth = pars_[p].getDepth(); + while (pit != pit_type(pars_.size())) { + Layout const & layout = pars_[pit].layout(); + int const endlabeltype = layout.endlabeltype; + + if (endlabeltype != END_LABEL_NO_LABEL) { + if (p + 1 == pit_type(pars_.size())) + return endlabeltype; + + depth_type const next_depth = + pars_[p + 1].getDepth(); + if (par_depth > next_depth || + (par_depth == next_depth && layout != pars_[p + 1].layout())) + return endlabeltype; + break; + } + if (par_depth == 0) + break; + pit = outerHook(pit); + if (pit != pit_type(pars_.size())) + par_depth = pars_[pit].getDepth(); + } + return END_LABEL_NO_LABEL; +} + + static void acceptOrRejectChanges(ParagraphList & pars, BufferParams const & bparams, Text::ChangeOp op) { @@ -445,6 +474,9 @@ void Text::readParToken(Paragraph & par, Lexer & lex, } else if (token == "\\numeric") { lex.next(); font.fontInfo().setNumber(setLyXMisc(lex.getString())); + } else if (token == "\\nospellcheck") { + lex.next(); + font.fontInfo().setNoSpellcheck(setLyXMisc(lex.getString())); } else if (token == "\\emph") { lex.next(); font.fontInfo().setEmph(setLyXMisc(lex.getString())); @@ -922,8 +954,8 @@ bool canInsertChar(Cursor const & cur, char_type c) "beginning of a paragraph. Please read the Tutorial.")); return false; } - // LASSERT: Is it safe to continue here? - LASSERT(cur.pos() > 0, /**/); + // If something is wrong, ignore this character. + LASSERT(cur.pos() > 0, return false); if ((par.isLineSeparator(cur.pos() - 1) || par.isNewline(cur.pos() - 1)) && !par.isDeleted(cur.pos() - 1)) { cur.message(_( @@ -968,14 +1000,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(".,:"); + // European 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) && + !(isEuropeanNumberSeparator(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 +1030,7 @@ void Text::insertChar(Cursor & cur, char_type c) ) { setCharFont(pit, cur.pos() - 1, cur.current_font, tm.font_); - } else if (contains(number_separators, ch) + } else if (isEuropeanNumberSeparator(ch) && cur.pos() >= 2 && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) { setCharFont(pit, cur.pos() - 1, cur.current_font, @@ -1476,7 +1513,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 +1531,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(); } } @@ -2039,7 +2076,7 @@ docstring Text::getPossibleLabel(DocIterator 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(i); ++i; } @@ -2191,7 +2228,8 @@ docstring Text::previousWord(CursorSlice const & sl) const bool Text::completionSupported(Cursor const & cur) const { Paragraph const & par = cur.paragraph(); - return cur.pos() > 0 + return !cur.selection() + && cur.pos() > 0 && (cur.pos() >= par.size() || par.isWordSeparator(cur.pos())) && !par.isWordSeparator(cur.pos() - 1); }