option editor: allow EntryOption to have a list of valid chars (not just invalid)
This commit is contained in:
parent
bae15f216b
commit
52f713b591
@ -347,9 +347,21 @@ void
|
||||
EntryOption::filter_text (const Glib::ustring&, int*)
|
||||
{
|
||||
std::string text = _entry->get_text ();
|
||||
|
||||
if (!_valid.empty()) {
|
||||
for (std::string::const_iterator t = text.begin(); t != text.end(); ) {
|
||||
if (_valid.find_first_of (*t) == std::string::npos) {
|
||||
t = text.erase (t);
|
||||
} else {
|
||||
++t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _invalid.length(); ++i) {
|
||||
text.erase (std::remove(text.begin(), text.end(), _invalid.at(i)), text.end());
|
||||
}
|
||||
|
||||
if (text != _entry->get_text ()) {
|
||||
_entry->set_text (text);
|
||||
}
|
||||
|
@ -278,6 +278,7 @@ public:
|
||||
void add_to_page (OptionEditorPage*);
|
||||
void set_sensitive (bool);
|
||||
void set_invalid_chars (std::string i) { _invalid = i; }
|
||||
void set_valid_chars (std::string i) { _valid = i; }
|
||||
|
||||
Gtk::Widget& tip_widget() { return *_entry; }
|
||||
|
||||
@ -291,6 +292,7 @@ private:
|
||||
Gtk::Label* _label; ///< UI label
|
||||
Gtk::Entry* _entry; ///< UI entry
|
||||
std::string _invalid;
|
||||
std::string _valid;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user