]> git.lyx.org Git - lyx.git/blobdiff - src/trans_mgr.h
A better fix for bug 675:
[lyx.git] / src / trans_mgr.h
index 1a6917386f585e9708336643c3e1ab2654074819..06e98991eb0d0d068df3c17d59f4f92d30da082f 100644 (file)
@@ -1,30 +1,42 @@
 // -*- C++ -*-
-#ifndef Trans_Manager_h
-#define Trans_Manager_h
+/**
+ * \file trans_mgr.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef TRANS_MANAGER_H
+#define TRANS_MANAGER_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "tex-accent.h"
-#include "trans_decl.h"
 #include "chset.h"
-#include "LString.h"
+#include "trans_decl.h"
+
+#include <boost/scoped_ptr.hpp>
+
 
+namespace lyx {
+
+class LCursor;
 class LyXText;
 class Trans;
 
-/// Translation State
+/// Translation state
 class TransState {
 public:
        ///
        virtual ~TransState() {}
        ///
-       virtual string normalkey(char, char *) = 0;
+       virtual std::string const normalkey(char) = 0;
        ///
        virtual bool backspace() = 0;
        ///
-       virtual string deadkey(char, KmodInfo) = 0;
+       virtual std::string const deadkey(char, KmodInfo) = 0;
        ///
        static char const TOKEN_SEP;
 };
@@ -44,7 +56,7 @@ protected:
        ///
        KmodInfo deadkey2_info_;
        ///
-       KmodException comb_info_;
+       Keyexc comb_info_;
        ///
        TransState * init_state_;
        ///
@@ -61,70 +73,62 @@ public:
 
 
 /// Init State
-class TransInitState : 
-       virtual public TransFSMData,
-       public TransState {
+class TransInitState :virtual public TransFSMData, public TransState {
 public:
        ///
        TransInitState();
        ///
-       virtual string normalkey(char, char *);
+       virtual std::string const normalkey(char);
        ///
        virtual bool backspace() { return true; }
        ///
-       virtual string deadkey(char, KmodInfo);
+       virtual std::string const deadkey(char, KmodInfo);
 };
 
 
 /// Deadkey State
-class TransDeadkeyState : 
-       virtual public TransFSMData,
-       public TransState {
+class TransDeadkeyState : virtual public TransFSMData, public TransState {
 public:
        ///
        TransDeadkeyState();
        ///
-       virtual string normalkey(char, char *);
+       virtual std::string const normalkey(char);
        ///
        virtual bool backspace() {
                currentState = init_state_;
                return false;
        }
        ///
-       virtual string deadkey(char, KmodInfo);
+       virtual std::string const deadkey(char, KmodInfo);
 };
 
 
 /// Combined State
-class TransCombinedState: 
-       virtual public TransFSMData,
-       public TransState {
+class TransCombinedState : virtual public TransFSMData, public TransState {
 public:
        ///
        TransCombinedState();
        ///
-       virtual string normalkey(char, char *);
+       virtual std::string const normalkey(char);
        ///
        virtual bool backspace() {
                // cancel the second deadkey
                deadkey2_ = 0;
                deadkey2_info_.accent = TEX_NOACCENT;
                currentState = deadkey_state_;
-               
+
                return false;
        }
        ///
-       virtual string deadkey(char, KmodInfo);
+       virtual std::string const deadkey(char, KmodInfo);
 };
 
 
 ///
-class TransFSM :       
-       virtual public TransFSMData,
-       public TransInitState,
-       public TransDeadkeyState,
-       public TransCombinedState
-{
+class TransFSM : virtual public TransFSMData,
+                public TransInitState,
+                public TransDeadkeyState,
+                public TransCombinedState {
 public:
        ///
        TransFSM();
@@ -139,58 +143,63 @@ private:
        ///
        Trans * active_;
        ///
-       Trans * t1_;
+       boost::scoped_ptr<Trans> t1_;
        ///
-       Trans * t2_;
+       boost::scoped_ptr<Trans> t2_;
        ///
-       static Trans default_;
+       static Trans default_;
        ///
        CharacterSet chset_;
        ///
-       void insert(string const &, LyXText *);
+       void insert(std::string const &, LyXText *, LCursor & cur);
        ///
-       void insertVerbatim(string const &, LyXText *);
+       void insertVerbatim(std::string const &, LyXText *, LCursor & cur);
 public:
        ///
        TransManager();
        ///
-       virtual ~TransManager();
+       ~TransManager();
        ///
-       int SetPrimary(string const &);
+       int setPrimary(std::string const &);
        ///
-       int SetSecondary(string const &);
+       int setSecondary(std::string const &);
        ///
-       void EnablePrimary();
+       void enablePrimary();
        ///
-       void EnableSecondary();
+       void enableSecondary();
        ///
-       void DisableKeymap();
+       void disableKeymap();
        ///
-       bool setCharset(const char *);
+       bool setCharset(std::string const &);
        ///
        bool backspace() {
                return trans_fsm_.currentState->backspace();
        }
        ///
-       void TranslateAndInsert(char, LyXText *);
+       void translateAndInsert(char, LyXText *, LCursor &);
        ///
-       inline string deadkey(char, KmodInfo);
+       std::string const deadkey(char, KmodInfo);
        ///
-       inline string normalkey(char, char *);
+       std::string const normalkey(char);
        ///
-       void deadkey(char, tex_accent, LyXText *);
+       void deadkey(char, tex_accent, LyXText *, LCursor &);
 };
 
 
-string TransManager::normalkey(char c, char * t)
+inline
+std::string const TransManager::normalkey(char c)
 {
-       return trans_fsm_.currentState->normalkey(c, t);
+       return trans_fsm_.currentState->normalkey(c);
 }
 
 
-string TransManager::deadkey(char c, KmodInfo t)
+inline
+std::string const TransManager::deadkey(char c, KmodInfo t)
 {
        return trans_fsm_.currentState->deadkey(c, t);
 }
 
-#endif
+
+} // namespace lyx
+
+#endif // TRANS_MANAGER_H