#include "frontends/Painter.h"
#include "frontends/Selection.h"
-#include "support/assert.h"
+#include "support/lassert.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
void InsetMathNest::write(WriteStream & os) const
{
- os << '\\' << name().c_str();
+ ModeSpecifier specifier(os, currentMode());
+ docstring const latex_name = name();
+ os << '\\' << latex_name;
for (size_t i = 0; i < nargs(); ++i)
os << '{' << cell(i) << '}';
if (nargs() == 0)
void InsetMathNest::normalize(NormalStream & os) const
{
- os << '[' << name().c_str();
+ os << '[' << name();
for (size_t i = 0; i < nargs(); ++i)
os << ' ' << cell(i);
os << ']';
int InsetMathNest::latex(odocstream & os, OutputParams const & runparams) const
{
- WriteStream wi(os, runparams.moving_arg, true);
+ WriteStream wi(os, runparams.moving_arg, true, runparams.dryrun,
+ runparams.encoding);
write(wi);
return wi.line();
}
break;
// Math fonts
- case LFUN_FONT_FREE_APPLY:
- case LFUN_FONT_FREE_UPDATE:
+ case LFUN_TEXTSTYLE_APPLY:
+ case LFUN_TEXTSTYLE_UPDATE:
handleFont2(cur, cmd.argument());
break;
else
handleFont(cur, cmd.argument(), "mathbb");
break;
- /*
- case LFUN_FONT_FREE_APPLY:
- handleFont(cur, cmd.argument(), "textrm");
- break;
- */
case LFUN_FONT_DEFAULT:
handleFont(cur, cmd.argument(), "textnormal");
break;
break;
}
- case LFUN_MATH_SIZE:
-#if 0
- cur.recordUndoSelection();
- cur.setSize(arg);
-#endif
+ case LFUN_MATH_SIZE: {
+ FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, cmd.argument());
+ doDispatch(cur, fr);
break;
+ }
case LFUN_MATH_MATRIX: {
cur.recordUndo();
}
case LFUN_SPACE_INSERT:
- case LFUN_MATH_SPACE:
cur.recordUndoSelection();
cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
break;
+ case LFUN_MATH_SPACE:
+ cur.recordUndoSelection();
+ if (cmd.argument().empty())
+ cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
+ else
+ cur.insert(MathAtom(new InsetMathSpace(cmd.argument())));
+ break;
+
case LFUN_ERT_INSERT:
// interpret this as if a backslash was typed
cur.recordUndo();
MathData ar;
asArray(cmd.argument(), ar);
if (ar.size() == 1 && ar[0]->asNestInset()
- && ar[0]->asNestInset()->nargs())
+ && ar[0]->asNestInset()->nargs() > 1)
handleNest(cur, ar[0]);
else
cur.niceInsert(cmd.argument());
string const arg = to_utf8(cmd.argument());
switch (cmd.action) {
case LFUN_TABULAR_FEATURE:
- flag.enabled(false);
+ flag.setEnabled(false);
break;
#if 0
case LFUN_TABULAR_FEATURE:
case LFUN_FONT_NOUN:
case LFUN_FONT_ROMAN:
case LFUN_FONT_DEFAULT:
- flag.enabled(true);
+ flag.setEnabled(true);
break;
case LFUN_MATH_MUTATE:
//flag.setOnOff(mathcursor::formula()->hullType() == to_utf8(cmd.argument()));
case LFUN_MATH_SPACE:
case LFUN_MATH_LIMITS:
case LFUN_MATH_EXTERN:
- flag.enabled(true);
+ flag.setEnabled(true);
break;
case LFUN_FONT_FRAK:
- flag.enabled(currentMode() != TEXT_MODE);
+ flag.setEnabled(currentMode() != TEXT_MODE);
break;
case LFUN_MATH_INSERT: {
arg == "\\textsl" || arg == "\\textup" ||
arg == "\\texttt" || arg == "\\textbb" ||
arg == "\\textnormal";
- flag.enabled(currentMode() != TEXT_MODE || textarg);
+ flag.setEnabled(currentMode() != TEXT_MODE || textarg);
break;
}
case LFUN_MATH_MATRIX:
- flag.enabled(currentMode() == MATH_MODE);
+ flag.setEnabled(currentMode() == MATH_MODE);
break;
case LFUN_INSET_INSERT: {
// getStatus is not called with a valid reference and the
// dialog would not be applyable.
string const name = cmd.getArg(0);
- flag.enabled(name == "ref");
+ flag.setEnabled(name == "ref");
break;
}
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM:
// Don't do this with multi-cell selections
- flag.enabled(cur.selBegin().idx() == cur.selEnd().idx());
+ flag.setEnabled(cur.selBegin().idx() == cur.selEnd().idx());
break;
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
bool found = findMacroToFoldUnfold(it, cmd.action == LFUN_MATH_MACRO_FOLD);
- flag.enabled(found);
+ flag.setEnabled(found);
break;
}
case LFUN_SPECIALCHAR_INSERT:
// FIXME: These would probably make sense in math-text mode
- flag.enabled(false);
+ flag.setEnabled(false);
break;
case LFUN_INSET_DISSOLVE:
- flag.enabled(!asHullInset());
+ flag.setEnabled(!asHullInset());
break;
default: