X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=2893e080f92800e49360e3af0bf3b8078cacb8b3;hb=14e01a92a4a8b3c861bec41d33a1743870844e63;hp=6b5b0c778e274998f30c11c44014288a1bc0cec3;hpb=bec9c1325e3c69e5bb3faa173cff0ffc091d3307;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 6b5b0c778e..2893e080f9 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -940,15 +940,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_NEWLINE_INSERT: { InsetNewlineParams inp; docstring arg = cmd.argument(); - // this avoids a double undo - // FIXME: should not be needed, ideally - if (!cur.selection()) - cur.recordUndo(); - cap::replaceSelection(cur); if (arg == "linebreak") inp.kind = InsetNewlineParams::LINEBREAK; else inp.kind = InsetNewlineParams::NEWLINE; + cap::replaceSelection(cur); + cur.recordUndo(); cur.insert(new InsetNewline(inp)); cur.posForward(); moveCursor(cur, false); @@ -1388,6 +1385,21 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } + case LFUN_ENVIRONMENT_SPLIT: { + Paragraph const & para = cur.paragraph(); + docstring const layout = para.layout().name(); + if (cur.pos() > 0) + lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK)); + bool const morecont = cur.lastpos() > cur.pos(); + lyx::dispatch(FuncRequest(LFUN_LAYOUT, "Separator")); + lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse")); + if (morecont) + lyx::dispatch(FuncRequest(LFUN_DOWN)); + lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout)); + + break; + } + case LFUN_CLIPBOARD_PASTE: cap::replaceSelection(cur); pasteClipboardText(cur, bv->buffer().errorList("Paste"), @@ -1432,14 +1444,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_QUOTE_INSERT: { - // this avoids a double undo - // FIXME: should not be needed, ideally - if (!cur.selection()) - cur.recordUndo(); cap::replaceSelection(cur); + cur.recordUndo(); Paragraph const & par = cur.paragraph(); pos_type pos = cur.pos(); + // Ignore deleted text before cursor + while (pos > 0 && par.isDeleted(pos - 1)) + --pos; BufferParams const & bufparams = bv->buffer().params(); bool const hebrew = @@ -2513,11 +2525,21 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, } break; } - case LFUN_CAPTION_INSERT: + case LFUN_CAPTION_INSERT: { code = CAPTION_CODE; - // not allowed in description items - enable = !inDescriptionItem(cur); + bool varia = true; + if (cur.depth() > 0) { + if (&cur[cur.depth() - 1].inset() + && !cur[cur.depth() - 1].inset().allowsCaptionVariation()) + varia = false; + } + string arg = cmd.getArg(0); + // not allowed in description items, + // and in specific insets + enable = !inDescriptionItem(cur) + && (varia || arg.empty() || arg == "Standard"); break; + } case LFUN_NOTE_INSERT: code = NOTE_CODE; // in commands (sections etc.) and description items, @@ -2863,7 +2885,17 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_LAYOUT: enable = !cur.inset().forcePlainLayout(); break; - + + case LFUN_ENVIRONMENT_SPLIT: { + if (cur.paragraph().layout().isEnvironment() + && cur.buffer()->params().documentClass().hasLayout(from_ascii("Separator"))) { + enable = true; + break; + } + enable = false; + break; + } + case LFUN_LAYOUT_PARAGRAPH: case LFUN_PARAGRAPH_PARAMS: case LFUN_PARAGRAPH_PARAMS_APPLY: