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/key_state.h"
20 #include "frontends/LyXKeySym.h"
22 #include <boost/shared_ptr.hpp>
29 /// Defines key maps and actions for key sequences
33 * Bind a key sequence to an action.
34 * @return 0 on success, or position in string seq where error
36 * See kb_sequence::parse for the syntax of the seq string
38 std::string::size_type bind(std::string const & seq, FuncRequest const & func);
41 bool read(std::string const & bind_file);
43 /// print all available keysyms
44 std::string const print() const;
47 * Look up a key press in the keymap.
48 * @param key the keysym
49 * @param mod the modifiers
50 * @param seq the current key sequence so far
51 * @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
54 lookup(LyXKeySymPtr key,
55 key_modifier::state mod, kb_sequence * seq) const;
58 typedef std::deque<kb_sequence> Bindings;
60 /// Given an action, find all keybindings.
61 Bindings findbindings(FuncRequest const & func) const;
63 /// Given an action, print the keybindings.
64 std::string const printbindings(FuncRequest const & func) const;
67 * Given an action, find the first 1-key binding (if it exists).
68 * The LyXKeySym pointer is 0 is no key is found.
69 * [only used by the Qt/Mac frontend]
71 std::pair<LyXKeySym const *, key_modifier::state>
72 find1keybinding(FuncRequest const & func) const;
76 * Returns a string of the given keysym, with modifiers.
77 * @param key the key as a keysym
78 * @param mod the modifiers
80 static std::string const printKeySym(LyXKeySym const & key,
81 key_modifier::state mod);
83 typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
94 /// Keymap for prefix keys
95 boost::shared_ptr<kb_keymap> table;
97 /// Action for !prefix keys
102 * Define an action for a key sequence.
103 * @param r internal recursion level
105 void defkey(kb_sequence * seq, FuncRequest const & func,
108 /// Returns a string of the given key
109 std::string const printKey(kb_key const & key) const;
112 * Given an action, find all keybindings
113 * @param func the action
114 * @param prefix a sequence to prepend the results
116 Bindings findbindings(FuncRequest const & func,
117 kb_sequence const & prefix) const;
119 /// is the table empty ?
121 return table.empty();
124 typedef std::vector<kb_key> Table;