X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText.cpp;h=98cedccf9c93d213532b2387c72a739c08153e72;hb=1e519d1115f41f71c253cb9e2fbb7803e9a583a9;hp=b38baa79539ba1942e928c7fc41c43a0419f4514;hpb=7af1a065e8c8b2633796f4d61bae1ea58187c280;p=lyx.git diff --git a/src/Text.cpp b/src/Text.cpp index b38baa7953..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) { @@ -971,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 @@ -996,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, @@ -1479,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(); } } @@ -1497,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(); } } @@ -2042,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; } @@ -2194,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); }