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"
20 #include <boost/scoped_ptr.hpp>
33 virtual ~TransState() {}
35 virtual std::string const normalkey(char) = 0;
37 virtual bool backspace() = 0;
39 virtual std::string const deadkey(char, KmodInfo) = 0;
41 static char const TOKEN_SEP;
49 virtual ~TransFSMData() {}
53 KmodInfo deadkey_info_;
57 KmodInfo deadkey2_info_;
61 TransState * init_state_;
63 TransState * deadkey_state_;
65 TransState * combined_state_;
71 TransState * currentState;
76 class TransInitState :virtual public TransFSMData, public TransState {
81 virtual std::string const normalkey(char);
83 virtual bool backspace() { return true; }
85 virtual std::string const deadkey(char, KmodInfo);
90 class TransDeadkeyState : virtual public TransFSMData, public TransState {
95 virtual std::string const normalkey(char);
97 virtual bool backspace() {
98 currentState = init_state_;
102 virtual std::string const deadkey(char, KmodInfo);
107 class TransCombinedState : virtual public TransFSMData, public TransState {
110 TransCombinedState();
112 virtual std::string const normalkey(char);
114 virtual bool backspace() {
115 // cancel the second deadkey
117 deadkey2_info_.accent = TEX_NOACCENT;
118 currentState = deadkey_state_;
123 virtual std::string const deadkey(char, KmodInfo);
128 class TransFSM : virtual public TransFSMData,
129 public TransInitState,
130 public TransDeadkeyState,
131 public TransCombinedState {
146 boost::scoped_ptr<Trans> t1_;
148 boost::scoped_ptr<Trans> t2_;
150 static Trans default_;
154 void insert(std::string const &, LyXText *, LCursor & cur);
156 void insertVerbatim(std::string const &, LyXText *, LCursor & cur);
163 int setPrimary(std::string const &);
165 int setSecondary(std::string const &);
167 void enablePrimary();
169 void enableSecondary();
171 void disableKeymap();
173 bool setCharset(std::string const &);
176 return trans_fsm_.currentState->backspace();
179 void translateAndInsert(char, LyXText *, LCursor &);
181 std::string const deadkey(char, KmodInfo);
183 std::string const normalkey(char);
185 void deadkey(char, tex_accent, LyXText *, LCursor &);
190 std::string const TransManager::normalkey(char c)
192 return trans_fsm_.currentState->normalkey(c);
197 std::string const TransManager::deadkey(char c, KmodInfo t)
199 return trans_fsm_.currentState->deadkey(c, t);
205 #endif // TRANS_MANAGER_H