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 operator==(LyXKeySym const & k1, LyXKeySym const & k2)
108 return static_cast<XLyXKeySym const &>(k1).keysym()
109 == static_cast<XLyXKeySym const &>(k2).keysym();