]> git.lyx.org Git - lyx.git/commitdiff
Replace hardcoded hack with InsetLayout tag
authorGeorg Baum <baum@lyx.org>
Sun, 11 Jan 2015 19:00:45 +0000 (20:00 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 11 Jan 2015 19:01:19 +0000 (20:01 +0100)
lib/doc/Customization.lyx
lib/layouts/stdinsets.inc
lib/scripts/layout2layout.py
src/LaTeXFeatures.cpp
src/TextClass.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h

index 2b804d5ce136f72e674ba85c1180d660adcfe1f6..0a9fb7186af45500557c1b785d91c2e5018a9b53 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.2 created this file. For more info see http://www.lyx.org/
-\lyxformat 479
+\lyxformat 480
 \begin_document
 \begin_header
 \textclass scrbook
@@ -151,6 +151,7 @@ End
 \html_css_as_file 0
 \html_be_strict true
 \author -712698321 "Jürgen Spitzmüller" 
+\author -195340706 "Georg Baum" 
 \author 274215730 "scott" 
 \end_header
 
@@ -16901,6 +16902,86 @@ LabelFont
 \end_inset
 
  later if you want them to be different.
+\change_inserted -195340706 1421002157
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -195340706 1421002157
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -195340706 1421002157
+FixedWidthPreambleEncoding
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -195340706 1421002157
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -195340706 1421002157
+1
+\end_layout
+
+\end_inset
+
+] Force a fixed width encoding for the translated contents of 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -195340706 1421002157
+BabelPreamble
+\end_layout
+
+\end_inset
+
+ and 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -195340706 1421002157
+LangPreamble
+\end_layout
+
+\end_inset
+
+ code generated by this layout.
+ This is needed for special packages like the listings package that do not
+ work with variable width encodings such as utf8.
+ Default is false.
+ This setting is ignored if fully unicode aware LaTeX backends such as XeLaTeX
+ are used.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
index bd6114dfad5852cfd72850f6a71f24678789db02..d6a4f89fe91613e1cb3d21ad7620b08d24e31be8 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Detailed format description is available in the customization manual
 
-Format 53
+Format 54
 
 Provides stdinsets 1
 
@@ -267,6 +267,7 @@ InsetLayout TOC:Listings
        LangPreamble
                \renewcommand{\lstlistlistingname}{_(Listings[[List of Listings]])}
        EndLangPreamble
+       FixedWidthPreambleEncoding true
   HTMLTag h2
   HTMLStyle
     div.lyxtoc-flat {
@@ -287,6 +288,7 @@ InsetLayout Include:Listings
        LangPreamble
                \renewcommand{\lstlistingname}{_(Listing)}
        EndLangPreamble
+       FixedWidthPreambleEncoding true
 End
 
 InsetLayout Listings
index cf1374463b3e4b516854842c8e6cd4735e0bb7df..1957633c206b1d9bcc4f785df82ef3a3099bf9dd 100644 (file)
@@ -177,6 +177,9 @@ import os, re, string, sys
 # Incremented to format 53, 7 December 2014 by spitz
 # New InsetLayout tag "ObsoletedBy"
 
+# Incremented to format 54, 11 Jan 2014 by gb
+# New InsetLayout tag "FixedWidthPreambleEncoding"
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -184,7 +187,7 @@ import os, re, string, sys
 # development/tools/updatelayouts.py script to update all
 # layout files to the new format.
 
-currentFormat = 53
+currentFormat = 54
 
 
 def usage(prog_name):
@@ -408,7 +411,7 @@ def convert(lines):
                 i += 1
             continue
 
-        if format >= 50 and format <= 52:
+        if format >= 50 and format <= 53:
             # nothing to do.
             i += 1
             continue
index dca1b6cf66704c5d934da66b223a751c3b39988a..48c416dc0e778f96c7a564743d89497797299fb3 100644 (file)
@@ -1569,11 +1569,7 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
                // need to force a fixed width encoding for
                // \lstlistlistingname and \lstlistingname (bug 9382).
                // This needs to be consistent with InsetListings::latex().
-               docstring const ilname = it->second.name();
-               bool const need_fixedwidth = !runparams_.isFullUnicode() &&
-                               (ilname == "Listings" ||
-                                ilname == "Include:Listings" ||
-                                ilname == "TOC:Listings");
+               bool const need_fixedwidth = it->second.fixedwidthpreambleencoding();
                // language dependent commands (once per document)
                snippets.insert(i18npreamble(it->second.langpreamble(),
                                                buffer().language(),
index cc8fb993bbe9de3d86b76f5355a93a835b5607c7..12625dc0aa17e7e6e637f513e2c889d5878ea428 100644 (file)
@@ -61,7 +61,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 53; //spitz: add ObsoletedBy tag for InsetLayouts
+int const LAYOUT_FORMAT = 54; //gb: add FixedWidthPreambleEncoding tag for InsetLayouts
 
 namespace {
 
index b9d5b2dc4e6d78aab7d98b30cf3e8ceac07533ae..6b30f5a37b9f5aa2a240c7f213337e633d06a443 100644 (file)
@@ -34,20 +34,21 @@ namespace lyx {
 InsetLayout::InsetLayout() :
        name_(from_ascii("undefined")), lyxtype_(STANDARD),
        labelstring_(from_ascii("UNDEFINED")), contentaslabel_(false),
-       decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(inherit_font), 
-       labelfont_(sane_font), bgcolor_(Color_error), 
-       htmlforcecss_ (false), htmlisblock_(true),
-       multipar_(true), custompars_(true), forceplain_(false), 
-       passthru_(false), parbreakisnewline_(false), freespacing_(false), 
-       keepempty_(false), forceltr_(false), forceownlines_(false),
-       needprotect_(false), intoc_(false), spellcheck_(true), 
-       resetsfont_(false), display_(true), forcelocalfontswitch_(false)
+       decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(inherit_font),
+       labelfont_(sane_font), bgcolor_(Color_error),
+       fixedwidthpreambleencoding_(false), htmlforcecss_ (false),
+       htmlisblock_(true), multipar_(true), custompars_(true),
+       forceplain_(false), passthru_(false), parbreakisnewline_(false),
+       freespacing_(false), keepempty_(false), forceltr_(false),
+       forceownlines_(false), needprotect_(false), intoc_(false),
+       spellcheck_(true), resetsfont_(false), display_(true),
+       forcelocalfontswitch_(false)
 {
        labelfont_.setColor(Color_error);
 }
 
 
-InsetLayout::InsetDecoration translateDecoration(std::string const & str) 
+InsetLayout::InsetDecoration translateDecoration(std::string const & str)
 {
        if (support::compare_ascii_no_case(str, "classic") == 0)
                return InsetLayout::CLASSIC;
@@ -86,6 +87,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                IL_CUSTOMPARS,
                IL_DECORATION,
                IL_DISPLAY,
+               IL_FIXEDWIDTH_PREAMBLE_ENCODING,
                IL_FONT,
                IL_FORCE_LOCAL_FONT_SWITCH,
                IL_FORCELTR,
@@ -132,12 +134,13 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                { "babelpreamble", IL_BABELPREAMBLE },
                { "bgcolor", IL_BGCOLOR },
                { "contentaslabel", IL_CONTENTASLABEL },
-               { "copystyle", IL_COPYSTYLE }, 
+               { "copystyle", IL_COPYSTYLE },
                { "counter", IL_COUNTER},
                { "custompars", IL_CUSTOMPARS },
                { "decoration", IL_DECORATION },
                { "display", IL_DISPLAY },
                { "end", IL_END },
+               { "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING },
                { "font", IL_FONT },
                { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
                { "forceltr", IL_FORCELTR },
@@ -186,7 +189,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
        // for issuing a warning in case MultiPars comes later
        bool readCustomOrPlain = false;
 
-       string tmp;     
+       string tmp;
        while (!getout && lex.isOK()) {
                int le = lex.lex();
                switch (le) {
@@ -246,6 +249,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                        leftdelim_ = support::subst(leftdelim_, from_ascii("<br/>"),
                                                    from_ascii("\n"));
                        break;
+               case IL_FIXEDWIDTH_PREAMBLE_ENCODING:
+                       lex >> fixedwidthpreambleencoding_;
+                       break;
                case IL_FORCE_LOCAL_FONT_SWITCH:
                        lex >> forcelocalfontswitch_;
                        break;
@@ -313,7 +319,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
 
                        // We don't want to apply the algorithm in DocumentClass::insetLayout()
                        // here. So we do it the long way.
-                       TextClass::InsetLayouts::const_iterator it = 
+                       TextClass::InsetLayouts::const_iterator it =
                                        tclass.insetLayouts().find(style);
                        if (it != tclass.insetLayouts().end()) {
                                docstring const tmpname = name_;
@@ -324,9 +330,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                                        << style << "' to InsetLayout `"
                                        << name() << "'\n"
                                        << "All InsetLayouts so far:");
-                               TextClass::InsetLayouts::const_iterator lit = 
+                               TextClass::InsetLayouts::const_iterator lit =
                                                tclass.insetLayouts().begin();
-                               TextClass::InsetLayouts::const_iterator len = 
+                               TextClass::InsetLayouts::const_iterator len =
                                                tclass.insetLayouts().end();
                                for (; lit != len; ++lit)
                                        lyxerr << lit->second.name() << "\n";
@@ -354,9 +360,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                                        << "' with unknown InsetLayout `"
                                        << style << "'\n"
                                        << "All InsetLayouts so far:");
-                               TextClass::InsetLayouts::const_iterator lit = 
+                               TextClass::InsetLayouts::const_iterator lit =
                                                tclass.insetLayouts().begin();
-                               TextClass::InsetLayouts::const_iterator len = 
+                               TextClass::InsetLayouts::const_iterator len =
                                                tclass.insetLayouts().end();
                                for (; lit != len; ++lit)
                                        lyxerr << lit->second.name() << "\n";
@@ -427,7 +433,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                        break;
                case IL_REQUIRES: {
                        lex.eatLine();
-                       vector<string> const req 
+                       vector<string> const req
                                = support::getVectorFromString(lex.getString());
                        requires_.insert(req.begin(), req.end());
                        break;
@@ -450,7 +456,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
        // Here add element to list if getout == true
        if (!getout)
                return false;
-       
+
        // The label font is generally used as-is without
        // any realization against a given context.
        labelfont_.realize(sane_font);
@@ -460,9 +466,8 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
 }
 
 
-InsetLayout::InsetLyXType translateLyXType(std::string const & str) 
+InsetLayout::InsetLyXType translateLyXType(std::string const & str)
 {
-       
        if (support::compare_ascii_no_case(str, "charstyle") == 0)
                return InsetLayout::CHARSTYLE;
        if (support::compare_ascii_no_case(str, "custom") == 0)
@@ -481,7 +486,7 @@ string const & InsetLayout::htmltag() const
 {
        if (htmltag_.empty())
                htmltag_ = multipar_ ? "div" : "span";
-       return htmltag_; 
+       return htmltag_;
 }
 
 
@@ -489,7 +494,7 @@ string const & InsetLayout::htmlattr() const
 {
        if (htmlattr_.empty())
                htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
-       return htmlattr_; 
+       return htmlattr_;
 }
 
 
@@ -497,12 +502,12 @@ string const & InsetLayout::htmlinnerattr() const
 {
        if (htmlinnerattr_.empty())
                htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\"";
-       return htmlinnerattr_; 
+       return htmlinnerattr_;
 }
 
 
 string InsetLayout::defaultCSSClass() const
-{ 
+{
        if (!defaultcssclass_.empty())
                return defaultcssclass_;
        string d;
@@ -525,18 +530,18 @@ string InsetLayout::defaultCSSClass() const
 
 void InsetLayout::makeDefaultCSS() const
 {
-       if (!htmldefaultstyle_.empty()) 
+       if (!htmldefaultstyle_.empty())
                return;
        docstring const mainfontCSS = font_.asCSS();
        if (!mainfontCSS.empty())
-               htmldefaultstyle_ = 
+               htmldefaultstyle_ =
                                from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
                                mainfontCSS + from_ascii("\n}\n");
 }
 
 
-docstring InsetLayout::htmlstyle() const 
-{ 
+docstring InsetLayout::htmlstyle() const
+{
        if (!htmlstyle_.empty() && !htmlforcecss_)
                return htmlstyle_;
        if (htmldefaultstyle_.empty())
index cf5647dbc39b1132e8719acbf9573b7f15197b18..d2e6458c2d491dceb357879c9a29db7523a81e14 100644 (file)
@@ -108,6 +108,8 @@ public:
        /// this inset
        docstring const babelpreamble() const { return babelpreamble_; }
        ///
+       bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
+       ///
        docstring counter() const { return counter_; }
        ///
        docstring refprefix() const { return refprefix_; }
@@ -223,6 +225,8 @@ private:
        /// Language and babel dependent macro definitions needed for this inset
        docstring babelpreamble_;
        ///
+       bool fixedwidthpreambleencoding_;
+       ///
        docstring refprefix_;
        ///
        mutable std::string htmltag_;