]> git.lyx.org Git - lyx.git/blob - src/intl.C
fix typo that put too many include paths for most people
[lyx.git] / src / intl.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  * ====================================================== */
10
11 /*
12  *      International support for LyX
13  */
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "intl.h"
22 #include "debug.h"
23 #include "lyxrc.h"
24
25 #include "support/lstrings.h"
26 #include "language.h"
27
28 using std::endl;
29
30
31 Intl::Intl()
32         : keymap(Intl::PRIMARY), keymapon(lyxrc.use_kbmap),
33         prim_lang(lyxrc.primary_kbmap), sec_lang(lyxrc.secondary_kbmap)
34 {
35 }
36
37
38 void Intl::KeyMapOn(bool on)
39 {
40         keymapon = on;
41
42         if (on) {
43                 if (keymap == PRIMARY)
44                         KeyMapPrim();
45                 else
46                         KeyMapSec();
47         } else
48                 trans.DisableKeymap();
49 }
50
51
52 void Intl::ToggleKeyMap()
53 {
54         if (keymapon && (keymap == PRIMARY)) {
55                 KeyMapSec();
56         } else if (keymapon) {
57                 KeyMapOn(false);
58         } else
59                 KeyMapPrim();
60 }
61
62
63 void Intl::KeyMapPrim()
64 {
65         if (!trans.SetPrimary(prim_lang))
66                 trans.EnablePrimary();
67
68         keymapon = true;
69         keymap = PRIMARY;
70 }
71
72
73 void Intl::KeyMapSec()
74 {
75         if (!trans.SetSecondary(sec_lang))
76                 trans.EnableSecondary();
77
78         keymapon = true;
79         keymap = SECONDARY;
80 }
81
82
83 void Intl::InitKeyMapper(bool on)
84 {
85         lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
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         trans.SetPrimary(prim_lang);
98         trans.SetSecondary(sec_lang);
99         trans.setCharset(lyxrc.font_norm);
100 }