#include "FuncCode.h"
#include "FuncRequest.h"
#include "Language.h"
+#include "Layout.h"
#include "LyXAction.h"
#include "LyXRC.h"
#include "Paragraph.h"
else
++et.pit();
- double best_dist = numeric_limits<double>::max();;
+ double best_dist = numeric_limits<double>::max();
DocIterator best_cursor = et;
for ( ; it != et; it.forwardPos(true)) {
fixIfBroken();
FuncRequest cmd = cmd0;
Cursor safe = *this;
+ Cursor old = *this;
+ disp_ = DispatchResult();
buffer()->undo().beginUndoGroup();
-
+
// Is this a function that acts on inset at point?
if (lyxaction.funcHasFlag(cmd.action(), LyXAction::AtPoint)
&& nextInset()) {
beforeDispatchCursor_ = safe.beforeDispatchCursor_;
}
buffer()->undo().endUndoGroup();
+
+ // notify insets we just left
+ if (*this != old) {
+ old.beginUndoGroup();
+ old.fixIfBroken();
+ bool badcursor = notifyCursorLeavesOrEnters(old, *this);
+ if (badcursor) {
+ fixIfBroken();
+ bv().fixInlineCompletionPos();
+ }
+ old.endUndoGroup();
+ }
}
{
LASSERT(inset0, /**/);
if (inMathed())
- insert(MathAtom(inset0));
+ insert(MathAtom(inset0->asInsetMath()));
else {
text()->insertInset(*this, inset0);
inset0->setBuffer(bv_->buffer());
MathData ar(buffer());
asArray(safe, ar);
insert(ar);
+ } else if (t->asMacro() && !safe.empty()) {
+ MathData ar(buffer());
+ asArray(safe, ar);
+ docstring const name = t->asMacro()->name();
+ MacroData const * data = buffer()->getMacro(name);
+ if (data && data->numargs() - data->optionals() > 0) {
+ plainInsert(MathAtom(new InsetMathBrace(ar)));
+ posBackward();
+ }
}
}
}
-static docstring parbreak(InsetCode code)
+namespace {
+docstring parbreak(Cursor const * cur)
{
odocstringstream os;
os << '\n';
- // only add blank line if we're not in an ERT or Listings inset
- if (code != ERT_CODE && code != LISTINGS_CODE)
+ // only add blank line if we're not in a ParbreakIsNewline situation
+ if (!cur->inset().getLayout().parbreakIsNewline()
+ && !cur->paragraph().layout().parbreak_is_newline)
os << '\n';
return os.str();
}
+}
docstring Cursor::selectionAsString(bool with_label) const
// First paragraph in selection
docstring result = pars[startpit].
asString(startpos, pars[startpit].size(), label)
- + parbreak(inset().lyxCode());
+ + parbreak(this);
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
Paragraph const & par = pars[pit];
result += par.asString(0, par.size(), label)
- + parbreak(inset().lyxCode());
+ + parbreak(this);
}
// Last paragraph in selection
}
-void Cursor::recordUndoInset(UndoKind kind) const
+void Cursor::recordUndoInset(UndoKind kind, Inset const * inset) const
{
- buffer()->undo().recordUndoInset(*this, kind);
+ buffer()->undo().recordUndoInset(*this, kind, inset);
}