Pavel Sanda wrote:
> Georg,
>
> would it be easy to add Listing into the layouttranslation machinery we
> automatically use on the LyX side?
Yes (see attachment). Two questions:
1) Why is features.useInsetLayout() not called for each inset in validate()?
2) Does anything break if I make InsetInclude::layoutName() return
"Listings" for listing includes instead of the ugly hack in
InsetInclude::validate()?
While testing I also noticed that LyX would sometimes overwrite the exported
.tex without wraning, but I could not see a pattern. Is that known?
Georg
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index c3024df..f97cd15 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -14255,6 +14255,31 @@ InsetLayout
\end_layout
\begin_layout Description
+\change_inserted -195340706 1333913893
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+BabelPreamble
+\end_layout
+
+\end_inset
+
+ Preamble for changing languages. See section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:I18n"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Description
\begin_inset Flex Code
status collapsed
@@ -14904,6 +14929,34 @@ Branch
\end_inset
) modify this label on the fly.
+
+\end_layout
+
+\begin_layout Description
+\change_inserted -195340706 1333913893
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+LangPreamble
+\end_layout
+
+\end_inset
+
+ Language dependent preamble. See section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:I18n"
+
+\end_inset
+
+.
+
\end_layout
\begin_layout Description
diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index 28a08ab..2213612 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 36
+Format 38
Provides stdinsets 1
@@ -190,6 +190,9 @@ InsetLayout Listings
FreeSpacing true
ForceLTR true
RefPrefix lst
+ BabelPreamble
+ \addto\captions$$lang{\renewcommand{\lstlistingname}{_(Listing)}}
+ EndBabelPreamble
End
InsetLayout Branch
diff --git a/lib/layouttranslations b/lib/layouttranslations
index 2c9f81c..6174c81 100644
--- a/lib/layouttranslations
+++ b/lib/layouttranslations
@@ -30,6 +30,7 @@ Translation ar
"List of Graphs" "ÙائÙ
Ø© اÙرسÙÙ
اÙبÙاÙÙØ©"
"List of Schemes" "ÙائÙ
Ø© اÙتصÙ
ÙÙ
ات"
"List of Tableaux" "ÙائÙ
Ø© اÙجداÙÙ"
+ "Listing" "عÙ
Ù ÙÙائÙ
"
"Notation" "تدÙÙÙ"
"Note" "Ù
ÙاØظة"
"Problem" "Ù
Ø´ÙÙØ©"
@@ -106,6 +107,7 @@ Translation ca
"List of Graphs" "List of Graphs"
"List of Schemes" "List of Schemes"
"List of Tableaux" "List of Tableaux"
+ "Listing" "Llistat"
"Notation" "Notació"
"Note" "Nota"
"Problem" "Problema"
@@ -145,6 +147,7 @@ Translation cs
"List of Graphs" "Seznam grafů"
"List of Schemes" "Seznam schémat"
"List of Tableaux" "Seznam tabel"
+ "Listing" "Výpis"
"Notation" "ZnaÄenÃ"
"Note" "Poznámka"
"Problem" "Ãloha"
@@ -184,6 +187,7 @@ Translation da
"List of Graphs" "Grafliste"
"List of Schemes" "Schemaliste"
"List of Tableaux" "Tableauliste"
+ "Listing" "Listing"
"Notation" "Notation"
"Note" "Notat"
"Problem" "Problem"
@@ -223,6 +227,7 @@ Translation de
"List of Graphs" "Liste der Graphen"
"List of Schemes" "Liste der Schemata"
"List of Tableaux" "Tableaux-Verzeichnis"
+ "Listing" "Listing"
"Notation" "Notation"
"Note" "Notiz"
"Problem" "Problem"
@@ -266,6 +271,7 @@ Translation el
"List of Graphs" "ÎίÏÏα ÎÏαÏημάÏÏν"
"List of Schemes" "ÎίÏÏα ΣÏεδίÏν"
"List of Tableaux" "ÎίÏÏα ΤαμÏλÏ"
+ "Listing" "ÎαÏαλογοÏοίηÏη"
"Notation" "ΣημειογÏαÏία"
"Note" "ΣημείÏÏη"
"Problem" "Î ÏÏβλημα"
@@ -305,6 +311,7 @@ Translation en
"List of Graphs" "List of Graphs"
"List of Schemes" "List of Schemes"
"List of Tableaux" "List of Tableaux"
+ "Listing" "Listing"
"Notation" "Notation"
"Note" "Note"
"Problem" "Problem"
@@ -344,6 +351,7 @@ Translation es
"List of Graphs" "Ãndice de gráficos"
"List of Schemes" "Ãndice de esquemas"
"List of Tableaux" "Ãndice de Tableaux"
+ "Listing" "Listado"
"Notation" "Notación"
"Note" "Nota"
"Problem" "Problema"
@@ -383,6 +391,7 @@ Translation eu
"List of Graphs" "Grafikoen zerrenda"
"List of Schemes" "Eskemen zerrenda"
"List of Tableaux" "Taulen zerrenda"
+ "Listing" "Zerrenda"
"Notation" "Notazioa"
"Note" "Ohar"
"Problem" "Buruketa"
@@ -422,6 +431,7 @@ Translation fi
"List of Graphs" "Kuvaajien luettelo"
"List of Schemes" "Kuvausten lettelo"
"List of Tableaux" "Taulujen luettelo"
+ "Listing" "Listaus"
"Notation" "Merkintätapa"
"Note" "Muistiinpano"
"Problem" "Ongelma"
@@ -461,6 +471,7 @@ Translation fr
"List of Graphs" "Liste des graphiques"
"List of Schemes" "Liste des schémas"
"List of Tableaux" "Liste des tableaux (TO)"
+ "Listing" "Listing"
"Notation" "Notation"
"Note" "Note"
"Problem" "Problème"
@@ -500,6 +511,7 @@ Translation gl
"List of Graphs" "List of Graphs"
"List of Schemes" "List of Schemes"
"List of Tableaux" "List of Tableaux"
+ "Listing" "Lista"
"Notation" "Notación"
"Note" "Nota"
"Problem" "Problema"
@@ -539,6 +551,7 @@ Translation he
"List of Graphs" "רש××ת ×רפ××"
"List of Schemes" "רש××ת ס×××ת"
"List of Tableaux" "List of Tableaux"
+ "Listing" "ר×ש×× ×§××"
"Notation" "צ×רת ר×ש××"
"Note" "×ער×"
"Problem" "××¢××"
@@ -578,6 +591,7 @@ Translation hu
"List of Graphs" "Grafikonok listája"
"List of Schemes" "Sémák listája"
"List of Tableaux" "Csoportképek listája"
+ "Listing" "Lista"
"Notation" "Jelölés"
"Note" "Megjegyzés"
"Problem" "Probléma"
@@ -617,6 +631,7 @@ Translation ia
"List of Graphs" "Lista de graphicos"
"List of Schemes" "Lista de schemas"
"List of Tableaux" "Lista de tableau"
+ "Listing" "Listar"
"Notation" "Notation"
"Note" "Nota"
"Problem" "Problema"
@@ -656,6 +671,7 @@ Translation id
"List of Graphs" "Daftar Grafik"
"List of Schemes" "Daftar Skema"
"List of Tableaux" "Daftar Tableaux"
+ "Listing" "Listing"
"Notation" "Notasi"
"Note" "Nota"
"Problem" "Masalah"
@@ -695,6 +711,7 @@ Translation it
"List of Graphs" "Elenco dei grafici"
"List of Schemes" "Elenco degli schemi"
"List of Tableaux" "Elenco dei tableau"
+ "Listing" "Listato"
"Notation" "Notazione"
"Note" "Nota"
"Problem" "Problema"
@@ -734,6 +751,7 @@ Translation ja
"List of Graphs" "ã°ã©ãä¸è¦§"
"List of Schemes" "ã¹ãã¼ã ä¸è¦§"
"List of Tableaux" "çµµç»ä¸è¦§"
+ "Listing" "ãªã¹ã"
"Notation" "è¨æ³"
"Note" "注é"
"Problem" "åé¡"
@@ -810,6 +828,7 @@ Translation nb
"List of Graphs" "Grafer"
"List of Schemes" "Struktruformler"
"List of Tableaux" "Tablåer"
+ "Listing" "«Listing»"
"Notation" "Notasjon"
"Note" "Merknad"
"Problem" "Problem"
@@ -849,6 +868,7 @@ Translation nl
"List of Graphs" "Grafiekenlijst"
"List of Schemes" "Schema-lijst"
"List of Tableaux" "Lijst van Tableaus"
+ "Listing" "Opsomming"
"Notation" "Notatie"
"Note" "Noot"
"Problem" "Opgave"
@@ -888,6 +908,7 @@ Translation nn
"List of Graphs" "Liste over grafar"
"List of Schemes" "Liste over skjema"
"List of Tableaux" "Liste over tablå"
+ "Listing" "Kodeliste"
"Notation" "Notasjon"
"Note" "Notis"
"Problem" "Problem"
@@ -927,6 +948,7 @@ Translation pl
"List of Graphs" "Lista grafów"
"List of Schemes" "Lista schematów"
"List of Tableaux" "List of Tableaux"
+ "Listing" "Listing"
"Notation" "Notacja"
"Note" "Notka"
"Problem" "Problem"
@@ -966,6 +988,7 @@ Translation pt
"List of Graphs" "Lista de Gráficos"
"List of Schemes" "Lista de Esquemas"
"List of Tableaux" "Lista de Quadros"
+ "Listing" "Listagem"
"Notation" "Notação"
"Note" "Nota"
"Problem" "Problema"
@@ -1010,6 +1033,7 @@ Translation ro
"List of Graphs" "ListÄ de Grafice"
"List of Schemes" "ListÄ de Scheme"
"List of Tableaux" "ListÄ de Tabele"
+ "Listing" "Listare"
"Notation" "NotaÈie"
"Note" "NotÄ"
"Problem" "ProblemÄ"
@@ -1049,6 +1073,7 @@ Translation ru
"List of Graphs" "СпиÑок гÑаÑиков"
"List of Schemes" "СпиÑок ÑÑ
ем"
"List of Tableaux" "СпиÑок ÑаблиÑ"
+ "Listing" "ÐиÑÑинг"
"Notation" "ÐоÑаÑиÑ"
"Note" "ÐамеÑка"
"Problem" "ÐÑоблема"
@@ -1088,6 +1113,7 @@ Translation sk
"List of Graphs" "Zoznam grafÃk"
"List of Schemes" "Zoznam náÄrtkov"
"List of Tableaux" "Zoznam tablov"
+ "Listing" "Výpis"
"Notation" "Notácia"
"Note" "Poznámka"
"Problem" "Problém"
@@ -1164,6 +1190,7 @@ Translation sr
"List of Graphs" "Spisak Grafikona"
"List of Schemes" "Spisak Å ema"
"List of Tableaux" "Spisak Tabela "
+ "Listing" "Listing"
"Notation" "Zabeleška"
"Note" "Napomena"
"Problem" "Problem"
@@ -1203,6 +1230,7 @@ Translation sv
"List of Graphs" "Lista över grafer"
"List of Schemes" "Lista över scheman"
"List of Tableaux" "Lista över tablåer"
+ "Listing" "Listning"
"Notation" "Notation"
"Note" "Not"
"Problem" "Problem"
@@ -1242,6 +1270,7 @@ Translation tr
"List of Graphs" "List of Graphs"
"List of Schemes" "Plan Listesi"
"List of Tableaux" "Tablo Listesi"
+ "Listing" "Liste"
"Notation" "Notasyon"
"Note" "Not"
"Problem" "Problem"
@@ -1281,6 +1310,7 @@ Translation uk
"List of Graphs" "СпиÑок гÑаÑÑкÑв"
"List of Schemes" "СпиÑок ÑÑ
ем"
"List of Tableaux" "СпиÑок Ñабло"
+ "Listing" "ТекÑÑ Ð¿ÑогÑами"
"Notation" "ÐознаÑеннÑ"
"Note" "ÐÑимÑÑка"
"Problem" "ÐÑоблема"
@@ -1320,6 +1350,7 @@ Translation zh_CN
"List of Graphs" "å¾å½¢å表"
"List of Schemes" "æ¹æ¡å表"
"List of Tableaux" "åºæ¯å表"
+ "Listing" "å表"
"Notation" "è®°å·"
"Note" "å¤å¿"
"Problem" "é®é¢"
@@ -1359,6 +1390,7 @@ Translation zh_TW
"List of Graphs" "List of Graphs"
"List of Schemes" "List of Schemes"
"List of Tableaux" "List of Tableaux"
+ "Listing" "å表"
"Notation" "è¨æ³"
"Note" "註è¨"
"Problem" "åé¡"
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 9de6c83..6eebac5 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -129,6 +129,9 @@ import os, re, string, sys
# Implement the citation engine machinery in layouts.
# Change CiteFormat to CiteFormat (default|authoryear|numerical).
+# Incremented to format 38, 08 April 2012 by gb
+# Introduce LangPreamble and BabelPreamble for InsetLayout.
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
@@ -136,7 +139,7 @@ import os, re, string, sys
# development/tools/updatelayouts.sh script to update all
# layout files to the new format.
-currentFormat = 37
+currentFormat = 38
def usage(prog_name):
@@ -322,6 +325,10 @@ def convert(lines):
i += 1
continue
+ if format == 37:
+ i += 1
+ continue
+
if format == 36:
match = re_CiteFormat.match(lines[i]);
if match and match.group(4) == "":
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index f1d315c..d5a0b6f 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -38,6 +38,7 @@
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
+#include "support/regex.h"
#include <algorithm>
@@ -1181,6 +1182,49 @@ docstring const getFloatI18nPreamble(docstring const & type,
<< "{\\renewcommand{\\" << type << "name}{" << translated << "}}\n";
return os.str();
}
+
+
+docstring const i18npreamble(docstring const & templ, Language const * lang,
+ Encoding const & enc, bool const polyglossia)
+{
+ if (templ.empty())
+ return templ;
+
+ string preamble = polyglossia ?
+ subst(to_utf8(templ), "$$lang", lang->polyglossia()) :
+ subst(to_utf8(templ), "$$lang", lang->babel());
+
+ string const langenc = lang->encoding()->iconvName();
+ string const texenc = lang->encoding()->latexName();
+ string const bufenc = enc.iconvName();
+ // First and second character of plane 15 (Private Use Area)
+ string const s1 = "\xf3\xb0\x80\x80"; // U+F0000
+ string const s2 = "\xf3\xb0\x80\x81"; // U+F0001
+ // FIXME UNICODE
+ // lyx::regex is not unicode-safe.
+ // Should use QRegExp or (boost::u32regex, but that requires ICU)
+ static regex const reg("_\\(([^\\)]+)\\)");
+ smatch sub;
+ while (regex_search(preamble, sub, reg)) {
+ string const key = sub.str(1);
+ docstring const name = lang->translateLayout(key);
+ // Check whether name can be encoded in the buffer encoding
+ bool encodable = true;
+ for (size_t i = 0; i < name.size(); ++i) {
+ if (!enc.encodable(name[i])) {
+ encodable = false;
+ break;
+ }
+ }
+ string const translated = encodable ? to_utf8(name)
+ : "\\inputencoding{" + texenc + "}"
+ + s1 + langenc + s2 + to_utf8(name)
+ + s1 + bufenc + s2;
+ preamble = subst(preamble, sub.str(), translated);
+ }
+ return from_utf8(preamble);
+}
+
}
@@ -1197,17 +1241,20 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit) {
// language dependent commands (once per document)
- snippets.insert(tclass[*cit].langpreamble(buffer().language(),
+ snippets.insert(i18npreamble(tclass[*cit].langpreamble(),
+ buffer().language(),
buffer().params().encoding(),
use_polyglossia));
// commands for language changing (for multilanguage documents)
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
- snippets.insert(tclass[*cit].babelpreamble(
+ snippets.insert(i18npreamble(
+ tclass[*cit].babelpreamble(),
buffer().language(),
buffer().params().encoding(),
use_polyglossia));
for (lang_it lit = lbeg; lit != lend; ++lit)
- snippets.insert(tclass[*cit].babelpreamble(
+ snippets.insert(i18npreamble(
+ tclass[*cit].babelpreamble(),
*lit,
buffer().params().encoding(),
use_polyglossia));
@@ -1251,6 +1298,34 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
}
}
+ cit = usedInsetLayouts_.begin();
+ end = usedInsetLayouts_.end();
+ TextClass::InsetLayouts const & ils = tclass.insetLayouts();
+ for (; cit != end; ++cit) {
+ TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
+ if (it == ils.end())
+ continue;
+ // language dependent commands (once per document)
+ snippets.insert(i18npreamble(it->second.langpreamble(),
+ buffer().language(),
+ buffer().params().encoding(),
+ use_polyglossia));
+ // commands for language changing (for multilanguage documents)
+ if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
+ snippets.insert(i18npreamble(
+ it->second.babelpreamble(),
+ buffer().language(),
+ buffer().params().encoding(),
+ use_polyglossia));
+ for (lang_it lit = lbeg; lit != lend; ++lit)
+ snippets.insert(i18npreamble(
+ it->second.babelpreamble(),
+ *lit,
+ buffer().params().encoding(),
+ use_polyglossia));
+ }
+ }
+
odocstringstream tcpreamble;
set<docstring>::const_iterator const send = snippets.end();
set<docstring>::const_iterator it = snippets.begin();
diff --git a/src/Layout.cpp b/src/Layout.cpp
index bd4c08b..ec6e2dc 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -24,7 +24,6 @@
#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/Messages.h"
-#include "support/regex.h"
#include "support/textutils.h"
@@ -859,72 +858,6 @@ void Layout::readSpacing(Lexer & lex)
}
-namespace {
-
-docstring const i18npreamble(Language const * lang, Encoding const & enc,
- docstring const & templ, bool const polyglossia)
-{
- if (templ.empty())
- return templ;
-
- string preamble = polyglossia ?
- subst(to_utf8(templ), "$$lang", lang->polyglossia()) :
- subst(to_utf8(templ), "$$lang", lang->babel());
-
-#ifdef TEX2LYX
- // tex2lyx does not have getMessages()
- LASSERT(false, /**/);
- (void)enc;
-#else
- string const langenc = lang->encoding()->iconvName();
- string const texenc = lang->encoding()->latexName();
- string const bufenc = enc.iconvName();
- // First and second character of plane 15 (Private Use Area)
- string const s1 = "\xf3\xb0\x80\x80"; // U+F0000
- string const s2 = "\xf3\xb0\x80\x81"; // U+F0001
- // FIXME UNICODE
- // lyx::regex is not unicode-safe.
- // Should use QRegExp or (boost::u32regex, but that requires ICU)
- static regex const reg("_\\(([^\\)]+)\\)");
- smatch sub;
- while (regex_search(preamble, sub, reg)) {
- string const key = sub.str(1);
- docstring const name = lang->translateLayout(key);
- // Check whether name can be encoded in the buffer encoding
- bool encodable = true;
- for (size_t i = 0; i < name.size(); ++i) {
- if (!enc.encodable(name[i])) {
- encodable = false;
- break;
- }
- }
- string const translated = encodable ? to_utf8(name)
- : "\\inputencoding{" + texenc + "}"
- + s1 + langenc + s2 + to_utf8(name)
- + s1 + bufenc + s2;
- preamble = subst(preamble, sub.str(), translated);
- }
-#endif
- return from_utf8(preamble);
-}
-
-}
-
-
-docstring const Layout::langpreamble(Language const * lang,
- Encoding const & enc, bool const polyglossia) const
-{
- return i18npreamble(lang, enc, langpreamble_, polyglossia);
-}
-
-
-docstring const Layout::babelpreamble(Language const * lang,
- Encoding const & enc, bool const polyglossia) const
-{
- return i18npreamble(lang, enc, babelpreamble_, polyglossia);
-}
-
-
string const & Layout::htmltag() const
{
if (htmltag_.empty())
diff --git a/src/Layout.h b/src/Layout.h
index 1db9a23..08c049d 100644
--- a/src/Layout.h
+++ b/src/Layout.h
@@ -14,7 +14,6 @@
#ifndef LAYOUT_H
#define LAYOUT_H
-#include "Encoding.h"
#include "FontInfo.h"
#include "LayoutEnums.h"
#include "Spacing.h"
@@ -25,7 +24,6 @@
namespace lyx {
-class Language;
class Lexer;
class TextClass;
@@ -96,10 +94,10 @@ public:
docstring const & preamble() const { return preamble_; }
/// Get language dependent macro definitions needed for this layout
/// for language \p lang
- docstring const langpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
+ docstring const langpreamble() const { return langpreamble_; }
/// Get language and babel dependent macro definitions needed for
/// this layout for language \p lang
- docstring const babelpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
+ docstring const babelpreamble() const { return babelpreamble_; }
///
std::set<std::string> const & requires() const { return requires_; }
///
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 2d49a4d..82740cb 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -57,10 +57,10 @@ namespace lyx {
// could. See LayoutFileList::addEmptyClass() and, especially, the
// definition of the layoutpost string.
// You should also run (or ask someone who has bash to run) the
-// development/updatelayouts.sh script, to update the format of
+// development/tools/updatelayouts.sh script, to update the format of
// all of our layout files.
//
-int const LAYOUT_FORMAT = 37; //jrioux : move citation engine stuff into layouts
+int const LAYOUT_FORMAT = 38; //gb : LangPreamble and BabelPreamble for InsetLayout
namespace {
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index e7f9da3..542d128 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -907,8 +907,12 @@ void InsetInclude::validate(LaTeXFeatures & features) const
if (isVerbatim(params()))
features.require("verbatim");
- else if (isListings(params()))
+ else if (isListings(params())) {
+ InsetLayout const & insetlayout = buffer().params()
+ .documentClass().insetLayout(from_ascii("Listings"));
+ features.useInsetLayout(insetlayout);
features.require("listings");
+ }
// Here we must do the fun stuff...
// Load the file in the include if it needs
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index dee7e29..01642d8 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -75,6 +75,7 @@ InsetLayout::InsetLaTeXType translateLaTeXType(std::string const & str)
bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{
enum {
+ IL_BABELPREAMBLE,
IL_BGCOLOR,
IL_CONTENTASLABEL,
IL_COPYSTYLE,
@@ -98,6 +99,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
IL_INTOC,
IL_LABELFONT,
IL_LABELSTRING,
+ IL_LANGPREAMBLE,
IL_LATEXNAME,
IL_LATEXPARAM,
IL_LATEXTYPE,
@@ -117,6 +119,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
LexerKeyword elementTags[] = {
+ { "babelpreamble", IL_BABELPREAMBLE },
{ "bgcolor", IL_BGCOLOR },
{ "contentaslabel", IL_CONTENTASLABEL },
{ "copystyle", IL_COPYSTYLE },
@@ -142,6 +145,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{ "keepempty", IL_KEEPEMPTY },
{ "labelfont", IL_LABELFONT },
{ "labelstring", IL_LABELSTRING },
+ { "langpreamble", IL_LANGPREAMBLE },
{ "latexname", IL_LATEXNAME },
{ "latexparam", IL_LATEXPARAM },
{ "latextype", IL_LATEXTYPE },
@@ -311,6 +315,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
case IL_PREAMBLE:
preamble_ = from_utf8(lex.getLongString("EndPreamble"));
break;
+ case IL_BABELPREAMBLE:
+ babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
+ break;
+ case IL_LANGPREAMBLE:
+ langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
+ break;
case IL_REFPREFIX:
lex >> refprefix_;
break;
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 5b88cb8..4619abc 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -82,6 +82,11 @@ public:
ColorCode bgcolor() const { return bgcolor_; }
///
docstring preamble() const { return preamble_; }
+ /// Get language dependent macro definitions needed for this inset
+ docstring const langpreamble() const { return langpreamble_; }
+ /// Get language and babel dependent macro definitions needed for
+ /// this inset
+ docstring const babelpreamble() const { return babelpreamble_; }
///
docstring counter() const { return counter_; }
///
@@ -183,6 +188,10 @@ private:
docstring counter_;
///
docstring preamble_;
+ /// Language dependent macro definitions needed for this inset
+ docstring langpreamble_;
+ /// Language and babel dependent macro definitions needed for this inset
+ docstring babelpreamble_;
///
docstring refprefix_;
///
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index 0d61af6..7ae91e2 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -356,6 +356,7 @@ docstring const InsetListings::buttonLabel(BufferView const & bv) const
void InsetListings::validate(LaTeXFeatures & features) const
{
+ features.useInsetLayout(getLayout());
features.require("listings");
string param_string = params().params();
if (param_string.find("\\color") != string::npos)