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"
27 virtual ~TransState() {}
29 virtual std::string const normalkey(char) = 0;
31 virtual bool backspace() = 0;
33 virtual std::string const deadkey(char, KmodInfo) = 0;
35 static char const TOKEN_SEP;
43 virtual ~TransFSMData() {}
47 KmodInfo deadkey_info_;
51 KmodInfo deadkey2_info_;
55 TransState * init_state_;
57 TransState * deadkey_state_;
59 TransState * combined_state_;
65 TransState * currentState;
70 class TransInitState :virtual public TransFSMData, public TransState {
75 virtual std::string const normalkey(char);
77 virtual bool backspace() { return true; }
79 virtual std::string const deadkey(char, KmodInfo);
84 class TransDeadkeyState : virtual public TransFSMData, public TransState {
89 virtual std::string const normalkey(char);
91 virtual bool backspace() {
92 currentState = init_state_;
96 virtual std::string const deadkey(char, KmodInfo);
101 class TransCombinedState : virtual public TransFSMData, public TransState {
104 TransCombinedState();
106 virtual std::string const normalkey(char);
108 virtual bool backspace() {
109 // cancel the second deadkey
111 deadkey2_info_.accent = TEX_NOACCENT;
112 currentState = deadkey_state_;
117 virtual std::string const deadkey(char, KmodInfo);
122 class TransFSM : virtual public TransFSMData,
123 public TransInitState,
124 public TransDeadkeyState,
125 public TransCombinedState {
144 static Trans default_;
148 void insert(std::string const &, LyXText *);
150 void insertVerbatim(std::string const &, LyXText *);
155 virtual ~TransManager();
157 int SetPrimary(std::string const &);
159 int SetSecondary(std::string const &);
161 void EnablePrimary();
163 void EnableSecondary();
165 void DisableKeymap();
167 bool setCharset(std::string const &);
170 return trans_fsm_.currentState->backspace();
173 void TranslateAndInsert(char, LyXText *);
175 std::string const deadkey(char, KmodInfo);
177 std::string const normalkey(char);
179 void deadkey(char, tex_accent, LyXText *);
184 std::string const TransManager::normalkey(char c)
186 return trans_fsm_.currentState->normalkey(c);
191 std::string const TransManager::deadkey(char c, KmodInfo t)
193 return trans_fsm_.currentState->deadkey(c, t);
196 #endif // TRANS_MANAGER_H