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
17 #include "trans_decl.h"
19 #include <boost/scoped_ptr.hpp>
32 virtual ~TransState() {}
34 virtual docstring const normalkey(char_type) = 0;
36 virtual bool backspace() = 0;
38 virtual docstring const deadkey(char_type, KmodInfo) = 0;
40 static char_type 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 docstring const normalkey(char_type);
82 virtual bool backspace() { return true; }
84 virtual docstring const deadkey(char_type, KmodInfo);
89 class TransDeadkeyState : virtual public TransFSMData, public TransState {
94 virtual docstring const normalkey(char_type);
96 virtual bool backspace() {
97 currentState = init_state_;
101 virtual docstring const deadkey(char_type, KmodInfo);
106 class TransCombinedState : virtual public TransFSMData, public TransState {
109 TransCombinedState();
111 virtual docstring const normalkey(char_type);
113 virtual bool backspace() {
114 // cancel the second deadkey
116 deadkey2_info_.accent = TEX_NOACCENT;
117 currentState = deadkey_state_;
122 virtual docstring const deadkey(char_type, 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_;
151 void insert(docstring const &, LyXText *, LCursor & cur);
158 int setPrimary(std::string const &);
160 int setSecondary(std::string const &);
162 void enablePrimary();
164 void enableSecondary();
166 void disableKeymap();
169 return trans_fsm_.currentState->backspace();
172 void translateAndInsert(char_type, LyXText *, LCursor &);
174 docstring const deadkey(char_type, KmodInfo);
176 docstring const normalkey(char_type);
178 void deadkey(char_type, tex_accent, LyXText *, LCursor &);
183 docstring const TransManager::normalkey(char_type c)
185 return trans_fsm_.currentState->normalkey(c);
190 docstring const TransManager::deadkey(char_type c, KmodInfo t)
192 return trans_fsm_.currentState->deadkey(c, t);
198 #endif // TRANS_MANAGER_H