4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Matthias Ettrich
11 * Full author contact details are available in file CREDITS.
14 #ifndef TRANS_MANAGER_H
15 #define TRANS_MANAGER_H
18 #include "trans_decl.h"
20 #include <boost/scoped_ptr.hpp>
32 virtual ~TransState() {}
34 virtual std::string const normalkey(char) = 0;
36 virtual bool backspace() = 0;
38 virtual std::string const deadkey(char, KmodInfo) = 0;
40 static char const TOKEN_SEP;
48 virtual ~TransFSMData() {}
52 KmodInfo deadkey_info_;
56 KmodInfo deadkey2_info_;
60 TransState * init_state_;
62 TransState * deadkey_state_;
64 TransState * combined_state_;
70 TransState * currentState;
75 class TransInitState :virtual public TransFSMData, public TransState {
80 virtual std::string const normalkey(char);
82 virtual bool backspace() { return true; }
84 virtual std::string const deadkey(char, KmodInfo);
89 class TransDeadkeyState : virtual public TransFSMData, public TransState {
94 virtual std::string const normalkey(char);
96 virtual bool backspace() {
97 currentState = init_state_;
101 virtual std::string const deadkey(char, KmodInfo);
106 class TransCombinedState : virtual public TransFSMData, public TransState {
109 TransCombinedState();
111 virtual std::string const normalkey(char);
113 virtual bool backspace() {
114 // cancel the second deadkey
116 deadkey2_info_.accent = TEX_NOACCENT;
117 currentState = deadkey_state_;
122 virtual std::string const deadkey(char, KmodInfo);
127 class TransFSM : virtual public TransFSMData,
128 public TransInitState,
129 public TransDeadkeyState,
130 public TransCombinedState {
145 boost::scoped_ptr<Trans> t1_;
147 boost::scoped_ptr<Trans> t2_;
149 static Trans default_;
153 void insert(std::string const &, LyXText *);
155 void insertVerbatim(std::string const &, LyXText *);
162 int setPrimary(std::string const &);
164 int setSecondary(std::string const &);
166 void enablePrimary();
168 void enableSecondary();
170 void disableKeymap();
172 bool setCharset(std::string const &);
175 return trans_fsm_.currentState->backspace();
178 void translateAndInsert(char, LyXText *);
180 std::string const deadkey(char, KmodInfo);
182 std::string const normalkey(char);
184 void deadkey(char, tex_accent, LyXText *);
189 std::string const TransManager::normalkey(char c)
191 return trans_fsm_.currentState->normalkey(c);
196 std::string const TransManager::deadkey(char c, KmodInfo t)
198 return trans_fsm_.currentState->deadkey(c, t);
204 #endif // TRANS_MANAGER_H