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>
20 #include "support/std_string.h"
26 /// Holds a key sequence and the current and standard keymaps
29 typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
30 typedef std::vector<LyXKeySymPtr> KeySequence;
32 friend class kb_keymap;
35 kb_sequence(kb_keymap * std, kb_keymap * cur)
36 : stdmap(std), curmap(cur), deleted_(false) {}
39 * Add a key to the key sequence and look it up in the curmap
40 * if the latter is defined.
41 * @param keysym the key to add
42 * @param mod modifier mask
43 * @param nmod which modifiers to mask out for equality test
44 * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
46 int addkey(LyXKeySymPtr keysym, key_modifier::state mod,
47 key_modifier::state nmod = key_modifier::none);
50 * Add a sequence of keys from a string to the sequence
51 * @return string::npos if OK, else error position in string
53 * Keys in the string must be separated with whitespace;
54 * Use the keysym names used by XStringToKeysym, f.ex.
55 * "Space", "a", "Return", ...
56 * Prefixes are S-, C-, M- for shift, control, meta
57 * Prefixes can also be ignored by using the Tilde "~"
60 string::size_type parse(string const & s);
63 * Return the current sequence as a string.
66 string const print() const;
69 * Return the current sequence and available options as
70 * a string. No options are added if no curmap kb map exists.
72 string const printOptions() const;
74 /// Mark the sequence as deleted.
77 /// Reset sequence to become "deleted"
83 bool deleted() const {
87 /// length of sequence
88 KeySequence::size_type length() const {
89 return sequence.size();
92 /// Keymap to use if a new sequence is starting
95 /// Keymap to use for the next key
100 * Array holding the current key sequence as KeySyms.
101 * If sequence[length - 1] < 0xff it can be used as ISO8859 char
103 KeySequence sequence;
105 typedef std::pair<key_modifier::state, key_modifier::state>
108 /// modifiers for keys in the sequence
109 std::vector<modifier_pair> modifiers;
111 /// is keysequence deleted ?