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>
28 /// Defines key maps and actions for key sequences
32 * Bind a key sequence to an action.
33 * @return 0 on success, or position in string seq where error
35 * See kb_sequence::parse for the syntax of the seq string
37 std::string::size_type bind(std::string const & seq, FuncRequest const & func);
40 bool read(std::string const & bind_file);
42 /// print all available keysyms
43 std::string const print() const;
46 typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
48 * Look up a key press in the keymap.
49 * @param key the keysym
50 * @param mod the modifiers
51 * @param seq the current key sequence so far
52 * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
55 lookup(LyXKeySymPtr key,
56 key_modifier::state mod, kb_sequence * seq) const;
58 /// Given an action, find all keybindings.
59 std::string const findbinding(FuncRequest const & func,
60 std::string const & prefix = std::string()) const;
63 * Returns a string of the given keysym, with modifiers.
64 * @param key the key as a keysym
65 * @param mod the modifiers
67 static std::string const printKeySym(LyXKeySym const & key,
68 key_modifier::state mod);
70 typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
81 /// Keymap for prefix keys
82 boost::shared_ptr<kb_keymap> table;
84 /// Action for !prefix keys
89 * Define an action for a key sequence.
90 * @param r internal recursion level
92 void defkey(kb_sequence * seq, FuncRequest const & func,
95 /// Returns a string of the given key
96 std::string const printKey(kb_key const & key) const;
98 /// is the table empty ?
100 return table.empty();
103 typedef std::vector<kb_key> Table;