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>
23 #include "support/std_string.h"
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 string::size_type bind(string const & seq, FuncRequest const & func);
41 bool read(string const & bind_file);
43 /// print all available keysyms
44 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;
59 /// Given an action, find all keybindings.
60 string const findbinding(FuncRequest const & func,
61 string const & prefix = string()) const;
64 * Returns a string of the given keysym, with modifiers.
65 * @param key the key as a keysym
66 * @param mod the modifiers
68 static string const printKeysym(LyXKeySymPtr key,
69 key_modifier::state mod);
71 typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
82 /// Keymap for prefix keys
83 boost::shared_ptr<kb_keymap> table;
85 /// Action for !prefix keys
90 * Define an action for a key sequence.
91 * @param r internal recursion level
93 void defkey(kb_sequence * seq, FuncRequest const & func,
96 /// Returns a string of the given key
97 string const printKey(kb_key const & key) const;
99 /// is the table empty ?
101 return table.empty();
104 typedef std::vector<kb_key> Table;