3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
18 #include "GLyXKeySym.h"
21 #include "support/lstrings.h"
24 #include <gdk/gdkkeysyms.h>
29 GLyXKeySym::GLyXKeySym() : keyval_(GDK_VoidSymbol)
34 GLyXKeySym::GLyXKeySym(unsigned int keyval) : keyval_(keyval)
39 void GLyXKeySym::setKeyval(unsigned int keyval)
45 void GLyXKeySym::init(string const & symbolname)
47 keyval_ = gdk_keyval_from_name(symbolname.c_str());
51 bool GLyXKeySym::isOK() const
53 return keyval_ != GDK_VoidSymbol;
57 bool GLyXKeySym::isModifier() const
59 return ((keyval_ >= GDK_Shift_L && keyval_ <= GDK_Hyper_R)
60 || keyval_ == GDK_Mode_switch || keyval_ == 0);
64 string GLyXKeySym::getSymbolName() const
66 const char * name = gdk_keyval_name(keyval_);
67 return name ? name : string();
71 char GLyXKeySym::getISOEncoded(string const & /*encoding*/) const
73 if (keyval_ == GDK_VoidSymbol)
76 unsigned int c = keyval_;
78 switch (c & 0x0000FF00) {
80 case 0x00000000: break;
91 // latin 8 byte 3 = 18 (0x12)
93 // latin 9 byte 3 = 19 (0x13)
104 // Produce a human readable version (eg "Ctrl+N")
105 string const GLyXKeySym::print(key_modifier::state mod) const
109 if (mod & key_modifier::ctrl)
111 if (mod & key_modifier::shift)
113 if (mod & key_modifier::alt)
116 // Uppercase the first letter, for Ctrl+N rather than Ctrl+n,
117 // and for Ctrl+Greater rather than Ctrl+GREATER
118 string symname = getSymbolName();
119 if (!symname.empty()) {
120 symname[0] = lyx::support::uppercase(symname[0]);
128 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
130 return static_cast<GLyXKeySym const &>(k1).getKeyval()
131 == static_cast<GLyXKeySym const &>(k2).getKeyval();