+ return res == string::npos ? 0 : res;
+}
+
+
+size_t KeyMap::unbind(string const & seq, FuncRequest const & func)
+{
+ KeySequence k(0, 0);
+
+ string::size_type const res = k.parse(seq);
+ if (res == string::npos)
+ delkey(&k, func);
+ else
+ LYXERR(Debug::KBMAP) << "Parse error at position " << res
+ << " in key sequence '" << seq << "'."
+ << endl;
+ return res == string::npos ? 0 : res;
+}
+
+
+bool KeyMap::hasBinding(KeySequence const & seq, FuncRequest const & func,
+ unsigned int r)
+{
+ KeySymbol code = seq.sequence[r];
+ if (!code.isOK())
+ return false;
+
+ KeyModifier const mod1 = seq.modifiers[r].first;
+ KeyModifier const mod2 = seq.modifiers[r].second;
+
+ // check if key is already there
+ Table::iterator end = table.end();
+ for (Table::iterator it = table.begin(); it != end; ++it) {
+ if (code == it->code
+ && mod1 == it->mod.first
+ && mod2 == it->mod.second) {
+ if (r + 1 == seq.length())
+ return it->func == func;
+ else if (it->table.get())
+ return it->table->hasBinding(seq, func, r + 1);
+ }
+ }
+ return false;
+}
+
+
+void KeyMap::clear()
+{
+ table.clear();