From: Georg Baum Date: Thu, 18 Oct 2012 18:41:23 +0000 (+0200) Subject: Add automatic color package loading for listings X-Git-Tag: 2.1.0beta1~1369 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=75ba5d3db521c426b18b1991dbbde0ebd6a3298f;p=features.git Add automatic color package loading for listings 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. --- diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index f103f3a596..deed8a7cdb 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -1037,7 +1037,7 @@ Listings Inline: \begin_inset listings -lstparams "language={C++}" +lstparams "language={C++},keywordstyle={\color{green}}" inline true status collapsed diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index 508d19f827..78fb5f0751 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -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] diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 7f7603c198..88e10966e8 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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";