]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Account for old versions of Pygments
[lyx.git] / src / Layout.cpp
index db8c317764797306dd098b7e58958c7b05c9b9d9..3d1d78136018f859af6d41d801ab3854443b37c1 100644 (file)
@@ -105,6 +105,8 @@ enum LayoutTags {
        LT_SPELLCHECK,
        LT_REFPREFIX,
        LT_RESETARGS,
+       LT_RESUMECOUNTER,
+       LT_STEPMASTERCOUNTER,
        LT_RIGHTDELIM,
        LT_FORCELOCAL,
        LT_TOGGLE_INDENT,
@@ -121,6 +123,8 @@ Layout::Layout()
        unknown_ = false;
        margintype = MARGIN_STATIC;
        latextype = LATEX_PARAGRAPH;
+       resumecounter = false;
+       stepmastercounter = false;
        intitle = false;
        inpreamble = false;
        needprotect = false;
@@ -249,10 +253,12 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "refprefix",      LT_REFPREFIX },
                { "requires",       LT_REQUIRES },
                { "resetargs",      LT_RESETARGS },
+               { "resumecounter",  LT_RESUMECOUNTER },
                { "rightdelim",     LT_RIGHTDELIM },
                { "rightmargin",    LT_RIGHTMARGIN },
                { "spacing",        LT_SPACING },
                { "spellcheck",     LT_SPELLCHECK },
+               { "stepmastercounter",  LT_STEPMASTERCOUNTER },
                { "textfont",       LT_TEXTFONT },
                { "toclevel",       LT_TOCLEVEL },
                { "toggleindent",   LT_TOGGLE_INDENT },
@@ -367,6 +373,14 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        }
                        break;
 
+               case LT_RESUMECOUNTER:
+                       lex >> resumecounter;
+                       break;
+
+               case LT_STEPMASTERCOUNTER:
+                       lex >> stepmastercounter;
+                       break;
+
                case LT_ARGUMENT:
                        readArgument(lex);
                        break;
@@ -451,15 +465,15 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        break;
 
                case LT_PREAMBLE:
-                       preamble_ = from_utf8(lex.getLongString("EndPreamble"));
+                       preamble_ = lex.getLongString(from_ascii("EndPreamble"));
                        break;
 
                case LT_LANGPREAMBLE:
-                       langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
+                       langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
                        break;
 
                case LT_BABELPREAMBLE:
-                       babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
+                       babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
                        break;
 
                case LT_LABELTYPE:
@@ -621,7 +635,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        break;
                        
                case LT_HTMLSTYLE:
-                       htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
+                       htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
                        break;
 
                case LT_HTMLFORCECSS:
@@ -629,7 +643,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        break;
 
                case LT_HTMLPREAMBLE:
-                       htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble"));
+                       htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
                        break;
                
                case LT_HTMLTITLE:
@@ -967,6 +981,7 @@ void Layout::readArgument(Lexer & lex)
        arg.font = inherit_font;
        arg.labelfont = inherit_font;
        arg.is_toc_caption = false;
+       arg.passthru = PT_INHERITED;
        string id;
        lex >> id;
        bool const itemarg = prefixIs(id, "item:");
@@ -1027,6 +1042,15 @@ void Layout::readArgument(Lexer & lex)
                } else if (tok == "passthruchars") {
                        lex.next();
                        arg.pass_thru_chars = lex.getDocString();
+               } else if (tok == "passthru") {
+                       lex.next();
+                       docstring value = lex.getDocString();
+                       if (value == "true" || value == "1")
+                               arg.passthru = PT_TRUE;
+                       else if (value == "false" || value == "0")
+                               arg.passthru = PT_FALSE;
+                       else
+                               arg.passthru = PT_INHERITED;
                } else if (tok == "istoccaption") {
                        lex.next();
                        arg.is_toc_caption = lex.getBool();
@@ -1081,6 +1105,17 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
                lyxWrite(os, arg.font, "Font", 2);
        if (arg.labelfont != inherit_font)
                lyxWrite(os, arg.labelfont, "LabelFont", 2);
+       switch (arg.passthru) {
+               case PT_TRUE:
+                       os << "\t\tPassThru true\n";
+                       break;
+               case PT_FALSE:
+                       os << "\t\tPassThru false\n";
+                       break;
+               case PT_INHERITED:
+                       os << "\t\tPassThru inherited\n";
+                       break;
+       }
        if (!arg.pass_thru_chars.empty())
                os << "\t\tPassThruChars \"" << to_utf8(arg.pass_thru_chars) << "\"\n";
        os << "\tEndArgument\n";
@@ -1089,7 +1124,7 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
 
 void Layout::write(ostream & os) const
 {
-       os << "Style " << to_utf8(name_) << '\n';
+       os << "Style \"" << to_utf8(name_) << "\"\n";
        if (!category_.empty() && obsoleted_by_.empty())
                os << "\tCategory \"" << to_utf8(category_) << "\"\n";
        // Can't deduce Copystyle here :-(
@@ -1139,7 +1174,9 @@ void Layout::write(ostream & os) const
        }
        os << "\tInTitle " << intitle << "\n"
              "\tInPreamble " << inpreamble << "\n"
-             "\tTocLevel " << toclevel << '\n';
+             "\tTocLevel " << toclevel << "\n"
+             "\tResumeCounter " << resumecounter << "\n"
+            "\tStepMasterCounter " << stepmastercounter << '\n';
        // ResetArgs does not make sense here
        for (LaTeXArgMap::const_iterator it = latexargs_.begin();
             it != latexargs_.end(); ++it)
@@ -1387,6 +1424,13 @@ void Layout::write(ostream & os) const
 }
 
 
+bool Layout::hasArgs() const
+{
+       return !latexargs_.empty() || !postcommandargs_.empty() ||
+               !itemargs_.empty();
+}
+
+
 Layout::LaTeXArgMap Layout::args() const
 {
        LaTeXArgMap args = latexargs_;