]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_charinset.C
prepare hanling of chars the nee a backslash when written...
[lyx.git] / src / mathed / math_charinset.C
index fa9dceba913cae557124d32490a49f6d7173f69c..bfb6a7c3ab05996af66c92de8a65658abc59bb4e 100644 (file)
 
 
 MathCharInset::MathCharInset(char c)
-       : char_(c), code_(nativeCode(c))
+       : char_(c), code_(nativeCode(c)), needbs_(false)
 {
 //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;
 }
@@ -31,6 +38,9 @@ MathTextCodes MathCharInset::nativeCode(char c) const
 {
        if (isalpha(c))
                return LM_TC_VAR;
+       if (strchr("#$%{|}", c))
+               return LM_TC_SPECIAL;
+       //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
        return LM_TC_CONST;
 }
 
@@ -90,6 +100,8 @@ void MathCharInset::writeTrailer(std::ostream & os) const
 
 void MathCharInset::writeRaw(std::ostream & os) const
 {
+       if (needbs_)
+               os << "\\";
        os << char_;
 }
 
@@ -104,6 +116,8 @@ void MathCharInset::write(std::ostream & os, bool) const
 
 void MathCharInset::writeNormal(std::ostream & os) const
 {
+       if (needbs_)
+               os << "\\";
        os << char_;
 }