X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FXLyXKeySym.C;h=a16a7bc6c12e90eb9a66f9851463d79761a17e26;hb=d5443737342903de489d527802cd2cdd38987d74;hp=0398507910288d3ad471570c3bdee55d4500bec7;hpb=f1c24d100985c6df2eb5ec390017b69c78fe49c7;p=lyx.git diff --git a/src/frontends/xforms/XLyXKeySym.C b/src/frontends/xforms/XLyXKeySym.C index 0398507910..a16a7bc6c1 100644 --- a/src/frontends/xforms/XLyXKeySym.C +++ b/src/frontends/xforms/XLyXKeySym.C @@ -1,75 +1,90 @@ /** * \file XLyXKeySym.C - * Copyright 2002 the LyX Team - * Read the file COPYING + * 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. */ #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; } } + bool XLyXKeySym::isOK() const { - return keysym != NoSymbol; + return keysym_ != NoSymbol; } + 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 + +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 @@ -96,11 +111,11 @@ 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