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>
32 /// Defines key maps and actions for key sequences
36 * Bind a key sequence to an action.
37 * @return 0 on success, or position in string seq where error
39 * See kb_sequence::parse for the syntax of the seq string
41 std::string::size_type bind(std::string const & seq, FuncRequest const & func);
44 bool read(std::string const & bind_file);
46 /// print all available keysyms
47 std::string const print() const;
50 * Look up a key press in the keymap.
51 * @param key the keysym
52 * @param mod the modifiers
53 * @param seq the current key sequence so far
54 * @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
57 lookup(LyXKeySymPtr key,
58 key_modifier::state mod, kb_sequence * seq) const;
61 typedef std::deque<kb_sequence> Bindings;
63 /// Given an action, find all keybindings.
64 Bindings findbindings(FuncRequest const & func) const;
66 /// Given an action, print the keybindings.
67 std::string const printbindings(FuncRequest const & func) const;
70 * Given an action, find the first 1-key binding (if it exists).
71 * The LyXKeySym pointer is 0 is no key is found.
72 * [only used by the Qt/Mac frontend]
74 std::pair<LyXKeySym const *, key_modifier::state>
75 find1keybinding(FuncRequest const & func) const;
79 * Returns a string of the given keysym, with modifiers.
80 * @param key the key as a keysym
81 * @param mod the modifiers
83 static std::string const printKeySym(LyXKeySym const & key,
84 key_modifier::state mod);
86 typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
97 /// Keymap for prefix keys
98 boost::shared_ptr<kb_keymap> table;
100 /// Action for !prefix keys
105 * Define an action for a key sequence.
106 * @param r internal recursion level
108 void defkey(kb_sequence * seq, FuncRequest const & func,
111 /// Returns a string of the given key
112 std::string const printKey(kb_key const & key) const;
115 * Given an action, find all keybindings
116 * @param func the action
117 * @param prefix a sequence to prepend the results
119 Bindings findbindings(FuncRequest const & func,
120 kb_sequence const & prefix) const;
122 /// is the table empty ?
124 return table.empty();
127 typedef std::vector<kb_key> Table;
132 /// Implementation is in lyx_main.C
133 extern kb_keymap & theTopLevelKeymap();