X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText.cpp;h=0ca32a4e931847fbad9a89becf485192e8a2025c;hb=1d637b8af0f76d7c758db91ee3a196306f861a21;hp=aa70b18cbfb8bbba8fe7ecf0e0c97214dc80207c;hpb=6a7c9d12f9f45b207ed19b03cb494ec5fb660617;p=lyx.git diff --git a/src/Text.cpp b/src/Text.cpp index aa70b18cbf..0ca32a4e93 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1369,6 +1369,20 @@ void Text::selectWord(Cursor & cur, word_location loc) } +void Text::expandWordSel(Cursor & cur) +{ + // get selection of word around cur + Cursor c = cur; + c.selection(false); + c.text()->selectWord(c, WHOLE_WORD); + // use the correct word boundary, depending on selection direction + if (cur.top() > cur.normalAnchor()) + cur.pos() = c.selEnd().pos(); + else + cur.pos() = c.selBegin().pos(); +} + + void Text::selectAll(Cursor & cur) { LBUFERR(this == cur.text()); @@ -2149,7 +2163,10 @@ docstring Text::currentState(CursorData const & cur, bool devel_mode) const if (!par.empty() && cur.pos() < par.size()) { // Force output of code point, not character size_t const c = par.getChar(cur.pos()); - os << _(", Char: 0x") << hex << c; + if (c == META_INSET) + os << ", Char: INSET"; + else + os << _(", Char: 0x") << hex << c; } os << _(", Boundary: ") << cur.boundary(); // Row & row = cur.textRow(); @@ -2364,7 +2381,8 @@ void Text::setMacrocontextPosition(DocIterator const & pos) bool Text::completionSupported(Cursor const & cur) const { Paragraph const & par = cur.paragraph(); - return !cur.selection() + return !cur.buffer()->isReadonly() + && !cur.selection() && cur.pos() > 0 && (cur.pos() >= par.size() || par.isWordSeparator(cur.pos())) && !par.isWordSeparator(cur.pos() - 1); @@ -2378,9 +2396,12 @@ CompletionList const * Text::createCompletionList(Cursor const & cur) const } -bool Text::insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/) +bool Text::insertCompletion(Cursor & cur, docstring const & s) { LBUFERR(cur.bv().cursor() == cur); + if (cur.buffer()->isReadonly()) + return false; + cur.recordUndo(); cur.insert(s); cur.bv().cursor() = cur; if (!(cur.result().screenUpdate() & Update::Force))