]> git.lyx.org Git - lyx.git/blobdiff - src/KeyMap.h
Move editing, shortcuts, keyboard/mouse and completion to a separate category in...
[lyx.git] / src / KeyMap.h
index 06caf1a37ee8e68560cb3903af5deee6f278434e..acb0c22110ccdd0093a52aadd9e4a0802dfee1a0 100644 (file)
 #define KEYMAP_H
 
 #include "FuncRequest.h"
+#include "KeySequence.h"
 
-#include "frontends/KeyModifier.h"
-#include "frontends/KeySymbol.h"
-
-#include "support/docstream.h"
+#include "support/strfwd.h"
 
 #include <boost/shared_ptr.hpp>
-#include <boost/tuple/tuple.hpp>
 
 #include <vector>
-#include <deque>
 
 
 namespace lyx {
 
-class KeySequence;
-
 /// Defines key maps and actions for key sequences
 class KeyMap {
 public:
        /**
-        * Bind a key sequence to an action.
+        * Bind/Unbind a key sequence to an action.
         * @return 0 on success, or position in string seq where error
         * occurs.
         * See KeySequence::parse for the syntax of the seq string
         */
        size_t bind(std::string const & seq, FuncRequest const & func);
-
-       // Unbind a key sequence
        size_t unbind(std::string const & seq, FuncRequest const & func);
 
+       /**
+        * Define/Undefine an action for a key sequence.
+        * @param r internal recursion level
+        */
+       void bind(KeySequence * seq, FuncRequest const & func,
+                   unsigned int r = 0);
+       void unbind(KeySequence * seq, FuncRequest const & func,
+                   unsigned int r = 0);
+
+
        // if a keybinding has been defined.
        bool hasBinding(KeySequence const & seq, FuncRequest const & func,
                        unsigned int r = 0);
@@ -88,15 +90,21 @@ public:
        lookup(KeySymbol const & key, KeyModifier mod, KeySequence * seq) const;
 
        ///
-       typedef std::deque<KeySequence> Bindings;
+       typedef std::vector<KeySequence> Bindings;
 
        /// Given an action, find all keybindings.
-       Bindings findbindings(FuncRequest const & func) const;
+       Bindings findBindings(FuncRequest const & func) const;
 
        /// Given an action, print the keybindings.
-       docstring const printbindings(FuncRequest const & func) const;
-
-       typedef boost::tuple<FuncRequest, KeySequence, int> Binding; 
+       docstring printBindings(FuncRequest const & func) const;
+
+       struct Binding {
+               Binding(FuncRequest const & r, KeySequence const & s, int t)
+                       : request(r), sequence(s), tag(t) {}
+               FuncRequest request;
+               KeySequence sequence;
+               int tag;
+       }; 
        typedef std::vector<Binding> BindingList;
        /**
         * Return all lfun and their associated bindings.
@@ -130,32 +138,20 @@ private:
        struct Key {
                /// Keysym
                KeySymbol code;
-
                /// Modifier masks
                ModifierPair mod;
-
                /// Keymap for prefix keys
                boost::shared_ptr<KeyMap> table;
-
                /// Action for !prefix keys
                FuncRequest func;
        };
 
-       /**
-        * Define an action for a key sequence.
-        * @param r internal recursion level
-        */
-       void defkey(KeySequence * seq, FuncRequest const & func,
-                   unsigned int r = 0);
-       void delkey(KeySequence * seq, FuncRequest const & func,
-                   unsigned int r = 0);
-
        /**
         * Given an action, find all keybindings
         * @param func the action
         * @param prefix a sequence to prepend the results
         */
-       Bindings findbindings(FuncRequest const & func,
+       Bindings findBindings(FuncRequest const & func,
                              KeySequence const & prefix) const;
        
        void listBindings(BindingList & list, KeySequence const & prefix,