2002-06-18 15:44:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file XLyXKeySym.C
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Asger and J<EFBFBD>rgen
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "XLyXKeySym.h"
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2004-03-26 15:12:35 +00:00
|
|
|
|
#include "kbmap.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
|
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
|
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
|
|
|
|
|
{
|
|
|
|
|
using lyx::frontend::XLyXKeySym;
|
|
|
|
|
return static_cast<XLyXKeySym const &>(k1).keysym()
|
|
|
|
|
== static_cast<XLyXKeySym const &>(k2).keysym();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
XLyXKeySym::XLyXKeySym()
|
2002-10-20 01:48:28 +00:00
|
|
|
|
: LyXKeySym(), keysym_(NoSymbol)
|
2002-06-18 15:44:30 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
void XLyXKeySym::initFromKeySym(KeySym ks)
|
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
|
keysym_ = ks;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
void XLyXKeySym::init(string const & symbolname)
|
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
|
keysym_ = XStringToKeysym(symbolname.c_str());
|
|
|
|
|
if (keysym_ == NoSymbol) {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
lyxerr[Debug::KBMAP]
|
|
|
|
|
<< "XLyXKeySym.C: No such keysym: "
|
|
|
|
|
<< symbolname << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-20 00:09:12 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool XLyXKeySym::isOK() const
|
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
|
return keysym_ != NoSymbol;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-20 00:09:12 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool XLyXKeySym::isModifier() const
|
|
|
|
|
{
|
|
|
|
|
// Can we be sure that this will work for all X Window
|
|
|
|
|
// implementations? (Lgb)
|
|
|
|
|
// Perhaps all of them should be explictly mentioned?
|
2002-10-20 01:48:28 +00:00
|
|
|
|
return ((keysym_ >= XK_Shift_L && keysym_ <= XK_Hyper_R)
|
|
|
|
|
|| keysym_ == XK_Mode_switch || keysym_ == 0x0);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-20 00:09:12 +00:00
|
|
|
|
|
|
|
|
|
string XLyXKeySym::getSymbolName() const
|
2002-06-18 15:44:30 +00:00
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
|
char * name = XKeysymToString(keysym_);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
return name ? name : string();
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2003-01-05 22:38:42 +00:00
|
|
|
|
char XLyXKeySym::getISOEncoded(string const &) const
|
2002-06-18 15:44:30 +00:00
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
|
if (keysym_ == NoSymbol) {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
unsigned int c = keysym_;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
switch (c & 0x0000FF00) {
|
|
|
|
|
// latin 1 byte 3 = 0
|
|
|
|
|
case 0x00000000: break;
|
|
|
|
|
// latin 2 byte 3 = 1
|
|
|
|
|
case 0x00000100:
|
|
|
|
|
// latin 3 byte 3 = 2
|
|
|
|
|
case 0x00000200:
|
|
|
|
|
// latin 4 byte 3 = 3
|
|
|
|
|
case 0x00000300:
|
|
|
|
|
// cyrillic KOI8 & Co
|
|
|
|
|
case 0x00000600:
|
|
|
|
|
// greek
|
|
|
|
|
case 0x00000700:
|
|
|
|
|
// latin 8 byte 3 = 18 (0x12)
|
|
|
|
|
case 0x00001200:
|
|
|
|
|
// latin 9 byte 3 = 19 (0x13)
|
|
|
|
|
case 0x00001300:
|
|
|
|
|
c &= 0x000000FF;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
c = 0;
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2004-03-26 15:12:35 +00:00
|
|
|
|
string const XLyXKeySym::print(key_modifier::state mod) const
|
|
|
|
|
{
|
|
|
|
|
return kb_keymap::printKeySym(*this, mod);
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|