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"
18 #include <X11/keysym.h>
24 XLyXKeySym::XLyXKeySym()
25 : LyXKeySym(), keysym_(NoSymbol)
30 void XLyXKeySym::initFromKeySym(KeySym ks)
36 void XLyXKeySym::init(string const & symbolname)
38 keysym_ = XStringToKeysym(symbolname.c_str());
39 if (keysym_ == NoSymbol) {
41 << "XLyXKeySym.C: No such keysym: "
42 << symbolname << endl;
47 bool XLyXKeySym::isOK() const
49 return keysym_ != NoSymbol;
53 bool XLyXKeySym::isModifier() const
55 // Can we be sure that this will work for all X Window
56 // implementations? (Lgb)
57 // Perhaps all of them should be explictly mentioned?
58 return ((keysym_ >= XK_Shift_L && keysym_ <= XK_Hyper_R)
59 || keysym_ == XK_Mode_switch || keysym_ == 0x0);
63 string XLyXKeySym::getSymbolName() const
65 char * name = XKeysymToString(keysym_);
66 return name ? name : string();
70 char XLyXKeySym::getISOEncoded(string const &) const
72 if (keysym_ == NoSymbol) {
76 unsigned int c = keysym_;
78 switch (c & 0x0000FF00) {
80 case 0x00000000: break;
91 // latin 8 byte 3 = 18 (0x12)
93 // latin 9 byte 3 = 19 (0x13)
104 string const XLyXKeySym::print(key_modifier::state mod) const
106 return kb_keymap::printKeySym(*this, mod);
110 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
112 return static_cast<XLyXKeySym const &>(k1).keysym()
113 == static_cast<XLyXKeySym const &>(k2).keysym();