The branch, master, has been updated.

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

commit 1d6573a330791fb34541f4092cd49e4559972489
Author: Uwe Stöhr <[email protected]>
Date:   Sun Feb 17 06:18:42 2013 +0100

    tex2lyx: support for multiple indices and subindices

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 148c9ab..4b4bb73 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -185,6 +185,9 @@ const char * const known_lyx_packages[] = {"amsbsy", 
"amsmath", "amssymb",
 "setspace", "subscript", "textcomp", "tipa", "tipx", "ulem", "url", "varioref",
 "verbatim", "wrapfig", "xunicode", 0};
 
+// used for the handling of \newindex
+int index_number = 0;
+
 // codes used to remove packages that are loaded automatically by LyX.
 // Syntax: package_beg_sep<name>package_mid_sep<package loading 
code>package_end_sep
 const char package_beg_sep = '\001';
@@ -469,7 +472,7 @@ Preamble::Preamble() : one_language(true), 
title_layout_found(false),
        h_html_be_strict          = "false";
        h_html_css_as_file        = "0";
        h_html_math_output        = "0";
-       h_index                   = "Index";
+       h_index[0]                = "Index";
        h_index_command           = "default";
        h_inputencoding           = "auto";
        h_justification           = "true";
@@ -508,7 +511,7 @@ Preamble::Preamble() : one_language(true), 
title_layout_found(false),
        //h_pdf_quoted_options;
        h_quotes_language         = "english";
        h_secnumdepth             = "3";
-       h_shortcut                = "idx";
+       h_shortcut[0]             = "idx";
        h_spacing                 = "single";
        h_suppress_date           = "false";
        h_textclass               = "article";
@@ -1141,10 +1144,19 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
                os << "\\backgroundcolor " << h_backgroundcolor << '\n';
        if (!h_boxbgcolor.empty())
                os << "\\boxbgcolor " << h_boxbgcolor << '\n';
-       os << "\\index " << h_index << '\n'
-          << "\\shortcut " << h_shortcut << '\n'
-          << "\\color " << h_color << '\n'
-          << "\\end_index\n";
+       if (index_number != 0)
+               for (int i = 0; i < index_number; i++) {
+                       os << "\\index " << h_index[i] << '\n'
+                          << "\\shortcut " << h_shortcut[i] << '\n'
+                          << "\\color " << h_color << '\n'
+                          << "\\end_index\n";
+               }
+       else {
+               os << "\\index " << h_index[0] << '\n'
+                  << "\\shortcut " << h_shortcut[0] << '\n'
+                  << "\\color " << h_color << '\n'
+                  << "\\end_index\n";
+       }
        os << h_margins
           << "\\secnumdepth " << h_secnumdepth << "\n"
           << "\\tocdepth " << h_tocdepth << "\n"
@@ -1369,6 +1381,23 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                        p.setCatcode('@', catOther);
                }
 
+               else if (t.cs() == "makeindex") {
+                       // LyX will re-add this if a print index command is 
found
+                       p.skip_spaces();
+               }
+
+               else if (t.cs() == "newindex") {
+                       string const indexname = p.getArg('[', ']');
+                       string const shortcut = p.verbatim_item();
+                       if (!indexname.empty())
+                               h_index[index_number] = indexname;
+                       else
+                               h_index[index_number] = shortcut;
+                       h_shortcut[index_number] = shortcut;
+                       index_number += 1;
+                       p.skip_spaces();
+               }
+
                else if (t.cs() == "RS@ifundefined") {
                        string const name = p.verbatim_item();
                        string const body1 = p.verbatim_item();
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index e10c96d..f86c414 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -138,7 +138,7 @@ private:
        std::string h_html_be_strict;
        std::string h_html_css_as_file;
        std::string h_html_math_output;
-       std::string h_index;
+       std::string h_index[99];
        std::string h_index_command;
        std::string h_inputencoding;
        std::string h_justification;
@@ -178,7 +178,7 @@ private:
        std::string h_pdf_quoted_options;
        std::string h_quotes_language;
        std::string h_secnumdepth;
-       std::string h_shortcut;
+       std::string h_shortcut[99];
        std::string h_spacing;
        std::string h_suppress_date;
        std::string h_textclass;
diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index ee197f4..f4f9009 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -29,8 +29,6 @@ Format LaTeX feature                        LyX feature
 329    master documents                     \master
 332    ?                                    InsetGraphics groupId
 343    ?                                    \use_default_options
-353    \printsubindex                       InsetIndex
-354    \printindex*, \printsubindex*        InsetIndex
 358    custom bibtex command                \bibtex_command
 358    custom makeindex command             \index_command
 363    horizontal longtable alignment       InsetTabular
diff --git a/src/tex2lyx/test/Dummy Document.lyx b/src/tex2lyx/test/Dummy 
Document.lyx
index 22e0ee6..f9a4d91 100644
--- a/src/tex2lyx/test/Dummy Document.lyx       
+++ b/src/tex2lyx/test/Dummy Document.lyx       
@@ -60,6 +60,14 @@
 \shortcut idx
 \color #008000
 \end_index
+\index new
+\shortcut new
+\color #008000
+\end_index
+\index test
+\shortcut test
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
diff --git a/src/tex2lyx/test/DummyDocument.lyx 
b/src/tex2lyx/test/DummyDocument.lyx
index 948e959..92ec53c 100644
--- a/src/tex2lyx/test/DummyDocument.lyx
+++ b/src/tex2lyx/test/DummyDocument.lyx
@@ -60,6 +60,14 @@
 \shortcut idx
 \color #008000
 \end_index
+\index new
+\shortcut new
+\color #008000
+\end_index
+\index test
+\shortcut test
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
diff --git a/src/tex2lyx/test/Dummy~Document.lyx 
b/src/tex2lyx/test/Dummy~Document.lyx
index a879813..da5ab72 100644
--- a/src/tex2lyx/test/Dummy~Document.lyx
+++ b/src/tex2lyx/test/Dummy~Document.lyx
@@ -60,6 +60,14 @@
 \shortcut idx
 \color #008000
 \end_index
+\index new
+\shortcut new
+\color #008000
+\end_index
+\index test
+\shortcut test
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index cbe3736..b5dcfef 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -66,6 +66,14 @@
 \shortcut idx
 \color #008000
 \end_index
+\index new
+\shortcut new
+\color #008000
+\end_index
+\index test
+\shortcut test
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
@@ -6257,7 +6265,22 @@ options "bibtotoc,test"
 \end_layout
 
 \begin_layout Standard
-normal index:
+undefined index:
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset CommandInset index_print
+LatexCommand printindex
+type "idx"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+index "idx":
 \end_layout
 
 \begin_layout Standard
@@ -6272,6 +6295,64 @@ type "idx"
 \end_layout
 
 \begin_layout Standard
+index "new":
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset CommandInset index_print
+LatexCommand printindex
+type "new"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+subindex "new":
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset CommandInset index_print
+LatexCommand printsubindex
+type "idx"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+index of all indices:
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset CommandInset index_print
+LatexCommand printindex*
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+subindex of all indices:
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset CommandInset index_print
+LatexCommand printsubindex*
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
 normal nomenclature:
 \end_layout
 
diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex
index 9d70ad8..cbbce83 100644
--- a/src/tex2lyx/test/test-insets.tex
+++ b/src/tex2lyx/test/test-insets.tex
@@ -21,7 +21,9 @@
 \usepackage{prettyref}
 \usepackage{splitidx}
 \makeindex
-
+\newindex[Index]{idx}
+\newindex[new]{new}
+\newindex{test}
 \usepackage{graphicx}
 \usepackage{longtable}
 \usepackage{xargs}
@@ -611,10 +613,30 @@ with \textbackslash{}addcontentsline and 
\textbackslash{}nocite\{{*}\}:
 \bibliography{xampl}
 
 
-normal index:
+undefined index:
 
 \printindex{}
 
+index "idx":
+
+\printindex[idx]{}
+
+index "new":
+
+\printindex[new]{}
+
+subindex "new":
+
+\printsubindex[idx]{}
+
+index of all indices:
+
+\printindex*{}
+
+subindex of all indices:
+
+\printsubindex*{}
+
 normal nomenclature:
 
 \printnomenclature hello
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 6ac1888..6c84024 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3526,10 +3526,23 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        end_inset(os);
                }
 
-               else if (t.cs() == "printindex") {
+               else if (t.cs() == "printindex" || t.cs() == "printsubindex") {
                        context.check_layout(os);
-                       begin_command_inset(os, "index_print", "printindex");
-                       os << "type \"idx\"\n";
+                       string commandname = t.cs();
+                       bool star = false;
+                       if (p.next_token().asInput() == "*") {
+                               commandname += "*";
+                               star = true;
+                               p.get_token();
+                       }
+                       begin_command_inset(os, "index_print", commandname);
+                       string const indexname = p.getArg('[', ']');
+                       if (!star) {
+                               if (indexname.empty())
+                                       os << "type \"idx\"\n";
+                               else
+                                       os << "type \"" << indexname << "\"\n";
+                       }
                        end_inset(os);
                        skip_spaces_braces(p);
                        preamble.registerAutomaticallyLoadedPackage("makeidx");

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

Summary of changes:
 src/tex2lyx/Preamble.cpp             |   41 ++++++++++++++---
 src/tex2lyx/Preamble.h               |    4 +-
 src/tex2lyx/TODO.txt                 |    2 -
 src/tex2lyx/test/Dummy Document.lyx  |    8 +++
 src/tex2lyx/test/DummyDocument.lyx   |    8 +++
 src/tex2lyx/test/Dummy~Document.lyx  |    8 +++
 src/tex2lyx/test/test-insets.lyx.lyx |   83 +++++++++++++++++++++++++++++++++-
 src/tex2lyx/test/test-insets.tex     |   26 ++++++++++-
 src/tex2lyx/text.cpp                 |   19 +++++++-
 9 files changed, 183 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to