\{ and \% now correctly use the selection as their argument instead of
erasing it.
This commit is contained in:
Guillaume Munch 2015-08-23 11:47:37 +02:00 committed by Georg Baum
parent 07cd297c12
commit 125a297778
3 changed files with 19 additions and 5 deletions

View File

@ -26,6 +26,13 @@ InsetMathComment::InsetMathComment(Buffer * buf)
{} {}
InsetMathComment::InsetMathComment(MathData const & ar)
: InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
{
cell(0) = ar;
}
InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str) InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str)
: InsetMathNest(buf, 1) : InsetMathNest(buf, 1)
{ {

View File

@ -25,6 +25,8 @@ public:
/// ///
InsetMathComment(Buffer * buf); InsetMathComment(Buffer * buf);
/// ///
InsetMathComment(MathData const & ar);
///
explicit InsetMathComment(Buffer * buf, docstring const &); explicit InsetMathComment(Buffer * buf, docstring const &);
/// ///
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;

View File

@ -1657,12 +1657,17 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
} else if (c == '^' && currentMode() == InsetMath::MATH_MODE) { } else if (c == '^' && currentMode() == InsetMath::MATH_MODE) {
cur.backspace(); cur.backspace();
cur.niceInsert(createInsetMath("mathcircumflex", buf)); cur.niceInsert(createInsetMath("mathcircumflex", buf));
} else if (c == '{') { } else if (c == '{' || c == '%') {
//using the saved selection as argument
InsetMathUnknown * p = cur.activeMacro();
p->finalize();
MathData sel(cur.buffer());
asArray(p->selection(), sel);
cur.backspace(); cur.backspace();
cur.niceInsert(MathAtom(new InsetMathBrace(buf))); if (c == '{')
} else if (c == '%') { cur.niceInsert(MathAtom(new InsetMathBrace(sel)));
cur.backspace(); else
cur.niceInsert(MathAtom(new InsetMathComment(buf))); cur.niceInsert(MathAtom(new InsetMathComment(sel)));
} else if (c == '#') { } else if (c == '#') {
LASSERT(cur.activeMacro(), return false); LASSERT(cur.activeMacro(), return false);
cur.activeMacro()->setName(name + docstring(1, c)); cur.activeMacro()->setName(name + docstring(1, c));