X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=7422bea31249a1424740c694a5ce4f10e980f00b;hb=61d68d05bd0f2172ab9406f23dc2640e6b9ac56b;hp=9143e2659767610c63161e38765354c5c31c7edd;hpb=6adb083384e1c47a11595fc9b06ba3c9b4f9ae63;p=features.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 9143e26597..7422bea312 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -243,7 +243,8 @@ static void ipaChar(Cursor & cur, InsetIPAChar::Kind kind) static bool doInsertInset(Cursor & cur, Text * text, - FuncRequest const & cmd, bool edit, bool pastesel) + FuncRequest const & cmd, bool edit, + bool pastesel, bool resetfont = false) { Buffer & buffer = cur.bv().buffer(); BufferParams const & bparams = buffer.params(); @@ -346,6 +347,13 @@ static bool doInsertInset(Cursor & cur, Text * text, cur.clearSelection(); // bug 393 cur.finishUndo(); if (inset_text) { + if (resetfont) { + // Reset of font (not language) is requested. + // Used by InsetIndex (#11961). + Language const * lang = cur.getFont().language(); + Font font(bparams.getFont().fontInfo(), lang); + cur.paragraph().resetFonts(font); + } inset_text->fixParagraphsFont(); cur.pos() = 0; cur.pit() = 0; @@ -1866,8 +1874,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) bvcur.resetAnchor(); if (!bv->mouseSetCursor(cur, cmd.modifier() == ShiftModifier)) cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor); - if (bvcur.wordSelection()) - selectWord(bvcur, WHOLE_WORD); + // FIXME: move this to mouseSetCursor? + if (bvcur.wordSelection() && bvcur.inTexted()) + expandWordSel(bvcur); break; case mouse_button::button2: @@ -1935,6 +1944,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // We continue with our existing selection or start a new one, so don't // reset the anchor. bvcur.setCursor(cur); + if (bvcur.wordSelection() && bvcur.inTexted()) + expandWordSel(bvcur); bvcur.selection(true); bvcur.setCurrentFont(); if (cur.top() == old) { @@ -2105,16 +2116,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INDEX_INSERT: case LFUN_PREVIEW_INSERT: case LFUN_SCRIPT_INSERT: - case LFUN_IPA_INSERT: + case LFUN_IPA_INSERT: { + // Indexes reset font formatting (#11961) + bool const resetfont = cmd.action() == LFUN_INDEX_INSERT; // Open the inset, and move the current selection // inside it. - doInsertInset(cur, this, cmd, true, true); + doInsertInset(cur, this, cmd, true, true, resetfont); cur.posForward(); cur.setCurrentFont(); // Some insets are numbered, others are shown in the outline pane so // let's update the labels and the toc backend. cur.forceBufferUpdate(); break; + } case LFUN_FLEX_INSERT: { // Open the inset, and move the current selection @@ -3169,13 +3183,17 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_FLEX_INSERT: { code = FLEX_CODE; string s = cmd.getArg(0); - InsetLayout il = - cur.buffer()->params().documentClass().insetLayout(from_utf8(s)); - if (il.lyxtype() != InsetLyXType::CHARSTYLE && - il.lyxtype() != InsetLyXType::CUSTOM && - il.lyxtype ()!= InsetLyXType::STANDARD) + if (!cur.buffer()->params().documentClass().hasInsetLayout(from_utf8(s))) enable = false; - break; + else { + InsetLayout il = + cur.buffer()->params().documentClass().insetLayout(from_utf8(s)); + if (il.lyxtype() != InsetLyXType::CHARSTYLE && + il.lyxtype() != InsetLyXType::CUSTOM && + il.lyxtype ()!= InsetLyXType::STANDARD) + enable = false; + } + break; } case LFUN_BOX_INSERT: code = BOX_CODE; @@ -3554,8 +3572,10 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, docstring const req_layout = ignoreautonests ? from_utf8(cmd.getArg(0)) : cmd.argument(); docstring const layout = resolveLayout(req_layout, cur); - enable = !owner_->forcePlainLayout() && !layout.empty(); - status.setOnOff(!owner_->forcePlainLayout() && isAlreadyLayout(layout, cur)); + // FIXME: make this work in multicell selection case + enable = !owner_->forcePlainLayout() && !layout.empty() && !cur.selIsMultiCell(); + status.setOnOff(!owner_->forcePlainLayout() && !cur.selIsMultiCell() + && isAlreadyLayout(layout, cur)); break; }