+ 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;
+ else if (it->prefixes.get())
+ return it->prefixes->getBinding(seq, r + 1);
+ }
+ }
+ return FuncRequest::unknown;
+}
+
+
+void KeyMap::clear()
+{
+ table.clear();
+}
+
+
+bool KeyMap::read(string const & bind_file, KeyMap * unbind_map, BindReadType rt)
+{
+ FileName bf = i18nLibFileSearch("bind", bind_file, "bind");
+ if (bf.empty()) {
+ if (rt == MissingOK)
+ return true;
+
+ lyxerr << "Could not find bind file: " << bind_file;
+ if (rt == Default) {
+ frontend::Alert::warning(_("Could not find bind file"),
+ bformat(_("Unable to find the bind file\n%1$s.\n"
+ "Please check your installation."), from_utf8(bind_file)));
+ return false;
+ }
+
+ static string const defaultBindfile = "cua";
+ if (bind_file == defaultBindfile) {
+ frontend::Alert::warning(_("Could not find `cua.bind' file"),
+ _("Unable to find the default bind file `cua.bind'.\n"
+ "Please check your installation."));
+ return false;
+ }
+
+ // Try it with the default file.
+ frontend::Alert::warning(_("Could not find bind file"),
+ bformat(_("Unable to find the bind file\n%1$s.\n"
+ "Falling back to default."), from_utf8(bind_file)));
+ return read(defaultBindfile, unbind_map);
+ }
+ return read(bf, unbind_map);
+}
+
+
+bool KeyMap::read(FileName const & bind_file, KeyMap * unbind_map)
+{
+ enum {
+ BN_BIND,
+ BN_BINDFILE,
+ BN_UNBIND,
+ };
+
+ LexerKeyword bindTags[] = {
+ { "\\bind", BN_BIND },
+ { "\\bind_file", BN_BINDFILE },
+ { "\\unbind", BN_UNBIND },
+ };
+
+ Lexer lexrc(bindTags);