]> git.lyx.org Git - lyx.git/blobdiff - src/kbsequence.h
architectural changes to tex2lyx
[lyx.git] / src / kbsequence.h
index e00382d34edb58e13938541f940c2fe2eef5e22c..c63a9c72247a57f28239eed710e62205feebe8b0 100644 (file)
@@ -8,42 +8,47 @@
 #ifndef KBSEQUENCE_H
 #define KBSEQUENCE_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include <config.h>
 
-#include <vector>
+#include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
 #include "LString.h"
+#include <vector>
 
 class kb_keymap;
 
 /// Holds a key sequence and the current and standard keymaps
 class kb_sequence {
 public:
+       typedef std::vector<LyXKeySymPtr> KeySequence;
+
        friend class kb_keymap;
 
        ///
        kb_sequence(kb_keymap * std, kb_keymap * cur)
-               : stdmap(std), curmap(cur), length_(0), deleted_(false) {}
-
-
+               : stdmap(std), curmap(cur), deleted_(false) {}
 
        /**
         * Add a key to the key sequence and look it up in the curmap
         * if the latter is defined.
+        * @param keysym the key to add
         * @param mod modifier mask
         * @param nmod which modifiers to mask out for equality test
         * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
         */
-       int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
+       int addkey(LyXKeySymPtr keysym, key_modifier::state mod,
+                  key_modifier::state nmod = key_modifier::none);
 
        /**
         * Add a sequence of keys from a string to the sequence
         * @return string::npos if OK, else error position in string
         *
         * Keys in the string must be separated with whitespace;
-        * Use the keysym names used by XStringToKeysym
+        * Use the keysym names used by XStringToKeysym, f.ex.
+        * "Space", "a", "Return", ...
         * Prefixes are S-, C-, M- for shift, control, meta
+        * Prefixes can also be ignored by using the Tilde "~"
+        * f.ex.: "~S-Space".
         */
        string::size_type parse(string const & s);
 
@@ -62,9 +67,6 @@ public:
        /// Mark the sequence as deleted.
        void mark_deleted();
 
-       /// Return the ISO value of the last keysym in sequence, or 0
-       char getiso() const;
-
        /// Reset sequence to become "deleted"
        void reset();
 
@@ -76,8 +78,8 @@ public:
        }
 
        /// length of sequence
-       std::vector<unsigned int>::size_type length() const {
-               return length_;
+       KeySequence::size_type length() const {
+               return sequence.size();
        }
 
        /// Keymap to use if a new sequence is starting
@@ -87,20 +89,17 @@ public:
        kb_keymap * curmap;
 
 private:
-       /// get the keysym of last in sequence
-       unsigned int getsym() const;
-
        /**
-        * Array holding the current key sequence.
-        * If sequence[length-1] < 0xff it can be used as ISO8859 char
+        * Array holding the current key sequence as KeySyms.
+        * If sequence[length - 1] < 0xff it can be used as ISO8859 char
         */
-       std::vector<unsigned int> sequence;
+       KeySequence sequence;
 
-       /// modifiers for keys in the sequence
-       std::vector<unsigned int> modifiers;
+       typedef std::pair<key_modifier::state, key_modifier::state>
+               modifier_pair;
 
-       /// Current length of key sequence
-       std::vector<unsigned int>::size_type length_;
+       /// modifiers for keys in the sequence
+       std::vector<modifier_pair> modifiers;
 
        /// is keysequence deleted ?
        bool deleted_;