]> git.lyx.org Git - lyx.git/blob - src/intl.C
* src/tabular.[Ch]: simplify plaintext methods, because there
[lyx.git] / src / intl.C
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.
5  *
6  * \author unknown
7  * \author Lars Gullik Bjønnes
8  * \author Angus Leeming
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "intl.h"
17 #include "debug.h"
18 #include "lyxrc.h"
19
20
21 namespace lyx {
22
23
24 using std::endl;
25
26
27 Intl::Intl()
28         : keymap(Intl::PRIMARY), keymapon(lyxrc.use_kbmap),
29         prim_lang(lyxrc.primary_kbmap), sec_lang(lyxrc.secondary_kbmap)
30 {
31 }
32
33
34 void Intl::keyMapOn(bool on)
35 {
36         keymapon = on;
37
38         if (on) {
39                 if (keymap == PRIMARY)
40                         keyMapPrim();
41                 else
42                         keyMapSec();
43         } else
44                 trans.disableKeymap();
45 }
46
47
48 void Intl::toggleKeyMap()
49 {
50         if (keymapon && (keymap == PRIMARY)) {
51                 keyMapSec();
52         } else if (keymapon) {
53                 keyMapOn(false);
54         } else
55                 keyMapPrim();
56 }
57
58
59 void Intl::keyMapPrim()
60 {
61         if (!trans.setPrimary(prim_lang))
62                 trans.enablePrimary();
63
64         keymapon = true;
65         keymap = PRIMARY;
66 }
67
68
69 void Intl::keyMapSec()
70 {
71         if (!trans.setSecondary(sec_lang))
72                 trans.enableSecondary();
73
74         keymapon = true;
75         keymap = SECONDARY;
76 }
77
78
79 void Intl::initKeyMapper(bool on)
80 {
81         lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
82
83         if (trans.setPrimary(prim_lang) == -1)
84                 prim_lang.erase();
85         if (trans.setSecondary(sec_lang) == -1)
86                 sec_lang.erase();
87         trans.setCharset(lyxrc.font_norm);
88
89         if (prim_lang.empty() && sec_lang.empty())
90                 keymapon = false;
91         else
92                 keymapon = on;
93
94         keyMapOn(keymapon);
95
96         if (keymapon)
97                 keyMapPrim();
98 }
99
100
101 } // namespace lyx