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 "tex-accent.h"
18 #include "trans_decl.h"
20 #include "support/std_string.h"
29 virtual ~TransState() {}
31 virtual string const normalkey(char) = 0;
33 virtual bool backspace() = 0;
35 virtual string const deadkey(char, KmodInfo) = 0;
37 static char const TOKEN_SEP;
45 virtual ~TransFSMData() {}
49 KmodInfo deadkey_info_;
53 KmodInfo deadkey2_info_;
57 TransState * init_state_;
59 TransState * deadkey_state_;
61 TransState * combined_state_;
67 TransState * currentState;
72 class TransInitState :virtual public TransFSMData, public TransState {
77 virtual string const normalkey(char);
79 virtual bool backspace() { return true; }
81 virtual string const deadkey(char, KmodInfo);
86 class TransDeadkeyState : virtual public TransFSMData, public TransState {
91 virtual string const normalkey(char);
93 virtual bool backspace() {
94 currentState = init_state_;
98 virtual string const deadkey(char, KmodInfo);
103 class TransCombinedState : virtual public TransFSMData, public TransState {
106 TransCombinedState();
108 virtual string const normalkey(char);
110 virtual bool backspace() {
111 // cancel the second deadkey
113 deadkey2_info_.accent = TEX_NOACCENT;
114 currentState = deadkey_state_;
119 virtual string const deadkey(char, KmodInfo);
124 class TransFSM : virtual public TransFSMData,
125 public TransInitState,
126 public TransDeadkeyState,
127 public TransCombinedState {
146 static Trans default_;
150 void insert(string const &, LyXText *);
152 void insertVerbatim(string const &, LyXText *);
157 virtual ~TransManager();
159 int SetPrimary(string const &);
161 int SetSecondary(string const &);
163 void EnablePrimary();
165 void EnableSecondary();
167 void DisableKeymap();
169 bool setCharset(string const &);
172 return trans_fsm_.currentState->backspace();
175 void TranslateAndInsert(char, LyXText *);
177 string const deadkey(char, KmodInfo);
179 string const normalkey(char);
181 void deadkey(char, tex_accent, LyXText *);
186 string const TransManager::normalkey(char c)
188 return trans_fsm_.currentState->normalkey(c);
193 string const TransManager::deadkey(char c, KmodInfo t)
195 return trans_fsm_.currentState->deadkey(c, t);
198 #endif // TRANS_MANAGER_H