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"
17 #include "frontends/KeySymbol.h"
28 /// Holds a key sequence and the current and standard keymaps
31 typedef std::vector<KeySymbol> Sequence;
35 KeySequence() : stdmap(0), curmap(0), deleted_(true) {}
37 KeySequence(KeyMap * std, KeyMap * cur)
38 : stdmap(std), curmap(cur), deleted_(false) {}
41 * Add a key to the key sequence and look it up in the curmap
42 * if the latter is defined.
43 * @param keysym the key to add
44 * @param mod modifier mask
45 * @param nmod which modifiers to mask out for equality test
46 * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
49 addkey(KeySymbol const & keysym, key_modifier::state mod,
50 key_modifier::state nmod = key_modifier::none);
53 * Add a sequence of keys from a string to the sequence
54 * @return string::npos if OK, else error position in string
56 * Keys in the string must be separated with whitespace;
57 * Use the keysym names used by XStringToKeysym, f.ex.
58 * "Space", "a", "Return", ...
59 * Prefixes are S-, C-, M- for shift, control, meta
60 * Prefixes can also be ignored by using the Tilde "~"
63 size_t parse(std::string const & s);
66 * Return the current sequence as a string.
67 * @param forgui true if the string should use translations and
71 docstring const print(bool forgui) const;
74 * Return the current sequence and available options as
75 * a string. No options are added if no curmap kb map exists.
76 * @param forgui true if the string should use translations and
79 docstring const printOptions(bool forgui) const;
81 /// Mark the sequence as deleted.
84 /// Reset sequence to become "deleted"
90 bool deleted() const { return deleted_; }
92 /// length of sequence
93 size_t length() const { return sequence.size(); }
95 /// Keymap to use if a new sequence is starting
98 /// Keymap to use for the next key
103 * Array holding the current key sequence as KeySyms.
104 * If sequence[length - 1] < 0xff it can be used as ISO8859 char
108 typedef std::pair<key_modifier::state, key_modifier::state>
111 /// modifiers for keys in the sequence
112 std::vector<modifier_pair> modifiers;
114 /// is keysequence deleted ?