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