]> git.lyx.org Git - lyx.git/commitdiff
\use_nomentbl -> \nomencl_opts
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 22 Aug 2024 03:35:47 +0000 (05:35 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 22 Aug 2024 03:35:47 +0000 (05:35 +0200)
This allows for support of more options

As the param is only a few hours old, no lyx2lyx handling is needed

lib/lyx2lyx/lyx_2_5.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/LaTeXFeatures.cpp
src/frontends/qt/GuiIndices.cpp
src/insets/InsetNomencl.cpp
src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/text.cpp

index cd224fe946991d836446c150fceb16cc45786e2f..74a74339c7add0dbed1ea0857a8485fb0e898092 100644 (file)
@@ -717,18 +717,23 @@ def revert_index_sc(document):
 def revert_nomentbl(document):
     """Revert nomentbl inset to ERT."""
 
-    i = find_token(document.header, "\\use_nomentbl", 0)
+    # intermediate format
+    i = find_token(document.header, "\\nomencl_options", 0)
     if i == -1:
-        document.warning("Malformed document! Missing \\use_nomentbl")
-        return
-    if get_value(document.header, "\\use_nomentbl", i) == 0:
-        # just remove header
-        del document.header[i]
+        # nothing to do
         return
 
+    opts = get_value(document.header, "\\nomencl_options", i)
     # remove header
     del document.header[i]
 
+    # store options
+    document.append_local_layout([r"### Inserted by lyx2lyx (nomencl) ###",
+                                  r"PackageOptions nomencl %s" % opts])
+
+    if opts.find("nomentbl") == -1:
+        return
+    
     # revert insets to ERT
     have_nomencl = False
     i = 0
@@ -853,10 +858,6 @@ def revert_nomentbl(document):
         document.body[i : j + 1] = res
 
         i += 1
-        
-    if have_nomencl:
-        document.append_local_layout([r"### Inserted by lyx2lyx (nomencl) ###",
-                                      r"PackageOptions nomencl nomentbl"])
 
 
 ##
index cdbfe5f0e229ca06a9fe84d5d42c930f5460f995..6adafdf18ecfeaf5afd6173cea26750b50fb4706 100644 (file)
@@ -969,6 +969,7 @@ int Buffer::readHeader(Lexer & lex)
        params().biblatex_citestyle.erase();
        params().multibib.erase();
        params().lineno_opts.clear();
+       params().nomencl_opts.clear();
        params().spellignore().clear();
 
        for (int i = 0; i < 4; ++i) {
index 8f1563e5167aa1ca1e9df20cb8e0921f37cfce4f..f14ae84190e84a349455bc5be95358ce39c2275e 100644 (file)
@@ -492,7 +492,6 @@ BufferParams::BufferParams()
        use_formatted_ref = false;
        use_minted = false;
        use_lineno = false;
-       use_nomentbl = false;
 
        // map current author
        author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
@@ -1212,8 +1211,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> use_formatted_ref;
        } else if (token == "\\use_minted") {
                lex >> use_minted;
-       } else if (token == "\\use_nomentbl") {
-               lex >> use_nomentbl;
+       } else if (token == "\\nomencl_options") {
+               lex.eatLine();
+               nomencl_opts = trim(lex.getString());
        } else if (token == "\\use_lineno") {
                lex >> use_lineno;
        } else if (token == "\\lineno_options") {
@@ -1442,13 +1442,15 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\use_refstyle " << use_refstyle
           << "\n\\use_formatted_ref " << use_formatted_ref
           << "\n\\use_minted " << use_minted
-          << "\n\\use_nomentbl " << use_nomentbl
           << "\n\\use_lineno " << use_lineno
           << '\n';
 
        if (!lineno_opts.empty())
                os << "\\lineno_options " << lineno_opts << '\n';
 
+       if (!nomencl_opts.empty())
+               os << "\\nomencl_options " << nomencl_opts << '\n';
+
        if (isbackgroundcolor)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
        if (isfontcolor)
index bef948330c4f4bcb25781ad40503f68fae1eef16..d7400e2f36407069303f5c11a7c72d7ed2ee1184 100644 (file)
@@ -623,8 +623,8 @@ public:
        bool use_lineno;
        /// optional params for lineno package
        std::string lineno_opts;
-       /// use nomentbl nomenclature sty
-       bool use_nomentbl;
+       /// options for nomencl package
+       std::string nomencl_opts;
 
        /// Return true if language could be set to lang,
        /// otherwise return false and do not change language
index b4234372696d13071401a204b04d74548792cd6f..a6fc73ecc9e1d18ac8f1fab6b7e7520ee4bd3aed 100644 (file)
@@ -1498,8 +1498,8 @@ string const LaTeXFeatures::getPackages() const
 
        if (mustProvide("nomencl")) {
                packages << "\\usepackage";
-               if (params_.use_nomentbl)
-                       packages << "[nomentbl]";
+               if (!params_.nomencl_opts.empty())
+                       packages << "[" << params_.nomencl_opts << "]";
                packages << "{nomencl}\n";
                // Make it work with the new and old version of the package,
                // but don't use the compatibility option since it is
index 2c3a0d78ce5890c675ba54b0f4b6af1abca36292..f6003ec399ef8b0e68d3483462e050cf8982984e 100644 (file)
@@ -119,7 +119,7 @@ void GuiIndices::update(BufferParams const & params, bool const readonly)
                indexOptionsLE->clear();
        }
 
-       pos = (params.use_nomentbl) ? 1 : 0;
+       pos = (contains(params.nomencl_opts, "nomentbl")) ? 1 : 0;
        nomenclStyleCO->setCurrentIndex(pos);
 
        updateView();
@@ -169,7 +169,8 @@ void GuiIndices::apply(BufferParams & params) const
        params.use_indices = multipleIndicesCB->isChecked();
        params.indiceslist() = indiceslist_;
 
-       params.use_nomentbl = nomenclStyleCO->currentIndex() == 1;
+       if (nomenclStyleCO->currentIndex() == 1)
+               params.nomencl_opts = "nomentbl";
 
        string const index_command =
                fromqstr(indexCO->itemData(
index 4baa29ecfcf026ae3e71a66e0503670e369d700f..d694a166b74e726b2bf42a43907b80fbbe5cf7d0 100644 (file)
@@ -154,7 +154,7 @@ void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
 
 docstring InsetNomencl::layoutName() const
 {
-       return (buffer().params().use_nomentbl) ?
+       return (contains(buffer().params().nomencl_opts, "nomentbl")) ?
                                from_ascii("Nomenclature:nomentbl")
                              : from_ascii("Nomenclature");
 }
index cb57d9115c93c0685244e44e978a26b0d1db75f6..7802eae0b560c4621dc89579b5ef7f4582321957 100644 (file)
@@ -616,7 +616,6 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_use_lineno              = "false";
        h_use_refstyle            = false;
        h_use_minted              = false;
-       h_use_nomentbl            = false;
        h_use_packages["amsmath"]    = "1";
        h_use_packages["amssymb"]    = "0";
        h_use_packages["cancel"]     = "0";
@@ -1780,19 +1779,8 @@ void Preamble::handle_package(Parser &p, string const & name,
        }
 
        else if (name == "nomencl") {
-               vector<string>::iterator it =
-                       find(options.begin(), options.end(), "nomentbl");
-               if (it != options.end()) {
-                       h_use_nomentbl = true;
-                       options.erase(it);
-               }
-               // Add the package options to the global document options
-               if (!options.empty()) {
-                       if (h_options.empty())
-                               h_options = join(options, ",");
-                       else
-                               h_options += ',' + join(options, ",");
-               }
+               h_nomencl_options = join(options, ",");
+               options.clear();
        }
 
        else if (name == "geometry")
@@ -2124,10 +2112,11 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
           << "\\justification " << h_justification << '\n'
           << "\\use_refstyle " << h_use_refstyle << '\n'
           << "\\use_minted " << h_use_minted << '\n'
-          << "\\use_nomentbl " << h_use_nomentbl << '\n'
           << "\\use_lineno " << h_use_lineno << '\n';
        if (!h_lineno_options.empty())
                os << "\\lineno_options " << h_lineno_options << '\n';
+       if (!h_nomencl_options.empty())
+               os << "\\nomencl_options " << h_nomencl_options << '\n';
        if (!h_fontcolor.empty())
                os << "\\fontcolor " << h_fontcolor << '\n';
        if (!h_notefontcolor.empty())
index 9177784771dd866b7c5fca4f3f6467a4232d559a..01d29fcf54df18a26126b0cab5f31246321cad65 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        bool minted() const { return h_use_minted; }
        ///
-       bool nomentbl() const { return h_use_nomentbl; }
+       std::string nomenclOpts() const { return h_nomencl_options; }
        /// The document language
        std::string docLanguage() const { return h_language; }
        /// The language of text which is not explicitly marked
@@ -257,7 +257,7 @@ private:
        std::vector<std::string> h_includeonlys;
        bool h_use_refstyle;
        bool h_use_minted;
-       bool h_use_nomentbl;
+       std::string h_nomencl_options;
 
        /*!
         * Add package \p name with options \p options to used_packages.
index ee40d4a1ef0717aeda57b3c700dd54a65f4716dc..688286b7107b261783c8fa77e2ace1b203d8aa5e 100644 (file)
@@ -5010,7 +5010,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        set<string> pass_thru_cmds = context.pass_thru_cmds;
                        // These commands have special meanings in Nomenclature
                        context.pass_thru_cmds.insert("%");
-                       if (preamble.nomentbl())
+                       if (contains(preamble.nomenclOpts(), "nomentbl"))
                                parse_text_in_inset(p, os, FLAG_ITEM, outer, context, "Nomenclature:nomentbl");
                        else
                                parse_text_in_inset(p, os, FLAG_ITEM, outer, context, "Nomenclature");