#include "gettext.h"
#include "Intl.h"
#include "Language.h"
+#include "Layout.h"
#include "LyXAction.h"
#include "LyXFunc.h"
#include "Lexer.h"
#include "frontends/Clipboard.h"
#include "frontends/Selection.h"
+#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
#include "insets/InsetFloatList.h"
#include "insets/InsetNewline.h"
using support::isStrUnsignedInt;
using support::token;
-namespace frontend {
-extern docstring current_layout;
-}
-
// globals...
static Font freefont(Font::ALL_IGNORE);
static bool toggleall = false;
return false;
recordUndo(cur);
- bool gotsel = false;
- if (cur.selection()) {
- lyx::dispatch(FuncRequest(LFUN_CUT));
- gotsel = true;
- }
- text->insertInset(cur, inset);
-
- if (edit)
- inset->edit(cur, true);
-
- if (gotsel && pastesel) {
- lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
- // reset first par to default
- if (cur.lastpit() != 0 || cur.lastpos() != 0) {
- LayoutPtr const layout =
- cur.buffer().params().getTextClass().defaultLayout();
- cur.text()->paragraphs().begin()->layout(layout);
+ if (cmd.action == LFUN_INDEX_INSERT) {
+ docstring ds = support::subst(text->getStringToIndex(cur), '\n', ' ');
+ text->insertInset(cur, inset);
+ if (edit)
+ inset->edit(cur, true);
+ // Now put this into inset
+ static_cast<InsetCollapsable *>(inset)->text_.insertStringAsParagraphs(cur, ds);
+ } else {
+ bool gotsel = false;
+ if (cur.selection()) {
+ lyx::dispatch(FuncRequest(LFUN_CUT));
+ gotsel = true;
+ }
+ text->insertInset(cur, inset);
+
+ if (edit)
+ inset->edit(cur, true);
+
+ if (gotsel && pastesel) {
+ lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
+ // reset first par to default
+ if (cur.lastpit() != 0 || cur.lastpos() != 0) {
+ LayoutPtr const layout =
+ cur.buffer().params().getTextClass().defaultLayout();
+ cur.text()->paragraphs().begin()->layout(layout);
+ }
}
}
return true;
docstring layout = cmd.argument();
LYXERR(Debug::INFO) << "LFUN_LAYOUT: (arg) " << to_utf8(layout) << endl;
+ docstring const old_layout = cur.paragraph().layout()->name();
+
// Derive layout number from given argument (string)
// and current buffer's textclass (number)
TextClass const & tclass = bv->buffer().params().getTextClass();
break;
}
- bool change_layout = (frontend::current_layout != layout);
+ bool change_layout = (old_layout != layout);
if (!change_layout && cur.selection() &&
cur.selBegin().pit() != cur.selEnd().pit())
pit_type spit = cur.selBegin().pit();
pit_type epit = cur.selEnd().pit() + 1;
while (spit != epit) {
- if (pars_[spit].layout()->name() != frontend::current_layout) {
+ if (pars_[spit].layout()->name() != old_layout) {
change_layout = true;
break;
}
}
}
- if (change_layout) {
+ if (change_layout)
setLayout(cur, layout);
- // inform the GUI that the layout has changed.
- bv->layoutChanged(layout);
- }
+
break;
}
}
case LFUN_INDEX_INSERT:
+ doInsertInset(cur, this, cmd, true, true);
+ cur.posRight();
+ break;
case LFUN_NOMENCL_INSERT: {
Inset * inset = createInset(&cur.bv(), cmd);
if (!inset)