3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
6 * \author Asger and Juergen
12 #pragma implementation
15 #include "XLyXKeySym.h"
20 #include <X11/keysym.h>
24 XLyXKeySym::XLyXKeySym()
25 : LyXKeySym(), keysym(NoSymbol)
29 void XLyXKeySym::initFromKeySym(KeySym ks)
34 void XLyXKeySym::init(string const & symbolname)
36 keysym = XStringToKeysym(symbolname.c_str());
37 if (keysym == NoSymbol) {
39 << "XLyXKeySym.C: No such keysym: "
40 << symbolname << endl;
44 bool XLyXKeySym::isOK() const
46 return keysym != NoSymbol;
49 bool XLyXKeySym::isModifier() const
51 // Can we be sure that this will work for all X Window
52 // implementations? (Lgb)
53 // Perhaps all of them should be explictly mentioned?
54 return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
55 || keysym == XK_Mode_switch || keysym == 0x0);
59 XLyXKeySym::getSymbolName() const
61 char * name = XKeysymToString(keysym);
62 return name ? name : string();
66 XLyXKeySym::getISOEncoded() const
68 if (keysym == NoSymbol) {
72 unsigned int c = keysym;
74 switch (c & 0x0000FF00) {
76 case 0x00000000: break;
87 // latin 8 byte 3 = 18 (0x12)
89 // latin 9 byte 3 = 19 (0x13)
99 bool XLyXKeySym::operator==(LyXKeySym const & k) const
101 // This is dangerous! Ideally, we should use dynamic_cast instead,
102 // but on the other hand, we are sure that we will always get
103 // the right type, because we decide at compile time which
104 // frontend we use. (Asger)
105 return keysym == static_cast<XLyXKeySym const &>(k).keysym;