X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText.cpp;h=70f8eaa4723fb229dda2f96ac794bba2ef393f9b;hb=bf2bf2eaedadf39a6398db624c8b6c52099ca31d;hp=3de796442c285b89255a3428809b0ed0972c7e78;hpb=d9ebf6e2c75eca0f192fef0b7d822644e3b62e64;p=lyx.git diff --git a/src/Text.cpp b/src/Text.cpp index 3de796442c..70f8eaa472 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -445,6 +445,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 +925,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 +971,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 +1001,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 +1484,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 +1502,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(); } } @@ -1662,6 +1670,7 @@ bool Text::backspacePos0(Cursor & cur) plist.erase(lyx::next(plist.begin(), prevcur.pit())); needsUpdate = true; } + // FIXME: Do we really not want to allow this??? // Pasting is not allowed, if the paragraphs have different // layouts. I think it is a real bug of all other // word processors to allow it. It confuses the user. @@ -1974,12 +1983,44 @@ docstring Text::currentState(CursorData const & cur, bool devel_mode) const docstring Text::getPossibleLabel(DocIterator const & cur) const { - pit_type pit = cur.pit(); + pit_type textpit = cur.pit(); + Layout const * layout = &(pars_[textpit].layout()); - Layout const * layout = &(pars_[pit].layout()); + // Will contain the label prefix. + docstring name; + + // For captions, we just take the caption type + Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE); + if (caption_inset) { + string const & ftype = static_cast(caption_inset)->floattype(); + FloatList const & fl = cur.buffer()->params().documentClass().floats(); + if (fl.typeExist(ftype)) { + Floating const & flt = fl.getType(ftype); + name = from_utf8(flt.refPrefix()); + } + if (name.empty()) + name = from_utf8(ftype.substr(0,3)); + } else { + // For section, subsection, etc... + if (layout->latextype == LATEX_PARAGRAPH && textpit != 0) { + Layout const * layout2 = &(pars_[textpit - 1].layout()); + if (layout2->latextype != LATEX_PARAGRAPH) { + --textpit; + layout = layout2; + } + } + if (layout->latextype != LATEX_PARAGRAPH) + name = layout->refprefix; + + // If none of the above worked, see if the inset knows. + if (name.empty()) { + InsetLayout const & il = cur.inset().getLayout(); + name = il.refprefix(); + } + } docstring text; - docstring par_text = pars_[pit].asString(AS_STR_SKIPDELETE); + docstring par_text = pars_[textpit].asString(AS_STR_SKIPDELETE); // The return string of math matrices might contain linebreaks par_text = subst(par_text, '\n', '-'); @@ -2000,39 +2041,6 @@ docstring Text::getPossibleLabel(DocIterator const & cur) const if (text.size() > max_label_length) text.resize(max_label_length); - // Will contain the label prefix. - docstring name; - - // For section, subsection, etc... - if (layout->latextype == LATEX_PARAGRAPH && pit != 0) { - Layout const * layout2 = &(pars_[pit - 1].layout()); - if (layout2->latextype != LATEX_PARAGRAPH) { - --pit; - layout = layout2; - } - } - if (layout->latextype != LATEX_PARAGRAPH) - name = layout->refprefix; - - // For captions, we just take the caption type - Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE); - if (caption_inset) { - string const & ftype = static_cast(caption_inset)->floattype(); - FloatList const & fl = cur.buffer()->params().documentClass().floats(); - if (fl.typeExist(ftype)) { - Floating const & flt = fl.getType(ftype); - name = from_utf8(flt.refPrefix()); - } - if (name.empty()) - name = from_utf8(ftype.substr(0,3)); - } - - // If none of the above worked, see if the inset knows. - if (name.empty()) { - InsetLayout const & il = cur.inset().getLayout(); - name = il.refprefix(); - } - if (!name.empty()) text = name + ':' + text; @@ -2191,7 +2199,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); }