The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 3e8bfd8bd6e2ce6c1293cfe178a847a79ea32d49 Author: Juergen Spitzmueller <[email protected]> Date: Sun Dec 23 18:57:32 2012 +0100 Convenience LFUN to split an environment diff --git a/src/FuncCode.h b/src/FuncCode.h index c5749c3..7f54e9d 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -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 }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 68ce15d..1d4c746 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -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 }; diff --git a/src/Text3.cpp b/src/Text3.cpp index 6b5b0c7..cdc1bd4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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"), @@ -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.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: ----------------------------------------------------------------------- Summary of changes: src/FuncCode.h | 1 + src/LyXAction.cpp | 9 +++++++++ src/Text3.cpp | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
