1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
2001-03-16 12:08:14 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* LyX, The Document Processor
|
2001-03-16 12:08:14 +00:00
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2000-03-16 04:29:22 +00:00
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* International support for LyX
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
2001-03-16 12:08:14 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "intl.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxrc.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-03-10 13:22:20 +00:00
|
|
|
#include "language.h"
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
Intl::Intl()
|
2001-03-16 12:08:14 +00:00
|
|
|
: keymap(Intl::PRIMARY), keymapon(lyxrc.use_kbmap),
|
|
|
|
prim_lang(lyxrc.primary_kbmap), sec_lang(lyxrc.secondary_kbmap)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Intl::KeyMapOn(bool on)
|
|
|
|
{
|
|
|
|
keymapon = on;
|
|
|
|
|
|
|
|
if (on) {
|
2001-03-16 12:08:14 +00:00
|
|
|
if (keymap == PRIMARY)
|
1999-09-27 18:44:28 +00:00
|
|
|
KeyMapPrim();
|
2001-03-16 12:08:14 +00:00
|
|
|
else
|
1999-09-27 18:44:28 +00:00
|
|
|
KeyMapSec();
|
2001-03-16 12:08:14 +00:00
|
|
|
} else
|
2000-12-29 12:48:02 +00:00
|
|
|
trans.DisableKeymap();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Intl::ToggleKeyMap()
|
|
|
|
{
|
2001-03-16 12:08:14 +00:00
|
|
|
if (keymapon && (keymap == PRIMARY)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
KeyMapSec();
|
|
|
|
} else if (keymapon) {
|
|
|
|
KeyMapOn(false);
|
|
|
|
} else
|
|
|
|
KeyMapPrim();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Intl::KeyMapPrim()
|
|
|
|
{
|
2001-03-16 12:08:14 +00:00
|
|
|
if (!trans.SetPrimary(prim_lang))
|
2000-12-29 12:48:02 +00:00
|
|
|
trans.EnablePrimary();
|
2001-03-16 12:08:14 +00:00
|
|
|
|
|
|
|
keymapon = true;
|
|
|
|
keymap = PRIMARY;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Intl::KeyMapSec()
|
|
|
|
{
|
2001-03-16 12:08:14 +00:00
|
|
|
if (!trans.SetSecondary(sec_lang))
|
2000-12-29 12:48:02 +00:00
|
|
|
trans.EnableSecondary();
|
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
keymapon = true;
|
|
|
|
keymap = SECONDARY;
|
1999-10-25 14:18:30 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void Intl::InitKeyMapper(bool on)
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (prim_lang.empty() && sec_lang.empty())
|
2001-03-16 12:08:14 +00:00
|
|
|
keymapon = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
|
|
|
keymapon = on;
|
|
|
|
|
|
|
|
KeyMapOn(keymapon);
|
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
if (keymapon)
|
|
|
|
KeyMapPrim();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
trans.SetPrimary(prim_lang);
|
|
|
|
trans.SetSecondary(sec_lang);
|
|
|
|
trans.setCharset(lyxrc.font_norm);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|