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.
19 #include "support/docstring.h"
72 TEX_MAX_ACCENT = TEX_OGONEK
79 /// UCS4 code point of this accent
88 extern TeXAccent get_accent(FuncCode action);
93 /// character to make exception
97 /// Combination with another deadkey
99 /// The accent comined with
104 typedef std::list<Keyexc> KmodException;
114 KmodException exception_list;
118 /////////////////////////////////////////////////////////////////////
120 // Trans: holds a .kmap file
122 /////////////////////////////////////////////////////////////////////
129 ~Trans() { freeKeymap(); }
132 int load(std::string const & language);
134 bool isDefined() const;
136 std::string const & getName() const { return name_; }
138 docstring const process(char_type, TransManager &);
140 bool isAccentDefined(tex_accent, KmodInfo &) const;
144 void addDeadkey(tex_accent, docstring const &);
150 docstring const & match(char_type c);
152 void insertException(KmodException & exclist, char_type c,
153 docstring const & data, bool = false,
154 tex_accent = TEX_NOACCENT);
156 void freeException(KmodException & exclist);
161 std::map<char_type, docstring> keymap_;
163 std::map<tex_accent, KmodInfo> kmod_list_;
168 inline docstring const & Trans::match(char_type c)
170 std::map<char_type, docstring>::iterator it = keymap_.find(c);
171 if (it != keymap_.end()) {
174 static docstring dummy;
179 /////////////////////////////////////////////////////////////////////
183 /////////////////////////////////////////////////////////////////////
185 /// Translation state
189 virtual ~TransState() {}
191 virtual docstring const normalkey(char_type) = 0;
193 virtual bool backspace() = 0;
195 virtual docstring const deadkey(char_type, KmodInfo) = 0;
197 static char_type const TOKEN_SEP;
205 virtual ~TransFSMData() {}
209 KmodInfo deadkey_info_;
213 KmodInfo deadkey2_info_;
217 TransState * init_state_;
219 TransState * deadkey_state_;
221 TransState * combined_state_;
227 TransState * currentState;
232 class TransInitState : virtual public TransFSMData, public TransState {
237 virtual docstring const normalkey(char_type);
239 virtual bool backspace() { return true; }
241 virtual docstring const deadkey(char_type, KmodInfo);
246 class TransDeadkeyState : virtual public TransFSMData, public TransState {
251 virtual docstring const normalkey(char_type);
253 virtual bool backspace() {
254 currentState = init_state_;
258 virtual docstring const deadkey(char_type, KmodInfo);
263 class TransCombinedState : virtual public TransFSMData, public TransState {
266 TransCombinedState();
268 virtual docstring const normalkey(char_type);
270 virtual bool backspace() {
271 // cancel the second deadkey
273 deadkey2_info_.accent = TEX_NOACCENT;
274 currentState = deadkey_state_;
279 virtual docstring const deadkey(char_type, KmodInfo);
284 class TransFSM : virtual public TransFSMData,
285 public TransInitState,
286 public TransDeadkeyState,
287 public TransCombinedState {
295 /////////////////////////////////////////////////////////////////////
299 /////////////////////////////////////////////////////////////////////
312 static Trans default_;
314 void insert(docstring const &, Text *, Cursor & cur);
319 int setPrimary(std::string const &);
321 int setSecondary(std::string const &);
323 void enablePrimary();
325 void enableSecondary();
327 void disableKeymap();
329 bool backspace() { return trans_fsm_.currentState->backspace(); }
331 void translateAndInsert(char_type, Text *, Cursor &);
333 docstring const deadkey(char_type c, KmodInfo t)
334 { return trans_fsm_.currentState->deadkey(c, t); }
336 docstring const normalkey(char_type c)
337 { return trans_fsm_.currentState->normalkey(c); }
339 void deadkey(char_type, tex_accent, Text *, Cursor &);