// -*- 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 <boost/scoped_ptr.hpp>
+
+
+namespace lyx {
+
+class LCursor;
class LyXText;
-class LString;
-class CharacterSet;
class Trans;
-/// Translation State
+/// Translation state
class TransState {
public:
///
- virtual ~TransState();
+ virtual ~TransState() {}
///
- virtual string normalkey(char,char*)=0;
+ virtual docstring const normalkey(char_type) = 0;
///
- virtual bool backspace()=0;
+ virtual bool backspace() = 0;
///
- virtual string deadkey(char,KmodInfo)=0;
+ virtual docstring const deadkey(char_type, KmodInfo) = 0;
///
- static const char TOKEN_SEP;
+ static char_type const TOKEN_SEP;
};
class TransFSMData {
protected:
///
- virtual ~TransFSMData()
- {}
+ virtual ~TransFSMData() {}
///
- char deadkey_;
+ char_type deadkey_;
///
KmodInfo deadkey_info_;
///
- char deadkey2_;
+ char_type deadkey2_;
///
KmodInfo deadkey2_info_;
///
- KmodException comb_info_;
+ Keyexc comb_info_;
///
- TransState* init_state_;
+ TransState * init_state_;
///
- TransState* deadkey_state_;
+ TransState * deadkey_state_;
///
- TransState* combined_state_;
+ TransState * combined_state_;
///
public:
///
TransFSMData();
///
- TransState* currentState;
+ TransState * currentState;
};
/// Init State
-class TransInitState:
- virtual public TransFSMData,
- public TransState {
+class TransInitState :virtual public TransFSMData, public TransState {
public:
- ///
- TransInitState();
- ///
- virtual string normalkey(char,char*);
- ///
- virtual bool backspace() { return true; }
- ///
- virtual string deadkey(char,KmodInfo);
+ ///
+ TransInitState();
+ ///
+ virtual docstring const normalkey(char_type);
+ ///
+ virtual bool backspace() { return true; }
+ ///
+ virtual docstring const deadkey(char_type, 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 bool backspace()
- {
- currentState=init_state_;
+ ///
+ TransDeadkeyState();
+ ///
+ virtual docstring const normalkey(char_type);
+ ///
+ virtual bool backspace() {
+ currentState = init_state_;
return false;
}
- ///
- virtual string deadkey(char,KmodInfo);
+ ///
+ virtual docstring const deadkey(char_type, 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 bool backspace()
- {
+ ///
+ TransCombinedState();
+ ///
+ virtual docstring const normalkey(char_type);
+ ///
+ virtual bool backspace() {
// cancel the second deadkey
- deadkey2_=0;
- deadkey2_info_.accent=TEX_NOACCENT;
- currentState=deadkey_state_;
-
+ deadkey2_ = 0;
+ deadkey2_info_.accent = TEX_NOACCENT;
+ currentState = deadkey_state_;
+
return false;
}
- ///
- virtual string deadkey(char,KmodInfo);
+ ///
+ virtual docstring const deadkey(char_type, 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();
};
+
///
-class TransManager
-{
+class TransManager {
private:
///
TransFSM trans_fsm_;
///
- Trans* active_;
- ///
- Trans* t1_;
- ///
- Trans* t2_;
+ Trans * active_;
///
- static Trans* default_;
+ boost::scoped_ptr<Trans> t1_;
///
- CharacterSet* chset_;
+ boost::scoped_ptr<Trans> t2_;
///
- void insert(string,LyXText*);
+ static Trans default_;
///
- void insertVerbatim(const string&,LyXText*);
+ void insert(docstring 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 backspace()
- {
+ bool backspace() {
return trans_fsm_.currentState->backspace();
}
///
- void TranslateAndInsert(char,LyXText*);
+ void translateAndInsert(char_type, LyXText *, LCursor &);
///
- inline string deadkey(char,KmodInfo);
+ docstring const deadkey(char_type, KmodInfo);
///
- inline string normalkey(char,char*);
+ docstring const normalkey(char_type);
///
- void deadkey(char,tex_accent,LyXText*);
-
+ void deadkey(char_type, tex_accent, LyXText *, LCursor &);
};
-string TransManager::normalkey(char c,char *t)
+inline
+docstring const TransManager::normalkey(char_type c)
{
- return trans_fsm_.currentState->normalkey(c,t);
+ return trans_fsm_.currentState->normalkey(c);
}
-string TransManager::deadkey(char c,KmodInfo t)
+inline
+docstring const TransManager::deadkey(char_type c, KmodInfo t)
{
- return trans_fsm_.currentState->deadkey(c,t);
+ return trans_fsm_.currentState->deadkey(c, t);
}
-#endif
+
+} // namespace lyx
+
+#endif // TRANS_MANAGER_H