1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef Trans_Manager_h
|
|
|
|
#define Trans_Manager_h
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "tex-accent.h"
|
|
|
|
#include "trans_decl.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "chset.h"
|
|
|
|
#include "LString.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
class LyXText;
|
|
|
|
class Trans;
|
|
|
|
|
|
|
|
/// Translation State
|
|
|
|
class TransState {
|
|
|
|
public:
|
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
virtual ~TransState() {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual string normalkey(char, char *) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual bool backspace() = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual string deadkey(char, KmodInfo) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
static char const TOKEN_SEP;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Translation FSM
|
|
|
|
class TransFSMData {
|
|
|
|
protected:
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual ~TransFSMData() {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
char deadkey_;
|
|
|
|
///
|
|
|
|
KmodInfo deadkey_info_;
|
|
|
|
///
|
|
|
|
char deadkey2_;
|
|
|
|
///
|
|
|
|
KmodInfo deadkey2_info_;
|
|
|
|
///
|
|
|
|
KmodException comb_info_;
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
TransState * init_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
TransState * deadkey_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
TransState * combined_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransFSMData();
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
TransState * currentState;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Init State
|
1999-12-21 06:10:21 +00:00
|
|
|
class TransInitState :
|
1999-09-27 18:44:28 +00:00
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransState {
|
|
|
|
public:
|
1999-12-21 06:10:21 +00:00
|
|
|
///
|
|
|
|
TransInitState();
|
|
|
|
///
|
|
|
|
virtual string normalkey(char, char *);
|
|
|
|
///
|
|
|
|
virtual bool backspace() { return true; }
|
|
|
|
///
|
|
|
|
virtual string deadkey(char, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Deadkey State
|
1999-12-21 06:10:21 +00:00
|
|
|
class TransDeadkeyState :
|
1999-09-27 18:44:28 +00:00
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransState {
|
|
|
|
public:
|
1999-12-21 06:10:21 +00:00
|
|
|
///
|
|
|
|
TransDeadkeyState();
|
|
|
|
///
|
|
|
|
virtual string normalkey(char, char *);
|
|
|
|
///
|
|
|
|
virtual bool backspace() {
|
1999-11-15 12:01:38 +00:00
|
|
|
currentState = init_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
1999-12-21 06:10:21 +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:
|
1999-12-21 06:10:21 +00:00
|
|
|
///
|
|
|
|
TransCombinedState();
|
|
|
|
///
|
|
|
|
virtual string normalkey(char, char *);
|
|
|
|
///
|
|
|
|
virtual bool backspace() {
|
1999-09-27 18:44:28 +00:00
|
|
|
// cancel the second deadkey
|
1999-11-15 12:01:38 +00:00
|
|
|
deadkey2_ = 0;
|
|
|
|
deadkey2_info_.accent = TEX_NOACCENT;
|
|
|
|
currentState = deadkey_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
1999-12-21 06:10:21 +00:00
|
|
|
///
|
|
|
|
virtual string deadkey(char, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
class TransFSM :
|
1999-09-27 18:44:28 +00:00
|
|
|
virtual public TransFSMData,
|
|
|
|
public TransInitState,
|
|
|
|
public TransDeadkeyState,
|
|
|
|
public TransCombinedState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TransFSM();
|
|
|
|
};
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
class TransManager {
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
TransFSM trans_fsm_;
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
Trans * active_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
Trans * t1_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
Trans * t2_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
static Trans * default_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
CharacterSet chset_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-01 00:01:17 +00:00
|
|
|
void insert(string const &, LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void insertVerbatim(string const &, 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();
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
bool setCharset(const char *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
bool backspace() {
|
1999-09-27 18:44:28 +00:00
|
|
|
return trans_fsm_.currentState->backspace();
|
|
|
|
}
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void TranslateAndInsert(char, LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
inline string deadkey(char, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
inline string normalkey(char, char *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void deadkey(char, tex_accent, LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
string TransManager::normalkey(char c, char * t)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
return trans_fsm_.currentState->normalkey(c, t);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
string TransManager::deadkey(char c, KmodInfo t)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
return trans_fsm_.currentState->deadkey(c, t);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|