X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FKeySequence.h;h=a0eb74eb03b2c80e657c2588a622621b23c54093;hb=3d4076b598deb18660e50ec9c327efc3b15f15d0;hp=3aead2826c1cd0ad7d38b6771381e9e77aa5e8cd;hpb=5265a8c02c7223f72dda771fd776c104bc729487;p=lyx.git diff --git a/src/KeySequence.h b/src/KeySequence.h index 3aead2826c..a0eb74eb03 100644 --- a/src/KeySequence.h +++ b/src/KeySequence.h @@ -4,17 +4,17 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Jean-Marc Lasgouttes * * Full author contact details are available in file CREDITS. */ -#ifndef KB_SEQUENCE_H -#define KB_SEQUENCE_H +#ifndef KEYSEQUENCE_H +#define KEYSEQUENCE_H -#include "frontends/key_state.h" -#include "frontends/LyXKeySym.h" +#include "frontends/KeyModifier.h" +#include "frontends/KeySymbol.h" #include #include @@ -28,10 +28,11 @@ class FuncRequest; /// Holds a key sequence and the current and standard keymaps class KeySequence { public: - typedef std::vector Sequence; + typedef std::vector Sequence; friend class KeyMap; + KeySequence() : stdmap(0), curmap(0), deleted_(true) {} /// KeySequence(KeyMap * std, KeyMap * cur) : stdmap(std), curmap(cur), deleted_(false) {} @@ -44,9 +45,8 @@ public: * @param nmod which modifiers to mask out for equality test * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION */ - FuncRequest const & - addkey(LyXKeySymPtr keysym, key_modifier::state mod, - key_modifier::state nmod = key_modifier::none); + FuncRequest const & addkey(KeySymbol const & keysym, KeyModifier mod, + KeyModifier nmod = NoModifier); /** * Add a sequence of keys from a string to the sequence @@ -61,54 +61,58 @@ public: */ size_t parse(std::string const & s); + enum outputFormat { + Portable, //< use a more portable format + ForGui, //< use platform specific translations and special characters + BindFile //< the format used in lyx bind files + }; + /** * Return the current sequence as a string. - * @param forgui true if the string should use translations and - * special characters. + * @param format output format * @see parse() */ - docstring const print(bool forgui) const; + docstring const print(outputFormat format) const; /** * Return the current sequence and available options as * a string. No options are added if no curmap kb map exists. - * @param forgui true if the string should use translations and - * special characters. + * @param forgui true if the string should use translations and + * special characters. */ docstring const printOptions(bool forgui) const; - /// Mark the sequence as deleted. - void mark_deleted(); - /// Reset sequence to become "deleted" void reset(); /// clear in full void clear(); + /// remove last key in sequence + void removeKey(); + bool deleted() const { return deleted_; } /// length of sequence size_t length() const { return sequence.size(); } +private: /// Keymap to use if a new sequence is starting KeyMap * stdmap; /// Keymap to use for the next key KeyMap * curmap; -private: /** * Array holding the current key sequence as KeySyms. * If sequence[length - 1] < 0xff it can be used as ISO8859 char */ Sequence sequence; - typedef std::pair - modifier_pair; + typedef std::pair ModifierPair; /// modifiers for keys in the sequence - std::vector modifiers; + std::vector modifiers; /// is keysequence deleted ? bool deleted_;