]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListingsParams.cpp
Math.lyx, Tutorial.lyx: fix some typos spotted by a user
[lyx.git] / src / insets / InsetListingsParams.cpp
index 99ecbb0fdfac1d60f7b198d26797f108406c9ab7..fa488c07d82f60af68a702e285e4003f534d0702 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "support/convert.h"
 #include "support/gettext.h"
-#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
@@ -37,7 +36,7 @@ enum param_type {
        INTEGER, // accept an integer
        LENGTH,  // accept a latex length
        ONEOF,  // accept one of a few values
-       SUBSETOF, // accept a string composed of given characters
+       SUBSETOF // accept a string composed of given characters
 };
 
 
@@ -437,6 +436,8 @@ ParValidator::ParValidator()
                ListingsParam("", false, TRUEFALSE, "", empty_hint);
        all_params_["breaklines"] =
                ListingsParam("", false, TRUEFALSE, "", empty_hint);
+       all_params_["breakatwhitespace"] =
+               ListingsParam("", false, TRUEFALSE, "", empty_hint);
        all_params_["prebreak"] =
                ListingsParam("", false, ALL, "", empty_hint);
        all_params_["postbreak"] =
@@ -715,7 +716,7 @@ void InsetListingsParams::write(ostream & os) const
 void InsetListingsParams::read(Lexer & lex)
 {
        lex >> inline_;
-       int s = Inset::Collapsed;
+       int s = InsetCollapsable::Collapsed;
        lex >> s;
        status_ = static_cast<InsetCollapsable::CollapseStatus>(s);
        string par;
@@ -741,21 +742,22 @@ string InsetListingsParams::params(string const & sep) const
 }
 
 
-void InsetListingsParams::addParam(string const & key, string const & value)
+void InsetListingsParams::addParam(string const & key, 
+               string const & value, bool replace)
 {
        if (key.empty())
                return;
 
        // duplicate parameters!
        string keyname = key;
-       if (params_.find(key) != params_.end())
+       if (!replace && params_.find(key) != params_.end())
                // key=value,key=value1 is allowed in listings
                // use key_, key__, key___ etc to avoid name conflict
                while (params_.find(keyname += '_') != params_.end()) { }
        // check onoff flag
        // onoff parameter with value false
        if (!par_validator)
-               par_validator = new ParValidator();
+               par_validator = new ParValidator;
        if (par_validator->onoff(key) && (value == "false" || value == "{false}"))
                params_[keyname] = string();
        // if the parameter is surrounded with {}, good
@@ -766,7 +768,7 @@ void InsetListingsParams::addParam(string const & key, string const & value)
        else {
                bool has_special_char = false;
                for (size_t i = 0; i < value.size(); ++i)
-                       if (!isAlphaASCII(value[i]) && !isDigit(value[i])) {
+                       if (!isAlnumASCII(value[i])) {
                                has_special_char = true;
                                break;
                        }
@@ -882,7 +884,7 @@ docstring InsetListingsParams::validate() const
 {
        docstring msg;
        if (!par_validator)
-               par_validator = new ParValidator();
+               par_validator = new ParValidator;
        for (map<string, string>::const_iterator it = params_.begin();
                it != params_.end(); ++it) {
                msg = par_validator->validate(it->first, it->second);