X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=3f48d19f4503be17425bcc7d9675d667e7db9d35;hb=4089ff1ec36292a37866c81d844e9ebd6dffd850;hp=8efec47202e509aca0936658f432f23d26a42aac;hpb=f6c6416f289af0e21486c7a157dac7e5fab98623;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 8efec47202..3f48d19f45 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -97,6 +97,7 @@ using cap::replaceSelection; using cap::grabAndEraseSelection; using cap::selClearOrDel; using cap::pasteSimpleText; +using frontend::Clipboard; // globals... static Font freefont(ignore_font, ignore_language); @@ -178,7 +179,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd) LASSERT(cur.inMathed(), return); cur.pos() = 0; cur.resetAnchor(); - cur.setSelection(true); + cur.selection(true); cur.pos() = cur.lastpos(); if (cmd.action() != LFUN_MATH_MODE) // LFUN_MATH_MODE has a different meaning in math mode @@ -370,7 +371,7 @@ static void outline(OutlineOp mode, Cursor & cur) ParagraphList & pars = buf.text().paragraphs(); ParagraphList::iterator const bgn = pars.begin(); // The first paragraph of the area to be copied: - ParagraphList::iterator start = next(bgn, pit); + ParagraphList::iterator start = lyx::next(bgn, pit); // The final paragraph of area to be copied: ParagraphList::iterator finish = start; ParagraphList::iterator const end = pars.end(); @@ -808,7 +809,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) ParagraphList & pars = buf.text().paragraphs(); ParagraphList::iterator bgn = pars.begin(); // The first paragraph of the area to be selected: - ParagraphList::iterator start = next(bgn, pit); + ParagraphList::iterator start = lyx::next(bgn, pit); // The final paragraph of area to be selected: ParagraphList::iterator finish = start; ParagraphList::iterator end = pars.end(); @@ -1048,22 +1049,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_CHAR_DELETE_FORWARD: if (!cur.selection()) { - bool was_separator = cur.paragraph().isEnvSeparator(cur.pos()); if (cur.pos() == cur.paragraph().size()) // Par boundary, force full-screen update singleParUpdate = false; needsUpdate |= erase(cur); cur.resetAnchor(); - if (was_separator && cur.pos() == cur.paragraph().size() - && (!cur.paragraph().layout().isEnvironment() - || cur.paragraph().size() > 0)) { - // Force full-screen update - singleParUpdate = false; - needsUpdate |= erase(cur); - cur.resetAnchor(); - } - // It is possible to make it a lot faster still - // just comment out the line below... } else { cutSelection(cur, true, false); singleParUpdate = false; @@ -1097,6 +1087,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cap::replaceSelection(cur); pit_type pit = cur.pit(); Paragraph const & par = pars_[pit]; + bool lastpar = (pit == pit_type(pars_.size() - 1)); + Paragraph const & nextpar = lastpar ? par : pars_[pit + 1]; pit_type prev = pit; if (pit > 0) { if (!pars_[pit - 1].layout().isEnvironment()) @@ -1105,25 +1097,28 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) prev = pit - 1; } if (prev < pit && cur.pos() == par.beginOfBody() - && !par.isEnvSeparator(cur.pos()) + && !par.size() && !par.isEnvSeparator(cur.pos()) && !par.layout().isCommand() && pars_[prev].layout() != par.layout() - && pars_[prev].layout().isEnvironment()) { + && pars_[prev].layout().isEnvironment() + && !nextpar.isEnvSeparator(nextpar.beginOfBody())) { if (par.layout().isEnvironment() && pars_[prev].getDepth() == par.getDepth()) { docstring const layout = par.layout().name(); DocumentClass const & tc = bv->buffer().params().documentClass(); lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name())); - lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak")); + lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain")); lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse")); lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout)); } else { - lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak")); + lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain")); breakParagraph(cur); } Font const f(inherit_font, cur.current_font.language()); pars_[cur.pit() - 1].resetFonts(f); } else { + if (par.isEnvSeparator(cur.pos())) + cur.posForward(); breakParagraph(cur, cmd.argument() == "inverse"); } cur.resetAnchor(); @@ -1613,8 +1608,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.button()) { case mouse_button::button1: // Set the cursor - if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select")) - cur.screenUpdateFlags(Update::FitCursor); + if (!bv->mouseSetCursor(cur, cmd.modifier() == ShiftModifier)) + cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor); if (bvcur.wordSelection()) selectWord(bvcur, WHOLE_WORD); break; @@ -1667,6 +1662,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) tm->setCursorFromCoordinates(cur, cmd.x(), y); cur.setTargetX(cmd.x()); + // Don't allow selecting a separator inset + if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1)) + cur.posBackward(); if (cmd.y() >= wh) lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT)); else if (cmd.y() < 0) @@ -1681,7 +1679,7 @@ 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); - bvcur.setSelection(true); + bvcur.selection(true); if (cur.top() == old) { // We didn't move one iota, so no need to update the screen. cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor); @@ -2063,7 +2061,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.push(*inset); cur.top().pos() = cur.top().lastpos(); cur.resetAnchor(); - cur.setSelection(true); + cur.selection(true); cur.top().pos() = 0; } break; @@ -2439,7 +2437,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_ESCAPE: if (cur.selection()) { - cur.setSelection(false); + cur.selection(false); } else { cur.undispatched(); // This used to be LFUN_FINISHED_RIGHT, I think FORWARD is more @@ -2724,7 +2722,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_CAPTION_INSERT: { code = CAPTION_CODE; string arg = cmd.getArg(0); - bool varia = arg != "LongTableNoNumber" + bool varia = arg != "Unnumbered" && cur.inset().allowsCaptionVariation(arg); // not allowed in description items, // and in specific insets @@ -3108,13 +3106,12 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, break; case LFUN_LAYOUT: { - enable = !cur.inset().forcePlainLayout(); - + DocumentClass const & tclass = cur.buffer()->params().documentClass(); docstring layout = cmd.argument(); - if (layout.empty()) { - DocumentClass const & tclass = cur.buffer()->params().documentClass(); + if (layout.empty()) layout = tclass.defaultLayoutName(); - } + enable = !owner_->forcePlainLayout() && tclass.hasLayout(layout); + flag.setOnOff(layout == cur.paragraph().layout().name()); break; } @@ -3149,7 +3146,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_PARAGRAPH_PARAMS: case LFUN_PARAGRAPH_PARAMS_APPLY: case LFUN_PARAGRAPH_UPDATE: - enable = cur.inset().allowParagraphCustomization(); + enable = owner_->allowParagraphCustomization(); break; // FIXME: why are accent lfuns forbidden with pass_thru layouts?