1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef Trans_h
|
|
|
|
#define Trans_h
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "tex-accent.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include "trans_decl.h"
|
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
|
|
|
|
class TransManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
TransInterface: the interface that every translation class
|
|
|
|
should obey too.
|
|
|
|
Visitor pattern applied here
|
|
|
|
*/
|
|
|
|
class TransInterface {
|
|
|
|
public:
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual string process(char, TransManager &) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual bool isAccentDefined(tex_accent, KmodInfo &) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
DefaultTrans: the default translation class. Hols info
|
|
|
|
on tex-accents. Monostate
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
class DefaultTrans : public TransInterface {
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
static bool init_;
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
DefaultTrans();
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
virtual string process(char, TransManager &);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Trans: holds a .kmap file
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
class Trans : public TransInterface {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
Trans();
|
|
|
|
///
|
|
|
|
virtual ~Trans();
|
|
|
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
int Load(string const & language);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
bool IsDefined();
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
string const & GetName();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
string process(char, TransManager &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
bool isAccentDefined(tex_accent, KmodInfo &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
typedef KmodInfo kmod_list_decl;
|
|
|
|
///
|
|
|
|
typedef KmodException keyexc;
|
|
|
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void AddDeadkey(tex_accent, string const &, string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void FreeKeymap();
|
|
|
|
///
|
|
|
|
int Load(LyXLex &);
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
inline char * Match(char c);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void InsertException(keyexc & exclist, char c,
|
|
|
|
string const & data, bool = false,
|
1999-09-27 18:44:28 +00:00
|
|
|
tex_accent = TEX_NOACCENT);
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void FreeException(keyexc & exclist);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string name_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
char * keymap_[256];
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
char * Trans::Match(char c)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-10 14:45:32 +00:00
|
|
|
return keymap_[static_cast<unsigned char>(c)];
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|