Convenience LFUN to split an environment

This commit is contained in:
Juergen Spitzmueller 2012-12-23 18:57:32 +01:00
parent 667a5ebff7
commit 3e8bfd8bd6
3 changed files with 43 additions and 1 deletions

View File

@ -452,6 +452,7 @@ enum FuncCode
// 350
LFUN_BRANCH_MASTER_ACTIVATE, // spitz 20120930
LFUN_BRANCH_MASTER_DEACTIVATE, // spitz 20120930
LFUN_ENVIRONMENT_SPLIT, // spitz 20121223
LFUN_LASTACTION // end of the table
};

View File

@ -3626,6 +3626,15 @@ void LyXAction::init()
*/
{ LFUN_INSET_COPY_AS, "inset-copy-as", ReadOnly | NoUpdate | AtPoint, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_ENVIRONMENT_SPLIT
* \li Action: Splits the current environment with a Separator.
* \li Syntax: environment-split
* \li Origin: spitz, 23 Dec 2012
* \endvar
*/
{ LFUN_ENVIRONMENT_SPLIT, "environment-split", Noop, Layout },
{ LFUN_NOACTION, "", Noop, Hidden }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
};

View File

@ -1388,6 +1388,28 @@ 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) {
FuncRequest cmd(LFUN_PARAGRAPH_BREAK);
lyx::dispatch(cmd);
}
bool const morecont = cur.lastpos() > cur.pos();
FuncRequest cmd2(LFUN_LAYOUT, "Separator");
lyx::dispatch(cmd2);
FuncRequest cmd3(LFUN_PARAGRAPH_BREAK, "inverse");
lyx::dispatch(cmd3);
if (morecont) {
FuncRequest cmd4(LFUN_DOWN);
lyx::dispatch(cmd4);
}
FuncRequest cmd5(LFUN_LAYOUT, layout);
lyx::dispatch(cmd5);
break;
}
case LFUN_CLIPBOARD_PASTE:
cap::replaceSelection(cur);
pasteClipboardText(cur, bv->buffer().errorList("Paste"),
@ -2864,6 +2886,16 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
enable = !cur.inset().forcePlainLayout();
break;
case LFUN_ENVIRONMENT_SPLIT: {
if (!cur.buffer()->params().documentClass().hasLayout(from_ascii("Separator"))
|| !cur.paragraph().layout().isEnvironment()) {
enable = false;
break;
}
enable = true;
break;
}
case LFUN_LAYOUT_PARAGRAPH:
case LFUN_PARAGRAPH_PARAMS:
case LFUN_PARAGRAPH_PARAMS_APPLY: