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"
19 #include "support/std_string.h"
28 virtual ~TransState() {}
30 virtual string const normalkey(char) = 0;
32 virtual bool backspace() = 0;
34 virtual string const deadkey(char, KmodInfo) = 0;
36 static char const TOKEN_SEP;
44 virtual ~TransFSMData() {}
48 KmodInfo deadkey_info_;
52 KmodInfo deadkey2_info_;
56 TransState * init_state_;
58 TransState * deadkey_state_;
60 TransState * combined_state_;
66 TransState * currentState;
71 class TransInitState :virtual public TransFSMData, public TransState {
76 virtual string const normalkey(char);
78 virtual bool backspace() { return true; }
80 virtual string const deadkey(char, KmodInfo);
85 class TransDeadkeyState : virtual public TransFSMData, public TransState {
90 virtual string const normalkey(char);
92 virtual bool backspace() {
93 currentState = init_state_;
97 virtual string const deadkey(char, KmodInfo);
102 class TransCombinedState : virtual public TransFSMData, public TransState {
105 TransCombinedState();
107 virtual string const normalkey(char);
109 virtual bool backspace() {
110 // cancel the second deadkey
112 deadkey2_info_.accent = TEX_NOACCENT;
113 currentState = deadkey_state_;
118 virtual string const deadkey(char, KmodInfo);
123 class TransFSM : virtual public TransFSMData,
124 public TransInitState,
125 public TransDeadkeyState,
126 public TransCombinedState {
145 static Trans default_;
149 void insert(string const &, LyXText *);
151 void insertVerbatim(string const &, LyXText *);
156 virtual ~TransManager();
158 int SetPrimary(string const &);
160 int SetSecondary(string const &);
162 void EnablePrimary();
164 void EnableSecondary();
166 void DisableKeymap();
168 bool setCharset(string const &);
171 return trans_fsm_.currentState->backspace();
174 void TranslateAndInsert(char, LyXText *);
176 string const deadkey(char, KmodInfo);
178 string const normalkey(char);
180 void deadkey(char, tex_accent, LyXText *);
185 string const TransManager::normalkey(char c)
187 return trans_fsm_.currentState->normalkey(c);
192 string const TransManager::deadkey(char c, KmodInfo t)
194 return trans_fsm_.currentState->deadkey(c, t);
197 #endif // TRANS_MANAGER_H