]> git.lyx.org Git - lyx.git/blob - src/Intl.cpp
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / Intl.cpp
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 "LyXRC.h"
18
19 #include "support/debug.h"
20
21 namespace lyx {
22
23
24 Intl::Intl()
25         : keymap(Intl::PRIMARY), keymapon(lyxrc.use_kbmap),
26         prim_lang(lyxrc.primary_kbmap), sec_lang(lyxrc.secondary_kbmap)
27 {
28 }
29
30
31 void Intl::keyMapOn(bool on)
32 {
33         keymapon = on;
34
35         if (on) {
36                 if (keymap == PRIMARY)
37                         keyMapPrim();
38                 else
39                         keyMapSec();
40         } else {
41                 trans.disableKeymap();
42         }
43 }
44
45
46 void Intl::toggleKeyMap()
47 {
48         if (keymapon && (keymap == PRIMARY))
49                 keyMapSec();
50         else if (keymapon)
51                 keyMapOn(false);
52         else
53                 keyMapPrim();
54 }
55
56
57 void Intl::keyMapPrim()
58 {
59         if (!trans.setPrimary(prim_lang))
60                 trans.enablePrimary();
61
62         keymapon = true;
63         keymap = PRIMARY;
64 }
65
66
67 void Intl::keyMapSec()
68 {
69         if (!trans.setSecondary(sec_lang))
70                 trans.enableSecondary();
71
72         keymapon = true;
73         keymap = SECONDARY;
74 }
75
76
77 void Intl::initKeyMapper(bool on)
78 {
79         LYXERR(Debug::INIT, "Initializing key mappings...");
80
81         if (trans.setPrimary(prim_lang) == -1)
82                 prim_lang.erase();
83         if (trans.setSecondary(sec_lang) == -1)
84                 sec_lang.erase();
85
86         if (prim_lang.empty() && sec_lang.empty())
87                 keymapon = false;
88         else
89                 keymapon = on;
90
91         keyMapOn(keymapon);
92
93         if (keymapon)
94                 keyMapPrim();
95 }
96
97
98 } // namespace lyx