1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
#ifndef _Trans_Manager_h_
|
|
|
|
#define _Trans_Manager_h_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "tex-accent.h"
|
|
|
|
#include "trans_decl.h"
|
|
|
|
|
|
|
|
class LyXText;
|
|
|
|
class LString;
|
|
|
|
class CharacterSet;
|
|
|
|
class Trans;
|
|
|
|
|
|
|
|
/// Translation State
|
|
|
|
class TransState {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
virtual ~TransState();
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string normalkey(char,char*)=0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool backspace()=0;
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string deadkey(char,KmodInfo)=0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
static const char TOKEN_SEP;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Translation FSM
|
|
|
|
class TransFSMData {
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
virtual ~TransFSMData()
|
|
|
|
{}
|
|
|
|
///
|
|
|
|
char deadkey_;
|
|
|
|
///
|
|
|
|
KmodInfo deadkey_info_;
|
|
|
|
///
|
|
|
|
char deadkey2_;
|
|
|
|
///
|
|
|
|
KmodInfo deadkey2_info_;
|
|
|
|
///
|
|
|
|
KmodException comb_info_;
|
|
|
|
///
|
|
|
|
TransState* init_state_;
|
|
|
|
///
|
|
|
|
TransState* deadkey_state_;
|
|
|
|
///
|
|
|
|
TransState* combined_state_;
|
|
|
|
///
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransFSMData();
|
|
|
|
///
|
|
|
|
TransState* currentState;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Init State
|
|
|
|
class TransInitState:
|
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransState {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransInitState();
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string normalkey(char,char*);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool backspace() { return true; }
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string deadkey(char,KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Deadkey State
|
|
|
|
class TransDeadkeyState:
|
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransState {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransDeadkeyState();
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string normalkey(char,char*);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool backspace()
|
|
|
|
{
|
|
|
|
currentState=init_state_;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string deadkey(char,KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Combined State
|
|
|
|
class TransCombinedState:
|
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransState {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransCombinedState();
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string normalkey(char,char*);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool backspace()
|
|
|
|
{
|
|
|
|
// cancel the second deadkey
|
|
|
|
deadkey2_=0;
|
|
|
|
deadkey2_info_.accent=TEX_NOACCENT;
|
|
|
|
currentState=deadkey_state_;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string deadkey(char,KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
class TransFSM:
|
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransInitState,
|
|
|
|
public TransDeadkeyState,
|
|
|
|
public TransCombinedState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransFSM();
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
class TransManager
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
TransFSM trans_fsm_;
|
|
|
|
///
|
|
|
|
Trans* active_;
|
|
|
|
///
|
|
|
|
Trans* t1_;
|
|
|
|
///
|
|
|
|
Trans* t2_;
|
|
|
|
///
|
|
|
|
static Trans* default_;
|
|
|
|
///
|
|
|
|
CharacterSet* chset_;
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void insert(string,LyXText*);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void insertVerbatim(const string&,LyXText*);
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransManager();
|
|
|
|
///
|
|
|
|
virtual ~TransManager();
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
int SetPrimary(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
int SetSecondary(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void EnablePrimary();
|
|
|
|
///
|
|
|
|
void EnableSecondary();
|
|
|
|
///
|
|
|
|
void DisableKeymap();
|
|
|
|
///
|
|
|
|
bool setCharset(const char*);
|
|
|
|
///
|
|
|
|
bool backspace()
|
|
|
|
{
|
|
|
|
return trans_fsm_.currentState->backspace();
|
|
|
|
}
|
|
|
|
///
|
|
|
|
void TranslateAndInsert(char,LyXText*);
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
inline string deadkey(char,KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
inline string normalkey(char,char*);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void deadkey(char,tex_accent,LyXText*);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string TransManager::normalkey(char c,char *t)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return trans_fsm_.currentState->normalkey(c,t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string TransManager::deadkey(char c,KmodInfo t)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return trans_fsm_.currentState->deadkey(c,t);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|