]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XLyXKeySym.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / XLyXKeySym.C
1 /**
2  * \file XLyXKeySym.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Asger and Juergen
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "XLyXKeySym.h"
15
16 #include "debug.h"
17
18 #include <X11/Xlib.h>
19 #include <X11/keysym.h>
20
21 using std::endl;
22
23 XLyXKeySym::XLyXKeySym()
24         : LyXKeySym(), keysym_(NoSymbol)
25 {
26 }
27
28
29 void XLyXKeySym::initFromKeySym(KeySym ks)
30 {
31         keysym_ = ks;
32 }
33
34
35 void XLyXKeySym::init(string const & symbolname)
36 {
37         keysym_ = XStringToKeysym(symbolname.c_str());
38         if (keysym_ == NoSymbol) {
39                 lyxerr[Debug::KBMAP]
40                         << "XLyXKeySym.C: No such keysym: "
41                         << symbolname << endl;
42         }
43 }
44
45
46 bool XLyXKeySym::isOK() const
47 {
48         return keysym_ != NoSymbol;
49 }
50
51
52 bool XLyXKeySym::isModifier() const
53 {
54         // Can we be sure that this will work for all X Window
55         // implementations? (Lgb)
56         // Perhaps all of them should be explictly mentioned?
57         return ((keysym_ >= XK_Shift_L && keysym_ <= XK_Hyper_R)
58             || keysym_ == XK_Mode_switch || keysym_ == 0x0);
59 }
60
61
62 string XLyXKeySym::getSymbolName() const
63 {
64         char * name = XKeysymToString(keysym_);
65         return name ? name : string();
66 }
67
68
69 char XLyXKeySym::getISOEncoded(string const &) const
70 {
71         if (keysym_ == NoSymbol) {
72                 return 0;
73         }
74
75         unsigned int c = keysym_;
76
77         switch (c & 0x0000FF00) {
78                 // latin 1 byte 3 = 0
79         case 0x00000000: break;
80                 // latin 2 byte 3 = 1
81         case 0x00000100:
82                 // latin 3 byte 3 = 2
83         case 0x00000200:
84                 // latin 4 byte 3 = 3
85         case 0x00000300:
86                 // cyrillic KOI8 & Co
87         case 0x00000600:
88                 // greek
89         case 0x00000700:
90                 // latin 8 byte 3 = 18 (0x12)
91         case 0x00001200:
92                 // latin 9 byte 3 = 19 (0x13)
93         case 0x00001300:
94                 c &= 0x000000FF;
95                 break;
96         default:
97                 c = 0;
98         }
99         return c;
100 }
101
102
103 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
104 {
105         return static_cast<XLyXKeySym const &>(k1).keysym()
106                 == static_cast<XLyXKeySym const &>(k2).keysym();
107 }