MathCharInset::MathCharInset(char c)
- : char_(c), code_(nativeCode(c))
+ : char_(c), code_(nativeCode(c)), needbs_(false)
{
- if (isalpha(c))
- code_ = LM_TC_VAR;
+//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
}
MathCharInset::MathCharInset(char c, MathTextCodes t)
- : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
-{}
+ : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t), needbs_(false)
+{
+//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
+}
+
+
+MathCharInset::MathCharInset(char c, MathTextCodes t, bool needbs)
+ : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t), needbs_(needbs)
+{
+//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
+}
MathTextCodes MathCharInset::nativeCode(char c) const
{
if (isalpha(c))
return LM_TC_VAR;
- return LM_TC_MIN;
+ if (strchr("#$%{|}", c))
+ return LM_TC_SPECIAL;
+ //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
+ return LM_TC_CONST;
}
{
xo(x);
yo(y);
+ //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
drawChar(pain, code_, size_, x, y, char_);
}
-void MathCharInset::write(std::ostream & os, bool) const
+void MathCharInset::writeHeader(std::ostream & os) const
{
if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
+}
- if (code_ == LM_TC_TEX || code_ == LM_TC_SPECIAL)
- os << '\\';
-
- os << char_;
+void MathCharInset::writeTrailer(std::ostream & os) const
+{
if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
os << '}';
}
+void MathCharInset::writeRaw(std::ostream & os) const
+{
+ if (needbs_)
+ os << "\\";
+ os << char_;
+}
+
+
+void MathCharInset::write(std::ostream & os, bool) const
+{
+ writeHeader(os);
+ writeRaw(os);
+ writeTrailer(os);
+}
+
+
void MathCharInset::writeNormal(std::ostream & os) const
{
+ if (needbs_)
+ os << "\\";
os << char_;
}