4 * Copyright 2001 the LyX Team
5 * Read the file COPYING
17 #include "frontends/key_state.h"
18 #include "frontends/LyXKeySym.h"
24 /// Holds a key sequence and the current and standard keymaps
27 typedef std::vector<LyXKeySymPtr> KeySequence;
29 friend class kb_keymap;
32 kb_sequence(kb_keymap * std, kb_keymap * cur)
33 : stdmap(std), curmap(cur), deleted_(false) {}
36 * Add a key to the key sequence and look it up in the curmap
37 * if the latter is defined.
38 * @param keysym the key to add
39 * @param mod modifier mask
40 * @param nmod which modifiers to mask out for equality test
41 * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
43 int addkey(LyXKeySymPtr keysym, key_modifier::state mod,
44 key_modifier::state nmod = key_modifier::none);
47 * Add a sequence of keys from a string to the sequence
48 * @return string::npos if OK, else error position in string
50 * Keys in the string must be separated with whitespace;
51 * Use the keysym names used by XStringToKeysym, f.ex.
52 * "Space", "a", "Return", ...
53 * Prefixes are S-, C-, M- for shift, control, meta
54 * Prefixes can also be ignored by using the Tilde "~"
57 string::size_type parse(string const & s);
60 * Return the current sequence as a string.
63 string const print() const;
66 * Return the current sequence and available options as
67 * a string. No options are added if no curmap kb map exists.
69 string const printOptions() const;
71 /// Mark the sequence as deleted.
75 * Return the value of the last keysym in the sequence
76 * in the local ISO encoding. If it does not encode
77 * in this encoding, return 0.
79 char getLastKeyEncoded() const;
81 /// Reset sequence to become "deleted"
87 bool deleted() const {
91 /// length of sequence
92 KeySequence::size_type length() const {
93 return sequence.size();
96 /// Keymap to use if a new sequence is starting
99 /// Keymap to use for the next key
103 /// get the keysym of last in sequence
104 LyXKeySymPtr getsym() const;
107 * Array holding the current key sequence as KeySyms.
108 * If sequence[length-1] < 0xff it can be used as ISO8859 char
110 KeySequence sequence;
112 typedef std::pair<key_modifier::state, key_modifier::state>
115 /// modifiers for keys in the sequence
116 std::vector<modifier_pair> modifiers;
118 /// is keysequence deleted ?