X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FXLyXKeySym.C;h=a16a7bc6c12e90eb9a66f9851463d79761a17e26;hb=d5443737342903de489d527802cd2cdd38987d74;hp=bd1500e4a594944ff5a60a884312d965012e7a51;hpb=1eb8155fa0d2253d9504a8d660cb3d666c1224f6;p=lyx.git diff --git a/src/frontends/xforms/XLyXKeySym.C b/src/frontends/xforms/XLyXKeySym.C index bd1500e4a5..a16a7bc6c1 100644 --- a/src/frontends/xforms/XLyXKeySym.C +++ b/src/frontends/xforms/XLyXKeySym.C @@ -3,42 +3,51 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Asger and Juergen + * \author Asger and Jürgen * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "XLyXKeySym.h" #include "debug.h" +#include "kbmap.h" -#include #include using std::endl; +using std::string; + + +bool operator==(LyXKeySym const & k1, LyXKeySym const & k2) +{ + using lyx::frontend::XLyXKeySym; + return static_cast(k1).keysym() + == static_cast(k2).keysym(); +} + + +namespace lyx { +namespace frontend { XLyXKeySym::XLyXKeySym() - : LyXKeySym(), keysym(NoSymbol) + : LyXKeySym(), keysym_(NoSymbol) { } - + void XLyXKeySym::initFromKeySym(KeySym ks) { - keysym = ks; + keysym_ = ks; } - + void XLyXKeySym::init(string const & symbolname) { - keysym = XStringToKeysym(symbolname.c_str()); - if (keysym == NoSymbol) { + keysym_ = XStringToKeysym(symbolname.c_str()); + if (keysym_ == NoSymbol) { lyxerr[Debug::KBMAP] << "XLyXKeySym.C: No such keysym: " << symbolname << endl; @@ -48,7 +57,7 @@ void XLyXKeySym::init(string const & symbolname) bool XLyXKeySym::isOK() const { - return keysym != NoSymbol; + return keysym_ != NoSymbol; } @@ -57,25 +66,25 @@ 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? - return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R) - || keysym == XK_Mode_switch || keysym == 0x0); + return ((keysym_ >= XK_Shift_L && keysym_ <= XK_Hyper_R) + || keysym_ == XK_Mode_switch || keysym_ == 0x0); } string XLyXKeySym::getSymbolName() const { - char * name = XKeysymToString(keysym); + char * name = XKeysymToString(keysym_); return name ? name : string(); } - -char XLyXKeySym::getISOEncoded() const + +char XLyXKeySym::getISOEncoded(string const &) const { - if (keysym == NoSymbol) { + if (keysym_ == NoSymbol) { return 0; } - unsigned int c = keysym; + unsigned int c = keysym_; switch (c & 0x0000FF00) { // latin 1 byte 3 = 0 @@ -102,12 +111,11 @@ char XLyXKeySym::getISOEncoded() const return c; } - -bool XLyXKeySym::operator==(LyXKeySym const & k) const + +string const XLyXKeySym::print(key_modifier::state mod) const { - // This is dangerous! Ideally, we should use dynamic_cast instead, - // but on the other hand, we are sure that we will always get - // the right type, because we decide at compile time which - // frontend we use. (Asger) - return keysym == static_cast(k).keysym; + return kb_keymap::printKeySym(*this, mod); } + +} // namespace frontend +} // namespace lyx