diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 71b0ac8abd..31902637e2 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1515,9 +1515,11 @@ void LyXAction::init() * \li Action: Splits the current environment with a Separator. * \li Syntax: environment-split [outer|previous] * \li Params: outer: If this is given, LyX will split the outermost environment in - * the current nesting hierarchy. - * previous: If this is given, LyX will split the environment in the previous - * paragraph (is there is one). + the current nesting hierarchy. + previous: If this is given, LyX will split the environment in the previous + paragraph (is there is one). + before: If this is given, the new environment will be appended rather than + prepended. * \li Origin: spitz, 23 Dec 2012 * \endvar */ @@ -3059,10 +3061,11 @@ void LyXAction::init() * \var lyx::FuncCode lyx::LFUN_PARAGRAPH_BREAK * \li Action: Breaks the current paragraph at the current location. * \li Notion: Removes the selection. - * \li Syntax: paragraph-break [] + * \li Syntax: paragraph-break [] [ignoresep] * \li Params: : "inverse" - decreases depth by one (or change layout to default layout) when the cursor is at the end of the line. + ignoresep: Do not account for paragraph separators while breaking. * \endvar */ { LFUN_PARAGRAPH_BREAK, "paragraph-break", Noop, Edit }, diff --git a/src/Text3.cpp b/src/Text3.cpp index b5fb52f17c..c7e8b087e9 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1141,9 +1141,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Font const f(inherit_font, cur.current_font.language()); pars_[cur.pit() - 1].resetFonts(f); } else { - if (par.isEnvSeparator(cur.pos())) + if (par.isEnvSeparator(cur.pos()) && cmd.getArg(1) != "ignoresep") cur.posForward(); - breakParagraph(cur, cmd.argument() == "inverse"); + breakParagraph(cur, cmd.getArg(0) == "inverse"); } cur.resetAnchor(); // If we have a list and autoinsert item insets, @@ -1493,6 +1493,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_ENVIRONMENT_SPLIT: { bool const outer = cmd.argument() == "outer"; bool const previous = cmd.argument() == "previous"; + bool const before = cmd.argument() == "before"; Paragraph const & para = cur.paragraph(); docstring layout; if (para.layout().isEnvironment()) @@ -1521,7 +1522,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } } - if (cur.pos() > 0) + if (before) + cur.top().setPitPos(cur.pit(), 0); + if (before || cur.pos() > 0) lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK)); if (outer) { while (cur.paragraph().params().depth() > split_depth) @@ -1530,7 +1533,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) DocumentClass const & tc = bv->buffer().params().documentClass(); lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name())); lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain")); - lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse")); + if (before) { + cur.backwardPos(); + lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse ignoresep")); + while (cur.paragraph().params().depth() < split_depth) + lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT)); + } + else + lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse")); lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout)); break; diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index f19876c9ef..8daec7d5de 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -1880,15 +1880,19 @@ void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv) break; } if (par.layout().isEnvironment()) { - docstring const label = - bformat(_("Start New Environment (%1$s)"), + docstring label = bformat(_("Prepend New Environment (%1$s)"), + translateIfPossible(curlayout)); + add(MenuItem(MenuItem::Command, toqstr(label), + FuncRequest(LFUN_ENVIRONMENT_SPLIT, + from_ascii("before")))); + label = bformat(_("Append New Environment (%1$s)"), translateIfPossible(curlayout)); add(MenuItem(MenuItem::Command, toqstr(label), FuncRequest(LFUN_ENVIRONMENT_SPLIT))); } else if (!prevlayout.empty()) { docstring const label = - bformat(_("Start New Environment (%1$s)"), + bformat(_("Append New Environment (%1$s)"), translateIfPossible(prevlayout)); add(MenuItem(MenuItem::Command, toqstr(label), FuncRequest(LFUN_ENVIRONMENT_SPLIT, @@ -1896,7 +1900,7 @@ void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv) } if (!outerlayout.empty()) { docstring const label = - bformat(_("Start New Parent Environment (%1$s)"), + bformat(_("Append New Parent Environment (%1$s)"), translateIfPossible(outerlayout)); add(MenuItem(MenuItem::Command, toqstr(label), FuncRequest(LFUN_ENVIRONMENT_SPLIT,