X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FKeyMap.cpp;h=c5c387f28f8398617377225c7a102dc31d06f7f2;hb=9a1b26a156c913f484ca2293fb2ec1c4986d2a3e;hp=50833c923a755d694fd7042082aca99362cc6156;hpb=aafd52f44167d5510be1ddcb974daa9dae486933;p=lyx.git diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp index 50833c923a..c5c387f28f 100644 --- a/src/KeyMap.cpp +++ b/src/KeyMap.cpp @@ -25,6 +25,7 @@ #include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" +#include "support/TempFile.h" #include "frontends/alert.h" @@ -67,7 +68,7 @@ size_t KeyMap::bind(string const & seq, FuncRequest const & func) LYXERR(Debug::KBMAP, "BIND: Sequence `" << seq << "' Action `" << func.action() << '\''); - KeySequence k(0, 0); + KeySequence k(nullptr, nullptr); string::size_type const res = k.parse(seq); if (res == string::npos) { @@ -83,7 +84,7 @@ size_t KeyMap::bind(string const & seq, FuncRequest const & func) size_t KeyMap::unbind(string const & seq, FuncRequest const & func) { - KeySequence k(0, 0); + KeySequence k(nullptr, nullptr); string::size_type const res = k.parse(seq); if (res == string::npos) @@ -105,6 +106,8 @@ void KeyMap::bind(KeySequence * seq, FuncRequest const & func, unsigned int r) KeyModifier const mod2 = seq->modifiers[r].second; // check if key is already there + // FIXME perf: Profiling shows that this is responsible of 99% of the + // cost of GuiPrefs::applyView() Table::iterator end = table.end(); for (Table::iterator it = table.begin(); it != end; ++it) { if (code == it->code @@ -254,7 +257,8 @@ bool KeyMap::read(FileName const & bind_file, KeyMap * unbind_map) return retval == ReadOK; LYXERR(Debug::FILES, "Converting bind file to " << LFUN_FORMAT); - FileName const tempfile = FileName::tempName("convert_bind"); + TempFile tmp("convert_bind"); + FileName const tempfile = tmp.name(); bool const success = prefs2prefs(bind_file, tempfile, true); if (!success) { LYXERR0 ("Unable to convert " << bind_file << @@ -262,7 +266,6 @@ bool KeyMap::read(FileName const & bind_file, KeyMap * unbind_map) return false; } retval = readWithoutConv(tempfile, unbind_map); - tempfile.removeFile(); return retval == ReadOK; } @@ -443,7 +446,7 @@ FuncRequest const & KeyMap::lookup(KeySymbol const &key, if (cit->prefixes) { // this is a prefix key - set new map seq->curmap = cit->prefixes.get(); - static FuncRequest prefix(LFUN_COMMAND_PREFIX); + static const FuncRequest prefix(LFUN_COMMAND_PREFIX); return prefix; } else { // final key - reset map @@ -473,27 +476,28 @@ docstring const KeyMap::print(bool forgui) const docstring KeyMap::printBindings(FuncRequest const & func, - KeySequence::outputFormat format) const + KeySequence::outputFormat format, + bool const untranslated) const { Bindings bindings = findBindings(func); if (bindings.empty()) return docstring(); - + odocstringstream res; Bindings::const_iterator cit = bindings.begin(); Bindings::const_iterator cit_end = bindings.end(); // print the first item - res << cit->print(format); + res << cit->print(format, untranslated); // more than one shortcuts? for (++cit; cit != cit_end; ++cit) - res << ", " << cit->print(format); + res << ", " << cit->print(format, untranslated); return res.str(); } KeyMap::Bindings KeyMap::findBindings(FuncRequest const & func) const { - return findBindings(func, KeySequence(0, 0)); + return findBindings(func, KeySequence(nullptr, nullptr)); } @@ -525,7 +529,7 @@ KeyMap::Bindings KeyMap::findBindings(FuncRequest const & func, KeyMap::BindingList KeyMap::listBindings(bool unbound, KeyMap::ItemType tag) const { BindingList list; - listBindings(list, KeySequence(0, 0), tag); + listBindings(list, KeySequence(nullptr, nullptr), tag); if (unbound) { LyXAction::const_iterator fit = lyxaction.func_begin(); LyXAction::const_iterator const fen = lyxaction.func_end(); @@ -540,8 +544,8 @@ KeyMap::BindingList KeyMap::listBindings(bool unbound, KeyMap::ItemType tag) con break; } if (!has_action) - list.push_back(Binding(FuncRequest(action), KeySequence(0, 0), tag)); - } + list.push_back(Binding(FuncRequest(action), KeySequence(nullptr, nullptr), tag)); + } } return list; }