]> git.lyx.org Git - lyx.git/blobdiff - src/kbsequence.h
fix typo that put too many include paths for most people
[lyx.git] / src / kbsequence.h
index 8ad1a5ae6adf548c1a8dbf1ff5745e33286594b0..e00382d34edb58e13938541f940c2fe2eef5e22c 100644 (file)
@@ -1,10 +1,9 @@
 // -*- C++ -*-
-/* ======================================================================= *\
-   File   : kbmap.h, kbmap.h,v 1.3 1996/12/10 04:35:57 larsbj Exp
-   Author : chb, 30.Oct.1995
-   Docu   : see kbmap.C
-   Purpose: class definitions for XKeyEvent keymap handling
-   \* ==================================================================== */
+/**
+ * \file kbsequence.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ */
 
 #ifndef KBSEQUENCE_H
 #define KBSEQUENCE_H
@@ -21,52 +20,90 @@ class kb_keymap;
 /// Holds a key sequence and the current and standard keymaps
 class kb_sequence {
 public:
+       friend class kb_keymap;
+
        ///
-       kb_sequence() {
-               stdmap = curmap = 0;
-               length = 0;
-       }
+       kb_sequence(kb_keymap * std, kb_keymap * cur)
+               : stdmap(std), curmap(cur), length_(0), deleted_(false) {}
+
+
 
-       /** Add a key to the key sequence and look it up in the curmap
-           if the latter is defined. */
+       /**
+        * Add a key to the key sequence and look it up in the curmap
+        * if the latter is defined.
+        * @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 print(string & buf, bool when_defined = false) const;
-       
-        ///
-       int printOptions(string & buf) const;
-       
-       /// Make length negative to mark the sequence as deleted
-       void delseq();
+       /**
+        * 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
+        * Prefixes are S-, C-, M- for shift, control, meta
+        */
+       string::size_type parse(string const & s);
 
-       ///
+       /**
+        * Return the current sequence as a string.
+        * @see parse()
+        */
+       string const print() const;
+
+       /**
+        * Return the current sequence and available options as
+        * a string. No options are added if no curmap kb map exists.
+        */
+       string const printOptions() const;
+
+       /// Mark the sequence as deleted.
+       void mark_deleted();
+
+       /// Return the ISO value of the last keysym in sequence, or 0
        char getiso() const;
-       
-       ///
-       unsigned int getsym() const;
-       
-       ///
+
+       /// Reset sequence to become "deleted"
        void reset();
-       
-       ///
-       string::size_type parse(string const & s);
-       
+
+       /// clear in full
+       void clear();
+
+       bool deleted() const {
+               return deleted_;
+       }
+
+       /// length of sequence
+       std::vector<unsigned int>::size_type length() const {
+               return length_;
+       }
+
        /// Keymap to use if a new sequence is starting
        kb_keymap * stdmap;
-       
+
        /// Keymap to use for the next key
        kb_keymap * curmap;
-       
-       /** Array holding the current key sequence.
-           If sequence[length-1] < 0xff it can be used as ISO8859 char */
+
+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
+        */
        std::vector<unsigned int> sequence;
-       
-       ///
+
+       /// modifiers for keys in the sequence
        std::vector<unsigned int> modifiers;
-       
+
        /// Current length of key sequence
-       int length;
+       std::vector<unsigned int>::size_type length_;
+
+       /// is keysequence deleted ?
+       bool deleted_;
 };
 
 #endif