]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfont.C
use more std::functors add some of my own, some change to fl_display etc. read the...
[lyx.git] / src / lyxfont.C
index 5239fbba8f8b79c5eaf6a37284ec615d0db2842b..86d7939f17ab11f3f8b4eff6795c29817e6deb26 100644 (file)
@@ -290,6 +290,7 @@ void LyXFont::update(LyXFont const & newfont,
        setNoun(setMisc(newfont.noun(), noun()));
        setLatex(setMisc(newfont.latex(), latex()));
 
+       setNumber(setMisc(newfont.number(), number()));
        if (newfont.language() == language() && toggleall)
                if (language() == document_language)
                        setLanguage(default_language);
@@ -381,14 +382,9 @@ bool LyXFont::resolved() const
 
 
 /// Build GUI description of font state
-string LyXFont::stateText(BufferParams * params) const
+string const LyXFont::stateText(BufferParams * params) const
 {
-#ifdef HAVE_SSTREAM
        std::ostringstream ost;
-#else
-       char str[1024];
-       ostrstream ost(str, 1024);
-#endif
        if (family() != INHERIT_FAMILY)
                ost << _(GUIFamilyNames[family()]) << ", ";
        if (series() != INHERIT_SERIES)
@@ -411,14 +407,12 @@ string LyXFont::stateText(BufferParams * params) const
                ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", ";
        if (bits == inherit)
                ost << _("Default") << ", ";
-       if (!params || language() != params->language_info)
-               ost << _("Language: ") << _(language()->display.c_str());
-#ifdef HAVE_SSTREAM
+       if (!params || (language() != params->language))
+               ost << _("Language: ") << _(language()->display()) << ", ";
+       if (number() != OFF)
+               ost << _("  Number ") << _(GUIMiscNames[number()]);
+
        string buf(ost.str().c_str());
-#else
-       ost << '\0';
-       string buf(ost.str());
-#endif
        buf = strip(buf, ' ');
        buf = strip(buf, ',');
        return buf;
@@ -523,7 +517,7 @@ LyXFont & LyXFont::setGUISize(string const & siz)
 
 
 // Returns size in latex format
-string LyXFont::latexSize() const
+string const LyXFont::latexSize() const
 {
        return LaTeXSizeNames[size()];
 }
@@ -621,6 +615,9 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
        if (orgfont.emph() != emph()) {
                os << "\\emph " << LyXMiscNames[emph()] << " \n";
        }
+       if (orgfont.number() != number()) {
+               os << "\\numeric " << LyXMiscNames[number()] << " \n";
+       }
        if (orgfont.underbar() != underbar()) {
                // This is only for backwards compatibility
                switch (underbar()) {
@@ -666,7 +663,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
        }
        if (orgfont.language() != language()) {
                if (language())
-                       os << "\\lang " << language()->lang << "\n";
+                       os << "\\lang " << language()->lang() << "\n";
                else
                        os << "\\lang unknown\n";
        }
@@ -681,27 +678,31 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
        int count = 0;
        bool env = false;
 
-       if (language() != base.language() && language() != prev.language()) {
+       if (language()->babel() != base.language()->babel() &&
+           language()->babel() != prev.language()->babel()) {
                if (isRightToLeft() != prev.isRightToLeft()) {
                        if (isRightToLeft()) {
                                os << "\\R{";
                                count += 3;
-                               env = true; //We have opened a new environment
                        } else {
                                os << "\\L{";
                                count += 3;
-                               env = true; //We have opened a new environment
                        }
                } else {
                        string tmp = '{' + 
                                subst(lyxrc.language_command_begin,
-                                     "$$lang", language()->lang);
+                                     "$$lang", language()->babel());
                        os << tmp;
                        count += tmp.length();
-                       env = true; //We have opened a new environment
                }
        }
 
+       if (number() == ON && prev.number() != ON &&
+           language()->lang() == "hebrew") {
+               os << "{\\beginL ";
+               count += 9;
+       }
+
        LyXFont f = *this;
        f.reduce(base);
        
@@ -726,7 +727,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
                count += strlen(LaTeXShapeNames[f.shape()]) + 2;
                env = true; //We have opened a new environment
        }
-       if (f.color() != LColor::inherit) {
+       if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
                os << "\\textcolor{"
                   << lcolor.getLaTeXName(f.color())
                   << "}{";
@@ -773,18 +774,13 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
        int count = 0;
        bool env = false;
 
-       if (language() != base.language() && language() != next.language()) {
-               os << "}";
-               ++count;
-               env = true; // Size change need not bother about closing env.
-       }
-
        LyXFont f = *this; // why do you need this?
        f.reduce(base); // why isn't this just "reduce(base);" (Lgb)
        // Because this function is const. Everything breaks if this
        // method changes the font it represents. There is no speed penalty
        // by using the temporary. (Asger)
 
+
        if (f.family() != INHERIT_FAMILY) {
                os << '}';
                ++count;
@@ -800,7 +796,7 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
                ++count;
                env = true; // Size change need not bother about closing env.
        }
-       if (f.color() != LColor::inherit) {
+       if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
                os << '}';
                ++count;
                env = true; // Size change need not bother about closing env.
@@ -828,6 +824,17 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
                }
        }
 
+       if (number() == ON && next.number() != ON &&
+           language()->lang() == "hebrew") {
+               os << "\\endL}";
+               count += 6;
+       }
+
+       if (language() != base.language() && language() != next.language()) {
+               os << "}";
+               ++count;
+       }
+
        return count;
 }