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 _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
21 #include "GLyXKeySym.h"
24 #include "support/lstrings.h"
27 #include <gdk/gdkkeysyms.h>
32 GLyXKeySym::GLyXKeySym() : keyval_(GDK_VoidSymbol)
37 GLyXKeySym::GLyXKeySym(unsigned int keyval) : keyval_(keyval)
42 void GLyXKeySym::setKeyval(unsigned int keyval)
48 void GLyXKeySym::init(string const & symbolname)
50 keyval_ = gdk_keyval_from_name(symbolname.c_str());
54 bool GLyXKeySym::isOK() const
56 return keyval_ != GDK_VoidSymbol;
60 bool GLyXKeySym::isModifier() const
62 return ((keyval_ >= GDK_Shift_L && keyval_ <= GDK_Hyper_R)
63 || keyval_ == GDK_Mode_switch || keyval_ == 0);
67 string GLyXKeySym::getSymbolName() const
69 const char * name = gdk_keyval_name(keyval_);
70 return name ? name : string();
74 char GLyXKeySym::getISOEncoded(string const & /*encoding*/) const
76 if (keyval_ == GDK_VoidSymbol)
79 unsigned int c = keyval_;
81 switch (c & 0x0000FF00) {
83 case 0x00000000: break;
94 // latin 8 byte 3 = 18 (0x12)
96 // latin 9 byte 3 = 19 (0x13)
107 // Produce a human readable version (eg "Ctrl+N")
108 string const GLyXKeySym::print(key_modifier::state mod) const
112 if (mod & key_modifier::ctrl)
114 if (mod & key_modifier::shift)
116 if (mod & key_modifier::alt)
119 // Uppercase the first letter, for Ctrl+N rather than Ctrl+n,
120 // and for Ctrl+Greater rather than Ctrl+GREATER
121 string symname = getSymbolName();
122 if (!symname.empty()) {
123 symname[0] = lyx::support::uppercase(symname[0]);
131 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
133 return static_cast<GLyXKeySym const &>(k1).getKeyval()
134 == static_cast<GLyXKeySym const &>(k2).getKeyval();