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/KeyModifier.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
48 FuncRequest const & addkey(KeySymbol const & keysym, KeyModifier mod,
49 KeyModifier nmod = NoModifier);
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 size_t parse(std::string const & s);
65 Portable, //< use a more portable format
66 ForGui, //< use platform specific translations and special characters
67 BindFile //< the format used in lyx bind files
71 * Return the current sequence as a string.
72 * @param format output format
75 docstring const print(outputFormat format) const;
78 * Return the current sequence and available options as
79 * a string. No options are added if no curmap kb map exists.
80 * @param forgui true if the string should use translations and
83 docstring const printOptions(bool forgui) const;
85 /// Reset sequence to become "deleted"
91 /// remove last key in sequence
94 bool deleted() const { return deleted_; }
96 /// length of sequence
97 size_t length() const { return sequence.size(); }
100 /// Keymap to use if a new sequence is starting
103 /// Keymap to use for the next key
107 * Array holding the current key sequence as KeySyms.
108 * If sequence[length - 1] < 0xff it can be used as ISO8859 char
112 typedef std::pair<KeyModifier, KeyModifier> ModifierPair;
114 /// modifiers for keys in the sequence
115 std::vector<ModifierPair> modifiers;
117 /// is keysequence deleted ?