3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger and Juergen
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "XLyXKeySym.h"
22 #include <X11/keysym.h>
26 XLyXKeySym::XLyXKeySym()
27 : LyXKeySym(), keysym(NoSymbol)
32 void XLyXKeySym::initFromKeySym(KeySym ks)
38 void XLyXKeySym::init(string const & symbolname)
40 keysym = XStringToKeysym(symbolname.c_str());
41 if (keysym == NoSymbol) {
43 << "XLyXKeySym.C: No such keysym: "
44 << symbolname << endl;
49 bool XLyXKeySym::isOK() const
51 return keysym != NoSymbol;
55 bool XLyXKeySym::isModifier() const
57 // Can we be sure that this will work for all X Window
58 // implementations? (Lgb)
59 // Perhaps all of them should be explictly mentioned?
60 return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
61 || keysym == XK_Mode_switch || keysym == 0x0);
65 string XLyXKeySym::getSymbolName() const
67 char * name = XKeysymToString(keysym);
68 return name ? name : string();
72 char XLyXKeySym::getISOEncoded() const
74 if (keysym == NoSymbol) {
78 unsigned int c = keysym;
80 switch (c & 0x0000FF00) {
82 case 0x00000000: break;
93 // latin 8 byte 3 = 18 (0x12)
95 // latin 9 byte 3 = 19 (0x13)
106 bool XLyXKeySym::operator==(LyXKeySym const & k) const
108 // This is dangerous! Ideally, we should use dynamic_cast instead,
109 // but on the other hand, we are sure that we will always get
110 // the right type, because we decide at compile time which
111 // frontend we use. (Asger)
112 return keysym == static_cast<XLyXKeySym const &>(k).keysym;