]> git.lyx.org Git - lyx.git/blobdiff - src/kbsequence.C
write \mathrm{x}\mathrm{y} as \mathrm{xy} again
[lyx.git] / src / kbsequence.C
index 9289bf60a208497db25abf468eafb1a3f509694b..89ce116ad604053386dfd154d62fcad6a8e46344 100644 (file)
@@ -4,12 +4,12 @@
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  * ====================================================== */
 
 #include <config.h>
-#include <cstring>
+//#include <cstring>
 #include <X11/Xlib.h>
 
 #include "gettext.h"
@@ -93,7 +93,7 @@ int kb_sequence::addkey(unsigned int key,
                 Prefixes are S-, C-, M- for shift, control, meta
 \* ---F------------------------------------------------------------------- */
 
-int kb_sequence::parse(string const & s)
+string::size_type kb_sequence::parse(string const & s)
 {
        if (s.empty()) return 1;
 
@@ -103,7 +103,7 @@ int kb_sequence::parse(string const & s)
                if (s[i] && (s[i]) <= ' ') ++i;
                if (i >= s.length()) break;
                
-               if (s[i + 1] == '-')    { // is implicit that s[i] == true
+               if (i + 1 < s.length() && s[i + 1] == '-')      {
                        switch (s[i]) {
                        case 's': case 'S':
                                mod |= ShiftMask;
@@ -120,7 +120,8 @@ int kb_sequence::parse(string const & s)
                        default:
                                return i + 1;
                        }
-               } else if (s[i] == '~' && s[i + 1] && s[i + 2] == '-') {
+               } else if (i + 2 < s.length() && s[i] == '~'
+                          && s[i + 2] == '-') {
                        switch (s[i + 1]) {
                        case 's': case 'S':
                                nmod |= ShiftMask;
@@ -260,11 +261,36 @@ unsigned int kb_sequence::getsym() const
 
 char kb_sequence::getiso() const
 {
-       int const c = getsym();
+       unsigned int const c = getsym();
+
+       lyxerr[Debug::KBMAP] << "Raw keysym: "
+                            << std::hex << c << std::dec << endl;
+       lyxerr[Debug::KBMAP] << "byte 3: "
+                            << std::hex << (c & 0x0000FF00) << std::dec
+                            << endl;
        
-       if (c > 0xff)
+       switch (c & 0x0000FF00) {
+               // latin 1 byte 3 = 0
+       case 0x00000000:
+               return c;
+               // latin 2 byte 3 = 1
+       case 0x00000100:
+               // latin 3 byte 3 = 2
+       case 0x00000200:
+               // latin 4 byte 3 = 3
+       case 0x00000300:
+               // latin 8 byte 3 = 18 (0x12)
+       case 0x00001200:
+               // latin 9 byte 3 = 19 (0x13)
+       case 0x00001300:
+               return c & 0x000000FF;
+       default:
                return '\0';
-       return c;
+       }
+
+       // not a latin char we know of
+       // Yes but this is already handled above (JMarc)
+       //return '\0';
 }