The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 75ba5d3db521c426b18b1991dbbde0ebd6a3298f
Author: Georg Baum <[email protected]>
Date:   Thu Oct 18 20:41:23 2012 +0200

    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 f103f3a..deed8a7 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 508d19f..78fb5f0 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 7f7603c..88e1096 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";

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/test/test-insets.lyx.lyx |    2 +-
 src/tex2lyx/test/test-insets.tex     |    2 +-
 src/tex2lyx/text.cpp                 |    2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to