2 #ifndef TRANS_MANAGER_H
3 #define TRANS_MANAGER_H
9 #include "tex-accent.h"
10 #include "trans_decl.h"
21 virtual ~TransState() {}
23 virtual string const normalkey(char) = 0;
25 virtual bool backspace() = 0;
27 virtual string const deadkey(char, KmodInfo) = 0;
29 static char const TOKEN_SEP;
37 virtual ~TransFSMData() {}
41 KmodInfo deadkey_info_;
45 KmodInfo deadkey2_info_;
49 TransState * init_state_;
51 TransState * deadkey_state_;
53 TransState * combined_state_;
59 TransState * currentState;
64 class TransInitState : virtual public TransFSMData, public TransState {
69 virtual string const normalkey(char);
71 virtual bool backspace() { return true; }
73 virtual string const deadkey(char, KmodInfo);
78 class TransDeadkeyState : virtual public TransFSMData, public TransState {
83 virtual string const normalkey(char);
85 virtual bool backspace() {
86 currentState = init_state_;
90 virtual string const deadkey(char, KmodInfo);
95 class TransCombinedState : virtual public TransFSMData, public TransState {
100 virtual string const normalkey(char);
102 virtual bool backspace() {
103 // cancel the second deadkey
105 deadkey2_info_.accent = TEX_NOACCENT;
106 currentState = deadkey_state_;
111 virtual string const deadkey(char, KmodInfo);
116 class TransFSM : virtual public TransFSMData,
117 public TransInitState,
118 public TransDeadkeyState,
119 public TransCombinedState {
138 static Trans default_;
142 void insert(string const &, LyXText *);
144 void insertVerbatim(string const &, LyXText *);
149 virtual ~TransManager();
151 int SetPrimary(string const &);
153 int SetSecondary(string const &);
155 void EnablePrimary();
157 void EnableSecondary();
159 void DisableKeymap();
161 bool setCharset(string const &);
164 return trans_fsm_.currentState->backspace();
167 void TranslateAndInsert(char, LyXText *);
169 string const deadkey(char, KmodInfo);
171 string const normalkey(char);
173 void deadkey(char, tex_accent, LyXText *);
178 string const TransManager::normalkey(char c)
180 return trans_fsm_.currentState->normalkey(c);
185 string const TransManager::deadkey(char c, KmodInfo t)
187 return trans_fsm_.currentState->deadkey(c, t);
190 #endif // TRANS_MANAGER_H