#include "frontends/Painter.h"
-#include "support/lassert.h"
#include "support/debug.h"
+#include "support/lassert.h"
+#include "support/textutils.h"
#include <ostream>
#include <vector>
docstring MathMacro::name() const
{
- if (displayMode_ == DISPLAY_UNFOLDED)
+ if (displayMode_ == DISPLAY_UNFOLDED
+ && (name_.size() > 1 || (name_[0] != '_' && name_[0] != '^')))
return asString(cell(0));
- else
- return name_;
+
+ return name_;
}
int expy = y;
if (displayMode_ == DISPLAY_INIT || displayMode_ == DISPLAY_INTERACTIVE_INIT) {
- PainterInfo pi2(pi.base.bv, pi.pain);
- pi2.base.font.setColor(macro_ ? Color_latex : Color_error);
- //pi2.base.style = LM_ST_TEXT;
- pi2.pain.text(x, y, from_ascii("\\") + name(), pi2.base.font);
+ FontSetChanger dummy(pi.base, "lyxtex");
+ pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font);
} else if (displayMode_ == DISPLAY_UNFOLDED) {
- PainterInfo pi2(pi.base.bv, pi.pain);
- pi2.base.font.setColor(macro_ ? Color_latex : Color_error);
- //pi2.base.style = LM_ST_TEXT;
- pi2.pain.text(x, y, from_ascii("\\"), pi2.base.font);
- x += mathed_string_width(pi2.base.font, from_ascii("\\")) + 1;
- cell(0).draw(pi2, x, y);
- drawMarkers(pi2, expx, expy);
+ FontSetChanger dummy(pi.base, "lyxtex");
+ pi.pain.text(x, y, from_ascii("\\"), pi.base.font);
+ x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1;
+ cell(0).draw(pi, x, y);
+ drawMarkers(pi, expx, expy);
} else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
&& editing_[pi.base.bv]) {
// Macro will be edited in a old-style list mode here:
void MathMacro::write(WriteStream & os) const
{
+ MathEnsurer ensurer(os, macro_ != 0, true);
+
// non-normal mode
if (displayMode_ != DISPLAY_NORMAL) {
- os << "\\" << name() << " ";
- os.pendingSpace(true);
+ os << "\\" << name();
+ if (name().size() != 1 || isAlphaASCII(name()[0]))
+ os.pendingSpace(true);
return;
}