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
10 * Full author contact details are available in file CREDITS.
16 #include "frontends/key_state.h"
18 #include <boost/shared_ptr.hpp>
27 /// Holds a key sequence and the current and standard keymaps
30 typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
31 typedef std::vector<LyXKeySymPtr> KeySequence;
33 friend class kb_keymap;
36 kb_sequence(kb_keymap * std, kb_keymap * cur)
37 : stdmap(std), curmap(cur), deleted_(false) {}
40 * Add a key to the key sequence and look it up in the curmap
41 * if the latter is defined.
42 * @param keysym the key to add
43 * @param mod modifier mask
44 * @param nmod which modifiers to mask out for equality test
45 * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
48 addkey(LyXKeySymPtr keysym, key_modifier::state mod,
49 key_modifier::state nmod = key_modifier::none);
52 * Add a sequence of keys from a string to the sequence
53 * @return string::npos if OK, else error position in string
55 * Keys in the string must be separated with whitespace;
56 * Use the keysym names used by XStringToKeysym, f.ex.
57 * "Space", "a", "Return", ...
58 * Prefixes are S-, C-, M- for shift, control, meta
59 * Prefixes can also be ignored by using the Tilde "~"
62 std::string::size_type parse(std::string const & s);
65 * Return the current sequence as a string.
68 std::string const print() const;
71 * Return the current sequence and available options as
72 * a string. No options are added if no curmap kb map exists.
74 std::string const printOptions() const;
76 /// Mark the sequence as deleted.
79 /// Reset sequence to become "deleted"
85 bool deleted() const {
89 /// length of sequence
90 KeySequence::size_type length() const {
91 return sequence.size();
94 /// Keymap to use if a new sequence is starting
97 /// Keymap to use for the next key
102 * Array holding the current key sequence as KeySyms.
103 * If sequence[length - 1] < 0xff it can be used as ISO8859 char
105 KeySequence sequence;
107 typedef std::pair<key_modifier::state, key_modifier::state>
110 /// modifiers for keys in the sequence
111 std::vector<modifier_pair> modifiers;
113 /// is keysequence deleted ?