2002-06-12 03:16:41 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file Intl.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Intl.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
|
namespace lyx {
|
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();
|
2007-11-28 22:12:03 +00:00
|
|
|
|
} else {
|
2006-04-09 00:26:19 +00:00
|
|
|
|
trans.disableKeymap();
|
2007-11-28 22:12:03 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2007-11-28 22:12:03 +00:00
|
|
|
|
if (keymapon && (keymap == PRIMARY))
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapSec();
|
2007-11-28 22:12:03 +00:00
|
|
|
|
else if (keymapon)
|
2006-04-09 00:26:19 +00:00
|
|
|
|
keyMapOn(false);
|
2007-11-28 22:12:03 +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
|
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::INIT, "Initializing key mappings...");
|
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();
|
|
|
|
|
|
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
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|