4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
11 * Full author contact details are available in file CREDITS.
17 #include "FuncRequest.h"
19 #include "frontends/KeyModifier.h"
20 #include "frontends/KeySymbol.h"
22 #include "support/docstream.h"
24 #include <boost/shared_ptr.hpp>
34 /// Defines key maps and actions for key sequences
38 * Bind a key sequence to an action.
39 * @return 0 on success, or position in string seq where error
41 * See KeySequence::parse for the syntax of the seq string
43 size_t bind(std::string const & seq, FuncRequest const & func);
46 bool read(std::string const & bind_file);
49 * print all available keysyms
50 * @param forgui true if the string should use translations and
53 docstring const print(bool forgui) const;
56 * Look up a key press in the keymap.
57 * @param key the keysym
58 * @param mod the modifiers
59 * @param seq the current key sequence so far
60 * @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
63 lookup(KeySymbol const & key, KeyModifier mod, KeySequence * seq) const;
66 typedef std::deque<KeySequence> Bindings;
68 /// Given an action, find all keybindings.
69 Bindings findbindings(FuncRequest const & func) const;
71 /// Given an action, print the keybindings.
72 docstring const printbindings(FuncRequest const & func) const;
75 * Given an action, find the first 1-key binding (if it exists).
76 * The KeySymbol pointer is 0 is no key is found.
77 * [only used by the Qt/Mac frontend]
79 std::pair<KeySymbol, KeyModifier>
80 find1keybinding(FuncRequest const & func) const;
84 * Returns a string of the given keysym, with modifiers.
85 * @param key the key as a keysym
86 * @param mod the modifiers
88 static std::string const printKeySym(KeySymbol const & key,
91 typedef std::pair<KeyModifier, KeyModifier> ModifierPair;
101 /// Keymap for prefix keys
102 boost::shared_ptr<KeyMap> table;
104 /// Action for !prefix keys
109 typedef std::vector<Key> Table;
111 Table::const_iterator begin() const { return table.begin(); }
112 Table::const_iterator end() const { return table.end(); }
116 * Define an action for a key sequence.
117 * @param r internal recursion level
119 void defkey(KeySequence * seq, FuncRequest const & func,
123 * Given an action, find all keybindings
124 * @param func the action
125 * @param prefix a sequence to prepend the results
127 Bindings findbindings(FuncRequest const & func,
128 KeySequence const & prefix) const;
130 /// is the table empty ?
131 bool empty() const { return table.empty(); }
136 /// Implementation is in LyX.cpp
137 extern KeyMap & theTopLevelKeymap();