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"
70 TEX_MAX_ACCENT
= TEX_OGONEK
77 /// UCS4 code point of this accent
86 extern TeXAccent
get_accent(FuncCode action
);
91 /// character to make exception
95 /// Combination with another deadkey
97 /// The accent comined with
102 typedef std::list
<Keyexc
> KmodException
;
112 KmodException exception_list
;
116 /////////////////////////////////////////////////////////////////////
118 // Trans: holds a .kmap file
120 /////////////////////////////////////////////////////////////////////
127 ~Trans() { freeKeymap(); }
130 int load(std::string
const & language
);
132 bool isDefined() const;
134 std::string
const & getName() const { return name_
; }
136 docstring
const process(char_type
, TransManager
&);
138 bool isAccentDefined(tex_accent
, KmodInfo
&) const;
142 void addDeadkey(tex_accent
, docstring
const &);
148 docstring
const & match(char_type c
);
150 void insertException(KmodException
& exclist
, char_type c
,
151 docstring
const & data
, bool = false,
152 tex_accent
= TEX_NOACCENT
);
154 void freeException(KmodException
& exclist
);
159 std::map
<char_type
, docstring
> keymap_
;
161 std::map
<tex_accent
, KmodInfo
> kmod_list_
;
166 inline docstring
const & Trans::match(char_type c
)
168 std::map
<char_type
, docstring
>::iterator it
= keymap_
.find(c
);
169 if (it
!= keymap_
.end()) {
172 static docstring dummy
;
177 /////////////////////////////////////////////////////////////////////
181 /////////////////////////////////////////////////////////////////////
183 /// Translation state
187 virtual ~TransState() {}
189 virtual docstring
const normalkey(char_type
) = 0;
191 virtual bool backspace() = 0;
193 virtual docstring
const deadkey(char_type
, KmodInfo
) = 0;
195 static char_type
const TOKEN_SEP
;
203 virtual ~TransFSMData() {}
207 KmodInfo deadkey_info_
;
211 KmodInfo deadkey2_info_
;
215 TransState
* init_state_
;
217 TransState
* deadkey_state_
;
219 TransState
* combined_state_
;
225 TransState
* currentState
;
230 class TransInitState
: virtual public TransFSMData
, public TransState
{
235 virtual docstring
const normalkey(char_type
);
237 virtual bool backspace() { return true; }
239 virtual docstring
const deadkey(char_type
, KmodInfo
);
244 class TransDeadkeyState
: virtual public TransFSMData
, public TransState
{
249 virtual docstring
const normalkey(char_type
);
251 virtual bool backspace() {
252 currentState
= init_state_
;
256 virtual docstring
const deadkey(char_type
, KmodInfo
);
261 class TransCombinedState
: virtual public TransFSMData
, public TransState
{
264 TransCombinedState();
266 virtual docstring
const normalkey(char_type
);
268 virtual bool backspace() {
269 // cancel the second deadkey
271 deadkey2_info_
.accent
= TEX_NOACCENT
;
272 currentState
= deadkey_state_
;
277 virtual docstring
const deadkey(char_type
, KmodInfo
);
282 class TransFSM
: virtual public TransFSMData
,
283 public TransInitState
,
284 public TransDeadkeyState
,
285 public TransCombinedState
{
293 /////////////////////////////////////////////////////////////////////
297 /////////////////////////////////////////////////////////////////////
310 static Trans default_
;
312 void insert(docstring
const &, Text
*, Cursor
& cur
);
317 int setPrimary(std::string
const &);
319 int setSecondary(std::string
const &);
321 void enablePrimary();
323 void enableSecondary();
325 void disableKeymap();
327 bool backspace() { return trans_fsm_
.currentState
->backspace(); }
329 void translateAndInsert(char_type
, Text
*, Cursor
&);
331 docstring
const deadkey(char_type c
, KmodInfo t
)
332 { return trans_fsm_
.currentState
->deadkey(c
, t
); }
334 docstring
const normalkey(char_type c
)
335 { return trans_fsm_
.currentState
->normalkey(c
); }
337 void deadkey(char_type
, tex_accent
, Text
*, Cursor
&);