3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger and Jürgen
8 * Full author contact details are available in file CREDITS.
13 #include "XLyXKeySym.h"
17 #include <X11/keysym.h>
23 XLyXKeySym::XLyXKeySym()
24 : LyXKeySym(), keysym_(NoSymbol)
29 void XLyXKeySym::initFromKeySym(KeySym ks)
35 void XLyXKeySym::init(string const & symbolname)
37 keysym_ = XStringToKeysym(symbolname.c_str());
38 if (keysym_ == NoSymbol) {
40 << "XLyXKeySym.C: No such keysym: "
41 << symbolname << endl;
46 bool XLyXKeySym::isOK() const
48 return keysym_ != NoSymbol;
52 bool XLyXKeySym::isModifier() const
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);
62 string XLyXKeySym::getSymbolName() const
64 char * name = XKeysymToString(keysym_);
65 return name ? name : string();
69 char XLyXKeySym::getISOEncoded(string const &) const
71 if (keysym_ == NoSymbol) {
75 unsigned int c = keysym_;
77 switch (c & 0x0000FF00) {
79 case 0x00000000: break;
90 // latin 8 byte 3 = 18 (0x12)
92 // latin 9 byte 3 = 19 (0x13)
103 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
105 return static_cast<XLyXKeySym const &>(k1).keysym()
106 == static_cast<XLyXKeySym const &>(k2).keysym();