]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Allow to provide xunicode.
[lyx.git] / src / BufferParams.cpp
index 5522c705a0bee0baa259f907f7d0ca66e5886da1..2f7058a9e4403faf3cbcd0341381f6760ad69671 100644 (file)
@@ -323,7 +323,7 @@ bool inSystemDir(FileName const & document_dir, string & system_dir)
        return false;
 }
 
-} // anon namespace
+} // namespace
 
 
 class BufferParams::Impl
@@ -459,8 +459,10 @@ BufferParams::BufferParams()
        html_css_as_file = false;
        display_pixel_ratio = 1.0;
 
+       shell_escape = false;
        output_sync = false;
        use_refstyle = true;
+       use_minted = false;
 
        // map current author
        author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
@@ -865,7 +867,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> is_math_indent;
        } else if (token == "\\math_indentation") {
                lex.next();
-               pimpl_->mathindent = Length(lex.getString());
+               string mathindent = lex.getString();
+               if (mathindent == "default")
+                       pimpl_->mathindent = Length();
+               else
+                       pimpl_->mathindent = Length(mathindent);
        } else if (token == "\\math_numbering_side") {
                string tmp;
                lex >> tmp;
@@ -1095,6 +1101,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> output_sync_macro;
        } else if (token == "\\use_refstyle") {
                lex >> use_refstyle;
+       } else if (token == "\\use_minted") {
+               lex >> use_minted;
        } else {
                lyxerr << "BufferParams::readToken(): Unknown token: " <<
                        token << endl;
@@ -1112,7 +1120,7 @@ namespace {
                        return "\"" + str + "\"";
                return str;
        }
-}
+} // namespace
 
 
 void BufferParams::writeFile(ostream & os, Buffer const * buf) const
@@ -1302,6 +1310,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\suppress_date " << convert<string>(suppress_date)
           << "\n\\justification " << convert<string>(justification)
           << "\n\\use_refstyle " << use_refstyle
+          << "\n\\use_minted " << use_minted
           << '\n';
        if (isbackgroundcolor == true)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
@@ -1373,8 +1382,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        else
                os << "\n\\defskip " << getDefSkip().asLyXCommand();
        os << "\n\\is_math_indent " << is_math_indent;
-       if (is_math_indent && !getMathIndent().empty())
-               os << "\n\\math_indentation " << getMathIndent().asString();
+       if (is_math_indent)
+               os << "\n\\math_indentation "
+                  << (getMathIndent().empty() ? "default" : getMathIndent().asString());
        os << "\n\\math_numbering_side ";
        switch(math_numbering_side) {
        case LEFT:
@@ -1544,7 +1554,7 @@ void BufferParams::validate(LaTeXFeatures & features) const
 
        if (useNonTeXFonts && fontsMath() != "auto")
                features.require("unicode-math");
-       
+
        if (use_microtype)
                features.require("microtype");
 
@@ -2040,13 +2050,12 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg144349.html
        os << from_ascii(features.getColorOptions());
 
-       // If we use hyperref, jurabib, japanese, varioref or vietnamese,
+       // If we use hyperref, jurabib, japanese or varioref,
        // we have to call babel before
        if (use_babel
            && (features.isRequired("jurabib")
                || features.isRequired("hyperref")
                || features.isRequired("varioref")
-               || features.isRequired("vietnamese")
                || features.isRequired("japanese"))) {
                        os << features.getBabelPresettings();
                        // FIXME UNICODE
@@ -2242,8 +2251,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // called after babel, though.
        if (use_babel && !features.isRequired("jurabib")
            && !features.isRequired("hyperref")
-               && !features.isRequired("varioref")
-           && !features.isRequired("vietnamese")
+           && !features.isRequired("varioref")
            && !features.isRequired("japanese")) {
                os << features.getBabelPresettings();
                // FIXME UNICODE
@@ -2253,10 +2261,19 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
        if (features.isRequired("bicaption"))
                os << "\\usepackage{bicaption}\n";
-       if (!listings_params.empty() || features.mustProvide("listings"))
-               os << "\\usepackage{listings}\n";
+       if (!listings_params.empty()
+           || features.mustProvide("listings")
+           || features.mustProvide("minted")) {
+               if (features.mustProvide("listings"))
+                       os << "\\usepackage{listings}\n";
+               else
+                       os << "\\usepackage{minted}\n";
+       }
        if (!listings_params.empty()) {
-               os << "\\lstset{";
+               if (features.mustProvide("listings"))
+                       os << "\\lstset{";
+               else
+                       os << "\\setminted{";
                // do not test validity because listings_params is
                // supposed to be valid
                string par =
@@ -2269,7 +2286,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // (the rest is obsoleted by the new TU encoding).
        // It needs to be loaded at least after amsmath, amssymb,
        // esint and the other packages that provide special glyphs
-       if (features.mustProvide("tipa") && useNonTeXFonts) {
+       if (features.mustProvide("tipa") && useNonTeXFonts
+           && !features.isProvided("xunicode")) {
                // The package officially only supports XeTeX, but also works
                // with LuaTeX. Thus we work around its XeTeX test.
                if (features.runparams().flavor != OutputParams::XETEX) {
@@ -2353,7 +2371,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        docstring const i18npreamble =
-               features.getTClassI18nPreamble(use_babel, use_polyglossia);
+               features.getTClassI18nPreamble(use_babel, use_polyglossia,
+                                              use_minted);
        if (!i18npreamble.empty())
                os << i18npreamble + '\n';
 
@@ -2559,7 +2578,7 @@ FormatList const & BufferParams::exportableFormats(bool only_viewable) const
 {
        FormatList & cached = only_viewable ?
                        pimpl_->viewableFormatList : pimpl_->exportableFormatList;
-       bool & valid = only_viewable ? 
+       bool & valid = only_viewable ?
                        pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
        if (valid)
                return cached;
@@ -2574,7 +2593,7 @@ FormatList const & BufferParams::exportableFormats(bool only_viewable) const
                theConverters().getReachable(backs[0], only_viewable, true, excludes);
        for (vector<string>::const_iterator it = backs.begin() + 1;
             it != backs.end(); ++it) {
-               FormatList r = theConverters().getReachable(*it, only_viewable, 
+               FormatList r = theConverters().getReachable(*it, only_viewable,
                                false, excludes);
                result.insert(result.end(), r.begin(), r.end());
        }
@@ -2603,8 +2622,16 @@ vector<string> BufferParams::backends() const
                        v.push_back("luatex");
                        v.push_back("dviluatex");
                }
-       } else
-               v.push_back(buffmt);
+       } else {
+               string rbuffmt = buffmt;
+               // If we use an OutputFormat in Japanese docs,
+               // we need special format in order to get the path
+               // via pLaTeX (#8823)
+               if (documentClass().hasOutputFormat()
+                   && encoding().package() == Encoding::japanese)
+                       rbuffmt += "-ja";
+               v.push_back(rbuffmt);
+       }
 
        v.push_back("xhtml");
        v.push_back("text");
@@ -2669,14 +2696,15 @@ string BufferParams::getDefaultOutputFormat() const
        if (!default_output_format.empty()
            && default_output_format != "default")
                return default_output_format;
-       if (isDocBook()
-           || encoding().package() == Encoding::japanese) {
+       if (isDocBook()) {
                FormatList const & formats = exportableFormats(true);
                if (formats.empty())
                        return string();
                // return the first we find
                return formats.front()->name();
        }
+       if (encoding().package() == Encoding::japanese)
+               return lyxrc.default_platex_view_format;
        if (useNonTeXFonts)
                return lyxrc.default_otf_view_format;
        return lyxrc.default_view_format;
@@ -3349,7 +3377,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 Encoding const & BufferParams::encoding() const
 {
        // Main encoding for LaTeX output.
-       // 
+       //
        // Exception: XeTeX with 8-bit TeX fonts requires ASCII (see #9740).
        // As the "flavor" is only known once export started, this
        // cannot be handled here. Instead, runparams.encoding is set