2002-06-12 03:16:41 +00:00
|
|
|
|
/**
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \file intl.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-16 12:08:14 +00:00
|
|
|
|
*
|
2002-06-12 03:16:41 +00:00
|
|
|
|
* \author unknown
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void Intl::keyMapOn(bool on)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
keymapon = on;
|
|
|
|
|
|
|
|
|
|
if (on) {
|
2001-03-16 12:08:14 +00:00
|
|
|
|
if (keymap == PRIMARY)
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapPrim();
|
2001-03-16 12:08:14 +00:00
|
|
|
|
else
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapSec();
|
2001-03-16 12:08:14 +00:00
|
|
|
|
} else
|
2006-04-09 00:26:19 +00:00
|
|
|
|
trans.disableKeymap();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void Intl::toggleKeyMap()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-03-16 12:08:14 +00:00
|
|
|
|
if (keymapon && (keymap == PRIMARY)) {
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapSec();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else if (keymapon) {
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapOn(false);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
} else
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapPrim();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void Intl::keyMapPrim()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (!trans.setPrimary(prim_lang))
|
|
|
|
|
trans.enablePrimary();
|
2001-03-16 12:08:14 +00:00
|
|
|
|
|
|
|
|
|
keymapon = true;
|
|
|
|
|
keymap = PRIMARY;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void Intl::keyMapSec()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (!trans.setSecondary(sec_lang))
|
|
|
|
|
trans.enableSecondary();
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
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
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void Intl::initKeyMapper(bool on)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
|
lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-05-31 10:34:30 +00:00
|
|
|
|
if (trans.setPrimary(prim_lang) == -1)
|
|
|
|
|
prim_lang.erase();
|
|
|
|
|
if (trans.setSecondary(sec_lang) == -1)
|
|
|
|
|
sec_lang.erase();
|
|
|
|
|
trans.setCharset(lyxrc.font_norm);
|
|
|
|
|
|
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;
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapOn(keymapon);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
|
if (keymapon)
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapPrim();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|