\use_nomentbl -> \nomencl_opts

This allows for support of more options

As the param is only a few hours old, no lyx2lyx handling is needed
This commit is contained in:
Juergen Spitzmueller 2024-08-22 05:35:47 +02:00
parent 2552f350ba
commit 0ca600b93b
10 changed files with 33 additions and 39 deletions

View 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"])
##

View 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) {

View 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)

View 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

View 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

View 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(

View 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");
}

View 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())

View 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.

View 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");