From: Bo Peng Date: Tue, 5 Jun 2007 22:08:43 +0000 (+0000) Subject: ?xxx show all parameters containing xxx in InsetListingsParams, remove all_param_name... X-Git-Tag: 1.6.10~9468 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=276f6fcde5e31b0dbf5eae9799a2f695079c6bd4;p=features.git ?xxx show all parameters containing xxx in InsetListingsParams, remove all_param_names_ from ParValidator git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18687 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index 3ec4e74605..e4e6748219 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -41,6 +41,7 @@ using support::isStrInt; using support::prefixIs; using support::suffixIs; using support::getVectorFromString; +using lyx::support::contains; namespace { @@ -283,8 +284,6 @@ private: /// key is the name of the parameter typedef map ListingsParams; ListingsParams all_params_; - /// - string all_param_names_; }; @@ -579,14 +578,6 @@ ParValidator::ParValidator() ListingsParam("", false, ALL, "", empty_hint); all_params_["podcomment"] = ListingsParam("", false, ALL, "", empty_hint); - - ListingsParams::const_iterator it = all_params_.begin(); - ListingsParams::const_iterator end = all_params_.end(); - for (; it != end; ++it) { - if (!all_param_names_.empty()) - all_param_names_ += ", "; - all_param_names_ += it->first; - } } @@ -606,10 +597,27 @@ ListingsParam const & ParValidator::param(string const & name) const if (name.empty()) throw invalidParam(_("Invalid (empty) listing parameter name.")); - if (name == "?") - throw invalidParam(bformat( - _("Available listing parameters are %1$s"), from_ascii(all_param_names_))); - + if (name[0] == '?') { + string suffix = trim(string(name, 1)); + string param_names; + ListingsParams::const_iterator it = all_params_.begin(); + ListingsParams::const_iterator end = all_params_.end(); + for (; it != end; ++it) { + if (suffix.empty() || contains(it->first, suffix)) { + if (!param_names.empty()) + param_names += ", "; + param_names += it->first; + } + } + if (suffix.empty()) + throw invalidParam(bformat( + _("Available listing parameters are %1$s"), from_ascii(param_names))); + else + throw invalidParam(bformat( + _("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_.find(name); if (it != all_params_.end())