]> git.lyx.org Git - lyx.git/blobdiff - src/KeyMap.h
prepare Qt 5.6 builds
[lyx.git] / src / KeyMap.h
index 0dac18a6dfda705676c2369e453473b0ac1bd108..cd28782356ac98336fb791def7b84c5d5824d789 100644 (file)
 
 #include "support/strfwd.h"
 
-#include <tr1/memory>
+#include "support/shared_ptr.h"
+
 #include <vector>
 
 
 namespace lyx {
 
+namespace support {
+       class FileName; 
+}
+
 /// Defines key maps and actions for key sequences
 class KeyMap {
 public:
@@ -36,6 +41,12 @@ public:
                UserExtraUnbind //< \unbind loaded from user.bind, without
                                //<    corresponding entry in system bind file.
        };
+       enum BindReadType {
+               MissingOK,      //< It's OK if this file is missing.
+               Fallback,       //< If missing, fallback to default "cua". This should only 
+                               //< be used when attempting to read the user-secified bind file.
+               Default         //< Report error and return.
+       };
        /**
         * Bind/Unbind a key sequence to an action.
         * @return 0 on success, or position in string seq where error
@@ -71,8 +82,10 @@ public:
         *
         * @param bind_file bind file
         * @param unbind_map pointer to a KeyMap that holds \unbind bindings
+        * @param rt how to respond if the file can't be found
         */
-       bool read(std::string const & bind_file, KeyMap * unbind_map = 0);
+       bool read(std::string const & bind_file, KeyMap * unbind_map = 0, 
+                       BindReadType rt = Default);
 
        /** write to a bind file.
         * @param append append to the bind_file instead of overwrite it
@@ -150,11 +163,22 @@ private:
                /// Modifier masks
                ModifierPair mod;
                /// Keymap for prefix keys
-               std::tr1::shared_ptr<KeyMap> table;
+               shared_ptr<KeyMap> prefixes;
                /// Action for !prefix keys
                FuncRequest func;
        };
 
+       enum ReturnValues {
+               ReadOK,
+               ReadError,
+               FileError,
+               FormatMismatch
+       };
+       ///
+       bool read(support::FileName const & bind_file, KeyMap * unbind_map = 0);
+       ///
+       ReturnValues readWithoutConv(support::FileName const & bind_file, KeyMap * unbind_map = 0);
+
        /**
         * Given an action, find all keybindings
         * @param func the action