mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Introduce environment-split before
This one prepends the new environment rather than appending it. Easy way to add a new beamer frame before the current one.
This commit is contained in:
parent
2907160fff
commit
87a6c75d9d
@ -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 [<LAYOUT>]
|
||||
* \li Syntax: paragraph-break [<LAYOUT>] [ignoresep]
|
||||
* \li Params: <LAYOUT>: "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 },
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user