]> git.lyx.org Git - features.git/commitdiff
Add automatic color package loading for listings
authorGeorg Baum <baum@lyx.org>
Thu, 18 Oct 2012 18:41:23 +0000 (20:41 +0200)
committerGeorg Baum <baum@lyx.org>
Thu, 18 Oct 2012 18:41:23 +0000 (20:41 +0200)
The listings inset does automatically load the color package if any parameter
contains \color. As mentioned in bug #8066 tex2lyx needs to be aware of this,
so the \usepckage{color} is automatically skipped in these cases.

src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index f103f3a59673fb342691e6dc715698665185c190..deed8a7cdb6fd54d298907d4e8ffeda6d5de1347 100644 (file)
@@ -1037,7 +1037,7 @@ Listings
 
 Inline: 
 \begin_inset listings
-lstparams "language={C++}"
+lstparams "language={C++},keywordstyle={\color{green}}"
 inline true
 status collapsed
 
index 508d19f82771ece65529973ede67549fc8245a3c..78fb5f075177c94ad755fce45f6d946c9a71a28e 100644 (file)
@@ -181,7 +181,7 @@ parser test (escaped):\href{http://www.test.test}{a brace \} and another one \{
 
 \section{Listings}
 
-Inline: \lstinline[language={C++}]!int a=5;!\\
+Inline: \lstinline[language={C++},keywordstyle={\color{green}}]!int a=5;!\\
 Float:
 
 \begin{lstlisting}[caption={Example Listing float},label={lst:Example-Listing},language=Python]
index 7f7603c198b244057a8495edc381fd763e47db23..88e10966e82a55060d1dd18bf627cfed8ff00a4f 100644 (file)
@@ -1154,6 +1154,8 @@ void parse_listings(Parser & p, ostream & os, Context & parent_context, bool in_
        if (p.hasOpt()) {
                string arg = p.verbatimOption();
                os << "lstparams " << '"' << arg << '"' << '\n';
+               if (arg.find("\\color") != string::npos)
+                       preamble.registerAutomaticallyLoadedPackage("color");
        }
        if (in_line)
                os << "inline true\n";