]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
findadv: using \w instead of [[:word:]] makes test-case std::regex compatible; also...
[lyx.git] / src / BufferParams.cpp
index f20078bdff3e97cf742aec331ac7b9b4f055c3fb..1c00dbdd977f6c6f9523477cd03ecad27533e237 100644 (file)
@@ -342,6 +342,7 @@ public:
         */
        HSpace indentation;
        VSpace defskip;
+       HSpace math_indentation;
        PDFOptions pdfoptions;
        LayoutFileIndex baseClass_;
        FormatList exportableFormatList;
@@ -383,6 +384,8 @@ BufferParams::BufferParams()
        cite_engine_type_ = ENGINE_TYPE_DEFAULT;
        makeDocumentClass();
        paragraph_separation = ParagraphIndentSeparation;
+       is_math_indent = false;
+       math_indentation = "default";
        quotes_style = InsetQuotesParams::EnglishQuotes;
        dynamic_quotes = false;
        fontsize = "default";
@@ -415,6 +418,7 @@ BufferParams::BufferParams()
        fonts_default_family = "default";
        useNonTeXFonts = false;
        use_microtype = false;
+       use_dash_ligatures = true;
        fonts_expert_sc = false;
        fonts_old_figures = false;
        fonts_sans_scale[0] = 100;
@@ -625,6 +629,18 @@ PDFOptions const & BufferParams::pdfoptions() const
 }
 
 
+HSpace const & BufferParams::getMathIndentation() const
+{
+       return pimpl_->math_indentation;
+}
+
+
+void BufferParams::setMathIndentation(HSpace const & indent)
+{
+       pimpl_->math_indentation = indent;
+}
+
+
 HSpace const & BufferParams::getIndentation() const
 {
        return pimpl_->indentation;
@@ -812,6 +828,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> fonts_cjk;
        } else if (token == "\\use_microtype") {
                lex >> use_microtype;
+       } else if (token == "\\use_dash_ligatures") {
+               lex >> use_dash_ligatures;
        } else if (token == "\\paragraph_separation") {
                string parsep;
                lex >> parsep;
@@ -827,6 +845,12 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                if (pimpl_->defskip.kind() == VSpace::DEFSKIP)
                        // that is invalid
                        pimpl_->defskip = VSpace(VSpace::MEDSKIP);
+       } else if (token == "\\is_math_indent") {
+               lex >> is_math_indent;
+       } else if (token == "\\math_indentation") {
+               lex.next();
+               string math_indentation = lex.getString();
+               pimpl_->math_indentation = HSpace(math_indentation);
        } else if (token == "\\quotes_style") {
                string qstyle;
                lex >> qstyle;
@@ -1196,6 +1220,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                os << "\\font_cjk " << fonts_cjk << '\n';
        }
        os << "\\use_microtype " << convert<string>(use_microtype) << '\n';
+       os << "\\use_dash_ligatures " << convert<string>(use_dash_ligatures) << '\n';
        os << "\\graphics " << graphics_driver << '\n';
        os << "\\default_output_format " << default_output_format << '\n';
        os << "\\output_sync " << output_sync << '\n';
@@ -1322,6 +1347,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                os << "\n\\paragraph_indentation " << getIndentation().asLyXCommand();
        else
                os << "\n\\defskip " << getDefSkip().asLyXCommand();
+       os << "\n\\is_math_indent " << is_math_indent;
+       if (is_math_indent && getMathIndentation().asLyXCommand() != "default")
+               os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
        os << "\n\\quotes_style "
           << string_quotes_style[quotes_style]
           << "\n\\dynamic_quotes " << dynamic_quotes
@@ -1603,6 +1631,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
            && orientation == ORIENTATION_LANDSCAPE)
                clsoptions << "landscape,";
 
+       if (is_math_indent)
+               clsoptions << "fleqn,";
+
        // language should be a parameter to \documentclass
        if (language->babel() == "hebrew"
            && default_language->babel() != "hebrew")
@@ -1927,6 +1958,16 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                }
        }
 
+       if (is_math_indent) {
+               // when formula indentation
+               // only output something when it is not the default
+               if (getMathIndentation().asLyXCommand() != "default") {
+                       os << "\\setlength{\\mathindent}{"
+                          << from_utf8(getMathIndentation().asLatexCommand())
+                          << "}\n";
+               }
+       }
+
        // Now insert the LyX specific LaTeX commands...
        features.resolveAlternatives();
        features.expandMultiples();