diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 2b804d5ce1..0a9fb7186a 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -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 diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index bd6114dfad..d6a4f89fe9 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -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 diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index cf1374463b..1957633c20 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -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 diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index dca1b6cf66..48c416dc0e 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -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(), diff --git a/src/TextClass.cpp b/src/TextClass.cpp index cc8fb993bb..12625dc0aa 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -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 { diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index b9d5b2dc4e..6b30f5a37b 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -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("
"), 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 const req + vector 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()) diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index cf5647dbc3..d2e6458c2d 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -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_;