Another minor change, but this should almost get us to the point that we
[lyx.git] / src / Intl.cpp
blobfdae0b1aba144b5bc1471e0749830fba66d0f7ea
1 /**
2 * \file Intl.h
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author unknown
7 * \author Lars Gullik Bjønnes
8 * \author Angus Leeming
9 * \author John Levon
11 * Full author contact details are available in file CREDITS.
14 #include <config.h>
16 #include "Intl.h"
17 #include "LyXRC.h"
19 #include "support/debug.h"
21 namespace lyx {
24 Intl::Intl()
25 : keymap(Intl::PRIMARY), keymapon(lyxrc.use_kbmap),
26 prim_lang(lyxrc.primary_kbmap), sec_lang(lyxrc.secondary_kbmap)
31 void Intl::keyMapOn(bool on)
33 keymapon = on;
35 if (on) {
36 if (keymap == PRIMARY)
37 keyMapPrim();
38 else
39 keyMapSec();
40 } else {
41 trans.disableKeymap();
46 void Intl::toggleKeyMap()
48 if (keymapon && (keymap == PRIMARY))
49 keyMapSec();
50 else if (keymapon)
51 keyMapOn(false);
52 else
53 keyMapPrim();
57 void Intl::keyMapPrim()
59 if (!trans.setPrimary(prim_lang))
60 trans.enablePrimary();
62 keymapon = true;
63 keymap = PRIMARY;
67 void Intl::keyMapSec()
69 if (!trans.setSecondary(sec_lang))
70 trans.enableSecondary();
72 keymapon = true;
73 keymap = SECONDARY;
77 void Intl::initKeyMapper(bool on)
79 LYXERR(Debug::INIT, "Initializing key mappings...");
81 if (trans.setPrimary(prim_lang) == -1)
82 prim_lang.erase();
83 if (trans.setSecondary(sec_lang) == -1)
84 sec_lang.erase();
86 if (prim_lang.empty() && sec_lang.empty())
87 keymapon = false;
88 else
89 keymapon = on;
91 keyMapOn(keymapon);
93 if (keymapon)
94 keyMapPrim();
98 } // namespace lyx