mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
cleanup reading of lfun bindings
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8832 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d03f76a482
commit
025f30b361
@ -1,3 +1,15 @@
|
||||
2004-06-30 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* kbmap.C (findbindings): a couple of new methods. returns a
|
||||
container of kb_sequence objects. The real work is done by the
|
||||
private recursive version
|
||||
(printbindings): uses findbindings to print out a bracketed list
|
||||
of bindings (renamed from findbinding).
|
||||
|
||||
* MenuBackend.C (binding): use kb_keymap::findbindings
|
||||
|
||||
* lyxfunc.C (sendDispatchMessage): use use kb_keymap::printbindings.
|
||||
|
||||
2004-07-01 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* buffer.C: up LYX_FORMAT to 235 (needed for the paperpackage fix)
|
||||
|
@ -137,13 +137,13 @@ string const MenuItem::binding() const
|
||||
|
||||
// Get the keys bound to this action, but keep only the
|
||||
// first one later
|
||||
string bindings = toplevel_keymap->findbinding(func_);
|
||||
kb_keymap::Bindings bindings = toplevel_keymap->findbindings(func_);
|
||||
|
||||
if (!bindings.empty()) {
|
||||
return bindings.substr(1, bindings.find(']') - 1);
|
||||
if (bindings.size()) {
|
||||
return bindings.begin()->print();
|
||||
} else {
|
||||
lyxerr[Debug::KBMAP]
|
||||
<< "No bindings for "
|
||||
<< "No binding for "
|
||||
<< lyxaction.getActionName(func_.action)
|
||||
<< '(' << func_.argument << ')' << endl;
|
||||
return string();
|
||||
|
41
src/kbmap.C
41
src/kbmap.C
@ -23,6 +23,7 @@
|
||||
#include "frontends/LyXKeySym.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
using lyx::support::i18nLibFileSearch;
|
||||
|
||||
@ -281,24 +282,44 @@ void kb_keymap::defkey(kb_sequence * seq,
|
||||
}
|
||||
|
||||
|
||||
string const kb_keymap::findbinding(FuncRequest const & func,
|
||||
string const & prefix) const
|
||||
string const kb_keymap::printbindings(FuncRequest const & func) const
|
||||
{
|
||||
string res;
|
||||
std::ostringstream res;
|
||||
Bindings bindings = findbindings(func);
|
||||
for (Bindings::const_iterator cit = bindings.begin();
|
||||
cit != bindings.end() ; ++cit)
|
||||
res << '[' << cit->print() << ']';
|
||||
return res.str();
|
||||
}
|
||||
|
||||
|
||||
kb_keymap::Bindings
|
||||
kb_keymap::findbindings(FuncRequest const & func) const
|
||||
{
|
||||
return findbindings(func, kb_sequence(0, 0));
|
||||
}
|
||||
|
||||
|
||||
kb_keymap::Bindings
|
||||
kb_keymap::findbindings(FuncRequest const & func,
|
||||
kb_sequence const & prefix) const
|
||||
{
|
||||
Bindings res;
|
||||
if (table.empty()) return res;
|
||||
|
||||
Table::const_iterator end = table.end();
|
||||
for (Table::const_iterator cit = table.begin();
|
||||
cit != end; ++cit) {
|
||||
if (cit->table.get()) {
|
||||
res += cit->table->findbinding(func,
|
||||
prefix
|
||||
+ printKey((*cit))
|
||||
+ ' ');
|
||||
kb_sequence seq = prefix;
|
||||
seq.addkey(cit->code, cit->mod.first);
|
||||
Bindings res2 =
|
||||
cit->table->findbindings(func, seq);
|
||||
res.insert(res.end(), res2.begin(), res2.end());
|
||||
} else if (cit->func == func) {
|
||||
res += '[';
|
||||
res += prefix + printKey((*cit));
|
||||
res += "] ";
|
||||
kb_sequence seq = prefix;
|
||||
seq.addkey(cit->code, cit->mod.first);
|
||||
res.push_back(seq);
|
||||
}
|
||||
}
|
||||
|
||||
|
18
src/kbmap.h
18
src/kbmap.h
@ -21,6 +21,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
class kb_sequence;
|
||||
class LyXKeySym;
|
||||
@ -55,9 +56,14 @@ public:
|
||||
lookup(LyXKeySymPtr key,
|
||||
key_modifier::state mod, kb_sequence * seq) const;
|
||||
|
||||
///
|
||||
typedef std::deque<kb_sequence> Bindings;
|
||||
|
||||
/// Given an action, find all keybindings.
|
||||
std::string const findbinding(FuncRequest const & func,
|
||||
std::string const & prefix = std::string()) const;
|
||||
Bindings findbindings(FuncRequest const & func) const;
|
||||
|
||||
/// Given an action, print the keybindings.
|
||||
std::string const printbindings(FuncRequest const & func) const;
|
||||
|
||||
/**
|
||||
* Returns a string of the given keysym, with modifiers.
|
||||
@ -95,6 +101,14 @@ private:
|
||||
/// Returns a string of the given key
|
||||
std::string const printKey(kb_key const & key) const;
|
||||
|
||||
/**
|
||||
* Given an action, find all keybindings
|
||||
* @param func the action
|
||||
* @param prefix a sequence to prepend the results
|
||||
*/
|
||||
Bindings findbindings(FuncRequest const & func,
|
||||
kb_sequence const & prefix) const;
|
||||
|
||||
/// is the table empty ?
|
||||
bool empty() const {
|
||||
return table.empty();
|
||||
|
@ -1451,7 +1451,7 @@ void LyXFunc::sendDispatchMessage(string const & msg,
|
||||
}
|
||||
}
|
||||
|
||||
string const shortcuts = toplevel_keymap->findbinding(cmd);
|
||||
string const shortcuts = toplevel_keymap->printbindings(cmd);
|
||||
|
||||
if (!shortcuts.empty()) {
|
||||
comname += ": " + shortcuts;
|
||||
|
Loading…
Reference in New Issue
Block a user