3 * Read the file COPYING
5 * \author Asger and Juergen
7 * Full author contact details are available in file CREDITS
13 #pragma implementation
16 #include "XLyXKeySym.h"
21 #include <X11/keysym.h>
25 XLyXKeySym::XLyXKeySym()
26 : LyXKeySym(), keysym(NoSymbol)
31 void XLyXKeySym::initFromKeySym(KeySym ks)
37 void XLyXKeySym::init(string const & symbolname)
39 keysym = XStringToKeysym(symbolname.c_str());
40 if (keysym == NoSymbol) {
42 << "XLyXKeySym.C: No such keysym: "
43 << symbolname << endl;
48 bool XLyXKeySym::isOK() const
50 return keysym != NoSymbol;
54 bool XLyXKeySym::isModifier() const
56 // Can we be sure that this will work for all X Window
57 // implementations? (Lgb)
58 // Perhaps all of them should be explictly mentioned?
59 return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
60 || keysym == XK_Mode_switch || keysym == 0x0);
64 string XLyXKeySym::getSymbolName() const
66 char * name = XKeysymToString(keysym);
67 return name ? name : string();
71 char XLyXKeySym::getISOEncoded() const
73 if (keysym == NoSymbol) {
77 unsigned int c = keysym;
79 switch (c & 0x0000FF00) {
81 case 0x00000000: break;
92 // latin 8 byte 3 = 18 (0x12)
94 // latin 9 byte 3 = 19 (0x13)
105 bool XLyXKeySym::operator==(LyXKeySym const & k) const
107 // This is dangerous! Ideally, we should use dynamic_cast instead,
108 // but on the other hand, we are sure that we will always get
109 // the right type, because we decide at compile time which
110 // frontend we use. (Asger)
111 return keysym == static_cast<XLyXKeySym const &>(k).keysym;