1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2001-07-12 11:11:10 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "trans.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
2001-07-29 17:39:01 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "tex-strings.h"
|
|
|
|
#include "lyxlex.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "trans_mgr.h"
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// KmodInfo
|
|
|
|
KmodInfo::KmodInfo()
|
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-11-15 12:01:38 +00:00
|
|
|
exception_list = 0;
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
// Default Trans
|
1999-11-15 12:01:38 +00:00
|
|
|
bool DefaultTrans::init_ = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
DefaultTrans::DefaultTrans()
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
if (init_ == false) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// Do initialization
|
1999-11-15 12:01:38 +00:00
|
|
|
init_ = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-07 17:52:03 +00:00
|
|
|
#if 0
|
2000-09-14 17:53:12 +00:00
|
|
|
string const DefaultTrans::process(char c, TransManager & k)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
char dummy[2] = "?";
|
|
|
|
dummy[0] = c;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
return k.normalkey(c, dummy);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-07-07 17:52:03 +00:00
|
|
|
#else
|
|
|
|
string const DefaultTrans::process(char c, TransManager & k)
|
|
|
|
{
|
|
|
|
return k.normalkey(c);
|
|
|
|
}
|
|
|
|
#endif
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Trans class
|
|
|
|
|
|
|
|
Trans::Trans()
|
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
2000-11-04 10:00:12 +00:00
|
|
|
for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_[i] = 0;
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Trans::~Trans()
|
|
|
|
{
|
|
|
|
FreeKeymap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
void Trans::InsertException(KmodException & exclist, char c,
|
1999-11-15 12:01:38 +00:00
|
|
|
string const & data, bool flag, tex_accent accent)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-12-21 06:10:21 +00:00
|
|
|
keyexc p = new Keyexc;
|
1999-11-15 12:01:38 +00:00
|
|
|
p->next = exclist;
|
|
|
|
p->c = c;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
p->data = data;
|
1999-11-15 12:01:38 +00:00
|
|
|
p->combined = flag;
|
|
|
|
p->accent = accent;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
exclist = p;
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
Keyexc p;
|
|
|
|
p.c = c;
|
|
|
|
p.data = data;
|
|
|
|
p.combined = flag;
|
|
|
|
p.accent = accent;
|
|
|
|
exclist.insert(exclist.begin(), p);
|
|
|
|
// or just
|
|
|
|
// exclist.push_back(p);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
void Trans::FreeException(KmodException & exclist)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-12-16 06:43:25 +00:00
|
|
|
Trans::keyexc p = exclist;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (p) {
|
|
|
|
p = exclist->next;
|
|
|
|
delete exclist;
|
|
|
|
exclist = p;
|
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
exclist.clear();
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Trans::FreeKeymap()
|
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
2000-11-04 10:00:12 +00:00
|
|
|
for (int i = 0; i < 256; ++i)
|
2000-09-14 17:53:12 +00:00
|
|
|
if (!keymap_[i].empty()) {
|
|
|
|
keymap_[i].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-11-04 10:00:12 +00:00
|
|
|
for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
|
1999-09-27 18:44:28 +00:00
|
|
|
if (kmod_list_[i]) {
|
|
|
|
FreeException(kmod_list_[i]->exception_list);
|
|
|
|
delete kmod_list_[i];
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_[i] = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
kmod_list_.clear();
|
|
|
|
keymap_.clear();
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
bool Trans::IsDefined() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return !name_.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const & Trans::GetName() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-30 21:53:29 +00:00
|
|
|
enum kmaptags_ {
|
1999-11-15 12:01:38 +00:00
|
|
|
KCOMB = 1,
|
1999-09-27 18:44:28 +00:00
|
|
|
KMOD,
|
|
|
|
KMAP,
|
|
|
|
KXMOD,
|
|
|
|
K_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
struct keyword_item kmapTags[K_LAST - 1] = {
|
1999-11-15 12:01:38 +00:00
|
|
|
{"\\kcomb", KCOMB },
|
1999-09-27 18:44:28 +00:00
|
|
|
{ "\\kmap", KMAP },
|
|
|
|
{ "\\kmod", KMOD },
|
|
|
|
{ "\\kxmod", KXMOD }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
tex_accent getkeymod(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-07-12 11:11:10 +00:00
|
|
|
#if 0
|
1999-11-15 12:01:38 +00:00
|
|
|
void Trans::AddDeadkey(tex_accent accent, string const & keys,
|
|
|
|
string const & allowed)
|
2001-07-12 11:11:10 +00:00
|
|
|
#else
|
|
|
|
void Trans::AddDeadkey(tex_accent accent, string const & keys)
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
if (kmod_list_[accent]) {
|
|
|
|
FreeException(kmod_list_[accent]->exception_list);
|
|
|
|
|
|
|
|
delete kmod_list_[accent];
|
|
|
|
}
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
kmod_list_[accent] = new KmodInfo;
|
1999-09-27 18:44:28 +00:00
|
|
|
kmod_list_[accent]->data = keys;
|
|
|
|
kmod_list_[accent]->accent = accent;
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
KmodInfo tmp;
|
|
|
|
tmp.data = keys;
|
|
|
|
tmp.accent = accent;
|
|
|
|
kmod_list_[accent] = tmp;
|
|
|
|
#endif
|
2001-06-28 10:25:20 +00:00
|
|
|
#if 0
|
2000-07-18 11:06:04 +00:00
|
|
|
if (allowed == "native") {
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_[accent]->allowed= lyx_accent_table[accent].native;
|
2001-06-28 10:25:20 +00:00
|
|
|
} else {
|
1999-09-27 18:44:28 +00:00
|
|
|
kmod_list_[accent]->allowed = allowed;
|
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
for (string::size_type i = 0; i < keys.length(); ++i) {
|
2000-10-30 21:53:29 +00:00
|
|
|
string & temp =
|
|
|
|
keymap_[static_cast<unsigned char>(keys[i])];
|
2000-11-02 04:48:34 +00:00
|
|
|
if (!temp.empty())
|
|
|
|
temp.erase();
|
|
|
|
|
|
|
|
// But the question remains: "Should we be allowed
|
|
|
|
// to change bindings, without unbinding first?"
|
|
|
|
// Lgb
|
|
|
|
temp += char(0);
|
|
|
|
temp += char(accent);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
for (string::size_type i = 0; i < keys.length(); ++i) {
|
|
|
|
string tmp;
|
|
|
|
tmp += char(0);
|
|
|
|
tmp += char(accent);
|
|
|
|
keymap_[keys[i]] = tmp;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if 0
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_[accent]->exception_list = 0;
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-09 22:02:19 +00:00
|
|
|
int Trans::Load(LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
bool error = false;
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
while (lex.isOK() && !error) {
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (lex.lex()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
case KMOD:
|
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "KMOD:\t" << lex.text() << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lex.next(true)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "key\t`" << lex.text()
|
|
|
|
<< "'" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
string const keys = lex.getString();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (lex.next(true)) {
|
2000-11-04 10:00:12 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr << "accent\t`" << lex.text()
|
|
|
|
<< "'" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
tex_accent accent = getkeymod(lex.getString());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
if (accent == TEX_NOACCENT)
|
1999-09-27 18:44:28 +00:00
|
|
|
return -1;
|
|
|
|
|
2001-07-12 11:11:10 +00:00
|
|
|
#if 1
|
2001-09-09 22:02:19 +00:00
|
|
|
//#warning This code should be removed...
|
2001-07-12 11:11:10 +00:00
|
|
|
// But we need to fix up all the kmap files first
|
|
|
|
// so that this field is not present anymore.
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lex.next(true)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "allowed\t`" << lex.text()
|
|
|
|
<< "'" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
string const allowed = lex.getString();
|
2001-07-12 11:11:10 +00:00
|
|
|
AddDeadkey(accent, keys /*, allowed*/);
|
|
|
|
#else
|
|
|
|
AddDeadkey(accent, keys);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KCOMB: {
|
2000-09-14 17:53:12 +00:00
|
|
|
string str;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KBMAP] << "KCOMB:" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lex.next(true)) {
|
1999-11-15 12:01:38 +00:00
|
|
|
str= lex.text();
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KBMAP] << str << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
tex_accent accent_1 = getkeymod(str);
|
1999-11-15 12:01:38 +00:00
|
|
|
if (accent_1 == TEX_NOACCENT) return -1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (lex.next(true)) {
|
1999-12-13 00:05:34 +00:00
|
|
|
str = lex.text();
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KBMAP] << str << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
tex_accent accent_2= getkeymod(str);
|
|
|
|
if (accent_2 == TEX_NOACCENT) return -1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-12-16 06:43:25 +00:00
|
|
|
if (kmod_list_[accent_1] == 0
|
|
|
|
|| kmod_list_[accent_2] == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
return -1;
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
std::map<int, KmodInfo>::iterator it1 =
|
|
|
|
kmod_list_.find(accent_1);
|
|
|
|
std::map<int, KmodInfo>::iterator it2 =
|
|
|
|
kmod_list_.find(accent_2);
|
|
|
|
if (it1 == kmod_list_.end()
|
|
|
|
|| it2 == kmod_list_.end()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
// Find what key accent_2 is on - should
|
|
|
|
// check about accent_1 also
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-12-13 00:05:34 +00:00
|
|
|
int key = 0;
|
2000-11-04 10:00:12 +00:00
|
|
|
for (; key < 256; ++key) {
|
2000-09-14 17:53:12 +00:00
|
|
|
if (!keymap_[key].empty()
|
|
|
|
&& keymap_[key][0] == 0
|
1999-11-15 12:01:38 +00:00
|
|
|
&& keymap_[key][1] == accent_2)
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
string allowed;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (lex.next()) {
|
1999-11-15 12:01:38 +00:00
|
|
|
allowed = lex.GetString();
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KBMAP] << "allowed: "
|
|
|
|
<< allowed << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
InsertException(kmod_list_[accent_1].exception_list,
|
1999-12-13 00:05:34 +00:00
|
|
|
static_cast<char>(key), allowed,
|
|
|
|
true, accent_2);
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
std::map<int, string>::iterator it = keymap_.begin();
|
|
|
|
std::map<int, string>::iterator end = keymap_.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
if (!it->second.empty()
|
|
|
|
&& it->second[0] == 0
|
|
|
|
&& it->second[1] == accent_2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string allowed;
|
|
|
|
if (lex.next()) {
|
2001-08-06 19:12:46 +00:00
|
|
|
allowed = lex.getString();
|
2001-07-16 15:42:57 +00:00
|
|
|
lyxerr[Debug::KBMAP] << "allowed: "
|
|
|
|
<< allowed << endl;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
InsertException(kmod_list_[accent_1].exception_list,
|
|
|
|
static_cast<char>(it->first), allowed,
|
|
|
|
true, accent_2);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KMAP: {
|
1999-12-10 00:07:59 +00:00
|
|
|
unsigned char key_from;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "KMAP:\t" << lex.text() << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lex.next(true)) {
|
1999-12-21 06:10:21 +00:00
|
|
|
key_from = lex.text()[0];
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "\t`" << lex.text() << "'"
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (lex.next(true)) {
|
2000-09-14 17:53:12 +00:00
|
|
|
string string_to = lex.text();
|
1999-11-15 12:01:38 +00:00
|
|
|
keymap_[key_from] = string_to;
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "\t`" << string_to << "'"
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KXMOD: {
|
|
|
|
tex_accent accent;
|
|
|
|
char key;
|
2000-09-14 17:53:12 +00:00
|
|
|
string str;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "KXMOD:\t" << lex.text() << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lex.next(true)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "\t`" << lex.text() << "'"
|
|
|
|
<< endl;
|
2001-08-06 19:12:46 +00:00
|
|
|
accent = getkeymod(lex.getString());
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (lex.next(true)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "\t`" << lex.text() << "'"
|
|
|
|
<< endl;
|
1999-11-15 12:01:38 +00:00
|
|
|
key = lex.text()[0];
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (lex.next(true)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "\t`" << lex.text() << "'"
|
|
|
|
<< endl;
|
1999-11-15 12:01:38 +00:00
|
|
|
str = lex.text();
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
InsertException(kmod_list_[accent].exception_list,
|
1999-12-16 06:43:25 +00:00
|
|
|
key, str);
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LyXLex::LEX_FEOF:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::PARSER] << "End of parsing" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lex.printError("ParseKeymapFile: "
|
|
|
|
"Unknown tag: `$$Token'");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
2000-09-14 17:53:12 +00:00
|
|
|
if (kmod_list_[accent] != 0) {
|
1999-11-15 12:01:38 +00:00
|
|
|
i = *kmod_list_[accent];
|
1999-09-27 18:44:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
std::map<int, KmodInfo>::const_iterator cit = kmod_list_.find(accent);
|
|
|
|
if (cit != kmod_list_.end()) {
|
|
|
|
i = cit->second;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-07 17:52:03 +00:00
|
|
|
#if 0
|
2000-09-14 17:53:12 +00:00
|
|
|
string const Trans::process(char c, TransManager & k)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-06-04 23:57:32 +00:00
|
|
|
string dt("?");
|
2000-09-14 17:53:12 +00:00
|
|
|
string const t = Match(static_cast<unsigned char>(c));
|
|
|
|
|
|
|
|
if (t.empty() && c != 0) {
|
|
|
|
dt[0] = c;
|
|
|
|
return k.normalkey(c, dt);
|
2001-01-23 23:20:27 +00:00
|
|
|
} else if (!t.empty() && t[0] != char(0)) {
|
2000-09-14 17:53:12 +00:00
|
|
|
dt = t;
|
1999-11-15 12:01:38 +00:00
|
|
|
return k.normalkey(c, dt);
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
1999-12-16 06:43:25 +00:00
|
|
|
return k.deadkey(c,
|
|
|
|
*kmod_list_[static_cast<tex_accent>(t[1])]);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-07 17:52:03 +00:00
|
|
|
#else
|
|
|
|
string const Trans::process(char c, TransManager & k)
|
|
|
|
{
|
|
|
|
string const t = Match(static_cast<unsigned char>(c));
|
|
|
|
|
|
|
|
if (t.empty() && c != 0) {
|
|
|
|
return k.normalkey(c);
|
|
|
|
} else if (!t.empty() && t[0] != char(0)) {
|
2001-07-16 15:42:57 +00:00
|
|
|
//return k.normalkey(c);
|
|
|
|
return t;
|
2001-07-07 17:52:03 +00:00
|
|
|
} else {
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
2001-07-07 17:52:03 +00:00
|
|
|
return k.deadkey(c,
|
|
|
|
*kmod_list_[static_cast<tex_accent>(t[1])]);
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
return k.deadkey(c,
|
|
|
|
kmod_list_[static_cast<tex_accent>(t[1])]);
|
|
|
|
#endif
|
2001-07-07 17:52:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
int Trans::Load(string const & language)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-12-29 12:48:02 +00:00
|
|
|
string const filename = LibFileSearch("kbd", language, "kmap");
|
1999-09-27 18:44:28 +00:00
|
|
|
if (filename.empty())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
FreeKeymap();
|
|
|
|
LyXLex lex(kmapTags, K_LAST-1);
|
|
|
|
lex.setFile(filename);
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
int const res = Load(lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
if (res == 0) {
|
|
|
|
name_ = language;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
2000-05-04 10:57:00 +00:00
|
|
|
name_.erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
tex_accent getkeymod(string const & p)
|
1999-09-27 18:44:28 +00:00
|
|
|
/* return modifier - decoded from p and update p */
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
for (int i = 1; i <= TEX_MAX_ACCENT; ++i) {
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KBMAP))
|
|
|
|
lyxerr << "p = " << p
|
|
|
|
<< ", lyx_accent_table[" << i
|
1999-11-15 12:01:38 +00:00
|
|
|
<< "].name = `" << lyx_accent_table[i].name
|
1999-10-07 18:44:17 +00:00
|
|
|
<< "'" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (lyx_accent_table[i].name
|
1999-12-16 06:43:25 +00:00
|
|
|
&& contains(p, lyx_accent_table[i].name)) {
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KBMAP] << "Found it!" << endl;
|
1999-12-13 00:05:34 +00:00
|
|
|
return static_cast<tex_accent>(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TEX_NOACCENT;
|
|
|
|
}
|