X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetListingsParams.cpp;h=998554c395c7f3f6e33c4798c2fb469b3b6e0c36;hb=cf6ff2cac79d09adafa63e3a1ec02dfb09f707b9;hp=0daf4081852867bedbc9aeba46f222c4dbc0c269;hpb=28be7d552f62cc02fa86d7f79201d089bfb2d7b5;p=lyx.git diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index 0daf408185..998554c395 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -102,7 +102,7 @@ docstring ListingsParam::validate(string const & par) const bool unclosed = false; string par2 = par; // braces are allowed - if (prefixIs(par, "{") && suffixIs(par, "}") && !suffixIs(par, "\\}")) + if (prefixIs(par, "{") && suffixIs(par, "}") && !suffixIs(par, "\\}")) par2 = par.substr(1, par.size() - 2); // check for unmatched braces @@ -114,7 +114,7 @@ docstring ListingsParam::validate(string const & par) const --braces; } unclosed = braces != 0; - + switch (type_) { case ALL: @@ -914,10 +914,10 @@ docstring ParValidator::validate(string const & name, _("Available listing parameters are %1$s"), from_ascii(param_names)); else return bformat( - _("Available listings parameters containing string \"%1$s\" are %2$s"), + _("Available listings parameters containing string \"%1$s\" are %2$s"), from_utf8(suffix), from_utf8(param_names)); } - + // locate name in parameter table ListingsParams::const_iterator it = all_params_[p].find(name); if (it != all_params_[p].end()) { @@ -959,7 +959,7 @@ bool ParValidator::onoff(string const & name) const return false; } -} // namespace anon. +} // namespace // define a global ParValidator ParValidator * par_validator = 0; @@ -969,13 +969,13 @@ ParValidator * par_validator = 0; int InsetListingsParams::package_ = 0; InsetListingsParams::InsetListingsParams() - : inline_(false), params_(), status_(InsetCollapsable::Open) + : inline_(false), params_(), status_(InsetCollapsible::Open) { } InsetListingsParams::InsetListingsParams(string const & par, bool in, - InsetCollapsable::CollapseStatus s) + InsetCollapsible::CollapseStatus s) : inline_(in), params_(), status_(s) { // this will activate parameter validation. @@ -996,9 +996,9 @@ void InsetListingsParams::write(ostream & os) const void InsetListingsParams::read(Lexer & lex) { lex >> inline_; - int s = InsetCollapsable::Collapsed; + int s = InsetCollapsible::Collapsed; lex >> s; - status_ = static_cast(s); + status_ = static_cast(s); string par; lex >> par; fromEncodedString(par); @@ -1044,14 +1044,15 @@ string InsetListingsParams::getValue(string const & key) const } -void InsetListingsParams::addParam(string const & key, +void InsetListingsParams::addParam(string const & key, string const & val, bool replace) { if (key.empty()) return; - string const value = (minted() && key == "language") ? languageonly(val) - : val; + bool const is_minted_language = minted() && key == "language"; + string const value = (is_minted_language && !val.empty()) + ? languageonly(val) : val; // duplicate parameters! string keyname = key; if (!replace && hasParam(key)) @@ -1076,7 +1077,7 @@ void InsetListingsParams::addParam(string const & key, has_special_char = true; break; } - if (has_special_char) + if (has_special_char && !is_minted_language) params_.push_back(make_pair(keyname, "{" + value + "}")); else params_.push_back(make_pair(keyname, value)); @@ -1110,7 +1111,7 @@ void InsetListingsParams::addParams(string const & par) } else if (par[i] == '{' && i > 0 && par[i-1] != '\\') // don't count a brace in first position ++braces; - else if (par[i] == '}' && i != par.size() - 1 + else if (par[i] == '}' && i != par.size() - 1 && (i == 0 || (i > 0 && par[i-1] != '\\'))) --braces;