]> git.lyx.org Git - lyx.git/blob - src/intl.C
avoid to update when navigating
[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 using std::endl;
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 void Intl::ToggleKeyMap()
46 {
47         if (keymapon && (keymap == PRIMARY)) {
48                 KeyMapSec();
49         } else if (keymapon) {
50                 KeyMapOn(false);
51         } else
52                 KeyMapPrim();
53 }
54
55
56 void Intl::KeyMapPrim()
57 {
58         if (!trans.SetPrimary(prim_lang))
59                 trans.EnablePrimary();
60
61         keymapon = true;
62         keymap = PRIMARY;
63 }
64
65
66 void Intl::KeyMapSec()
67 {
68         if (!trans.SetSecondary(sec_lang))
69                 trans.EnableSecondary();
70
71         keymapon = true;
72         keymap = SECONDARY;
73 }
74
75
76 void Intl::InitKeyMapper(bool on)
77 {
78         lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
79
80         if (prim_lang.empty() && sec_lang.empty())
81                 keymapon = false;
82         else
83                 keymapon = on;
84
85         KeyMapOn(keymapon);
86
87         if (keymapon)
88                 KeyMapPrim();
89
90         trans.SetPrimary(prim_lang);
91         trans.SetSecondary(sec_lang);
92         trans.setCharset(lyxrc.font_norm);
93 }