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>
29 virtual ~TransState() {}
31 virtual std::string
const normalkey(char) = 0;
33 virtual bool backspace() = 0;
35 virtual std::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 std::string
const normalkey(char);
79 virtual bool backspace() { return true; }
81 virtual std::string
const deadkey(char, KmodInfo
);
86 class TransDeadkeyState
: virtual public TransFSMData
, public TransState
{
91 virtual std::string
const normalkey(char);
93 virtual bool backspace() {
94 currentState
= init_state_
;
98 virtual std::string
const deadkey(char, KmodInfo
);
103 class TransCombinedState
: virtual public TransFSMData
, public TransState
{
106 TransCombinedState();
108 virtual std::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 std::string
const deadkey(char, KmodInfo
);
124 class TransFSM
: virtual public TransFSMData
,
125 public TransInitState
,
126 public TransDeadkeyState
,
127 public TransCombinedState
{
142 boost::scoped_ptr
<Trans
> t1_
;
144 boost::scoped_ptr
<Trans
> t2_
;
146 static Trans default_
;
150 void insert(std::string
const &, LyXText
*);
152 void insertVerbatim(std::string
const &, LyXText
*);
159 int SetPrimary(std::string
const &);
161 int SetSecondary(std::string
const &);
163 void EnablePrimary();
165 void EnableSecondary();
167 void DisableKeymap();
169 bool setCharset(std::string
const &);
172 return trans_fsm_
.currentState
->backspace();
175 void TranslateAndInsert(char, LyXText
*);
177 std::string
const deadkey(char, KmodInfo
);
179 std::string
const normalkey(char);
181 void deadkey(char, tex_accent
, LyXText
*);
186 std::string
const TransManager::normalkey(char c
)
188 return trans_fsm_
.currentState
->normalkey(c
);
193 std::string
const TransManager::deadkey(char c
, KmodInfo t
)
195 return trans_fsm_
.currentState
->deadkey(c
, t
);
198 #endif // TRANS_MANAGER_H