]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/LyXKeySym.h
Fix bug 3101 and 3108
[lyx.git] / src / frontends / LyXKeySym.h
index 79d977383e162e2d033a2ccc9935f37a982a38de..fe30a1c76955ef09a62189f2924d28535438c427 100644 (file)
 #ifndef LYXKEYSYM_H
 #define LYXKEYSYM_H
 
-#include "support/std_string.h"
+#include <string>
+
+#include "key_state.h"
+
+#include "support/docstring.h"
+
+#include <boost/shared_ptr.hpp>
+
+
+namespace lyx {
 
 /**
  * This is a base class for representing a keypress.
@@ -26,8 +35,11 @@ public:
 
        virtual ~LyXKeySym() {}
 
+       ///
+       virtual bool operator==(LyXKeySym const& ks) const = 0;
+
        /// Initialize with the name of a key. F. ex. "space" or "a"
-       virtual void init(string const & symbolname) = 0;
+       virtual void init(std::string const & symbolname) = 0;
 
        /// Is this a valid key?
        virtual bool isOK() const = 0;
@@ -36,24 +48,28 @@ public:
        virtual bool isModifier() const = 0;
 
        /// Is this normal insertable text ? (last ditch attempt only)
-       virtual bool isText() const { return false; }
+       virtual bool isText() const = 0;
 
        /// What is the symbolic name of this key? F.ex. "Return" or "c"
-       virtual string getSymbolName() const = 0;
+       virtual std::string getSymbolName() const = 0;
 
        /**
-        * Return the value of the keysym into the local ISO encoding.
-        * This converts the LyXKeySym to a 8-bit encoded character.
-        * This relies on user to use the right encoding.
+        * Return the value of the keysym into the UCS-4 encoding.
+        * This converts the LyXKeySym to a 32-bit encoded character.
         */
-       virtual char getISOEncoded(string const & encoding) const = 0;
+       virtual size_t getUCSEncoded() const = 0;
+
+       /**
+        * Return a string describing the KeySym with modifier mod.
+        * Use the native UI format when \c forgui is true.
+        */
+       virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
 };
 
 
-/**
- * We need to be able to equality compare these for the
- * sake of the keymap business.
- */
-bool operator==(LyXKeySym const & k1, LyXKeySym const & k2);
+typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
+
+
+} // namespace lyx
 
 #endif