]> git.lyx.org Git - lyx.git/blobdiff - src/kbmap.C
* src/support/unicode.C
[lyx.git] / src / kbmap.C
index 9377be0c436b01e77684c83b2b0c34d9b58b0083..fd55a7c5ff5823b3183abe8d24ef08d71e1f4984 100644 (file)
 
 #include <sstream>
 
-using lyx::support::i18nLibFileSearch;
+
+namespace lyx {
+
+using support::FileName;
+using support::i18nLibFileSearch;
 
 using std::endl;
 using std::string;
@@ -51,7 +55,7 @@ string const kb_keymap::printKeySym(LyXKeySym const & key,
 }
 
 
-string const kb_keymap::printKey(kb_key const & key) const
+docstring const kb_keymap::printKey(kb_key const & key) const
 {
        return key.code->print(key.mod.first);
 }
@@ -103,7 +107,7 @@ bool kb_keymap::read(string const & bind_file)
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
 
-       string const tmp = i18nLibFileSearch("bind", bind_file, "bind");
+       FileName const tmp(i18nLibFileSearch("bind", bind_file, "bind"));
        lexrc.setFile(tmp);
        if (!lexrc.isOK()) {
                lyxerr << "kb_keymap::read: cannot open bind file:"
@@ -197,7 +201,7 @@ kb_keymap::lookup(LyXKeySymPtr key,
                        if (cit->table.get()) {
                                // this is a prefix key - set new map
                                seq->curmap = cit->table.get();
-                               static FuncRequest prefix(LFUN_PREFIX);
+                               static FuncRequest prefix(LFUN_COMMAND_PREFIX);
                                return prefix;
                        } else {
                                // final key - reset map
@@ -216,9 +220,9 @@ kb_keymap::lookup(LyXKeySymPtr key,
 }
 
 
-string const kb_keymap::print() const
+docstring const kb_keymap::print() const
 {
-       string buf;
+       docstring buf;
        Table::const_iterator end = table.end();
        for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
                buf += printKey((*cit));
@@ -248,16 +252,18 @@ void kb_keymap::defkey(kb_sequence * seq,
                        if (r + 1 == seq->length()) {
                                lyxerr[Debug::KBMAP]
                                        << "Warning: New binding for '"
-                                       << seq->print()
+                                       << to_utf8(seq->print())
                                        << "' is overriding old binding..."
                                        << endl;
                                if (it->table.get()) {
                                        it->table.reset();
                                }
                                it->func = func;
+                               it->func.origin = FuncRequest::KEYBOARD;
                                return;
                        } else if (!it->table.get()) {
-                               lyxerr << "Error: New binding for '" << seq->print()
+                               lyxerr << "Error: New binding for '" 
+                                      << to_utf8(seq->print())
                                       << "' is overriding old binding..."
                                               << endl;
                                return;
@@ -273,6 +279,7 @@ void kb_keymap::defkey(kb_sequence * seq,
        newone->mod = seq->modifiers[r];
        if (r + 1 == seq->length()) {
                newone->func = func;
+               newone->func.origin = FuncRequest::KEYBOARD;
                newone->table.reset();
                return;
        } else {
@@ -283,9 +290,9 @@ void kb_keymap::defkey(kb_sequence * seq,
 }
 
 
-string const kb_keymap::printbindings(FuncRequest const & func) const
+docstring const kb_keymap::printbindings(FuncRequest const & func) const
 {
-       std::ostringstream res;
+       odocstringstream res;
        Bindings bindings = findbindings(func);
        for (Bindings::const_iterator cit = bindings.begin();
             cit != bindings.end() ; ++cit)
@@ -340,3 +347,6 @@ kb_keymap::find1keybinding(FuncRequest const & func) const
 
        return std::make_pair<LyXKeySym const *, key_modifier::state>(0, key_modifier::none);
 }
+
+
+} // namespace lyx