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"
21 #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 typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
49 * Look up a key press in the keymap.
50 * @param key the keysym
51 * @param mod the modifiers
52 * @param seq the current key sequence so far
53 * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
56 lookup(LyXKeySymPtr key,
57 key_modifier::state mod, kb_sequence * seq) const;
60 typedef std::deque<kb_sequence> Bindings;
62 /// Given an action, find all keybindings.
63 Bindings findbindings(FuncRequest const & func) const;
65 /// Given an action, print the keybindings.
66 std::string const printbindings(FuncRequest const & func) const;
69 * Given an action, find the first 1-key binding (if it exists).
70 * The LyXKeySym pointer is 0 is no key is found.
71 * [only used by the Qt/Mac frontend]
73 std::pair<LyXKeySym const *, key_modifier::state>
74 find1keybinding(FuncRequest const & func) const;
78 * Returns a string of the given keysym, with modifiers.
79 * @param key the key as a keysym
80 * @param mod the modifiers
82 static std::string const printKeySym(LyXKeySym const & key,
83 key_modifier::state mod);
85 typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
96 /// Keymap for prefix keys
97 boost::shared_ptr<kb_keymap> table;
99 /// Action for !prefix keys
104 * Define an action for a key sequence.
105 * @param r internal recursion level
107 void defkey(kb_sequence * seq, FuncRequest const & func,
110 /// Returns a string of the given key
111 std::string const printKey(kb_key const & key) const;
114 * Given an action, find all keybindings
115 * @param func the action
116 * @param prefix a sequence to prepend the results
118 Bindings findbindings(FuncRequest const & func,
119 kb_sequence const & prefix) const;
121 /// is the table empty ?
123 return table.empty();
126 typedef std::vector<kb_key> Table;