]> git.lyx.org Git - lyx.git/blobdiff - src/kbsequence.C
add missing typename
[lyx.git] / src / kbsequence.C
index 0933d0b1bf1011ae52aab6adde43f47af831a422..fa93e556b7789fd748adfe51819bc1ec2e762d7e 100644 (file)
@@ -2,7 +2,7 @@
  * ======================================================
  *
  *           LyX, The Document Processor
- *     
+ *
  *           Copyright 1995 Matthias Ettrich
  *           Copyright 1995-2001 The LyX Team.
  *
 
 #include "kbsequence.h"
 #include "kbmap.h"
+#include "commandtags.h"
 #include "debug.h"
 
+
+using std::vector;
 using std::endl;
+using std::hex;
+using std::dec;
+
 
 // The only modifiers that we handle. We want to throw away things
 // like NumLock.
 enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
 
 
-kb_action kb_sequence::addkey(unsigned int key, unsigned int mod)
+int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
 {
        // adding a key to a deleted sequence
        // starts a new sequence
@@ -40,14 +46,14 @@ kb_action kb_sequence::addkey(unsigned int key, unsigned int mod)
                modifiers.clear();
        }
 
-       modifiers.push_back(mod);
+       modifiers.push_back(mod + (nmod << 16));
        sequence.push_back(key);
        ++length_;
 
        if (curmap) {
                return curmap->lookup(key, mod, this);
        }
-       
+
        return LFUN_UNKNOWN_ACTION;
 }
 
@@ -58,12 +64,13 @@ string::size_type kb_sequence::parse(string const & s)
 
        string::size_type i = 0;
        unsigned int mod = 0;
+       unsigned int nmod = 0;
        while (i < s.length()) {
                if (s[i] == ' ')
                        ++i;
                if (i >= s.length())
                        break;
-               
+
                if (i + 1 < s.length() && s[i + 1] == '-') {
                        switch (s[i]) {
                        case 's': case 'S':
@@ -85,12 +92,15 @@ string::size_type kb_sequence::parse(string const & s)
                           && s[i + 2] == '-') {
                        switch (s[i + 1]) {
                        case 's': case 'S':
+                               nmod |= ShiftMask;
                                i += 3;
                                continue;
                        case 'c': case 'C':
+                               nmod |= ControlMask;
                                i += 3;
                                continue;
                        case 'm': case 'M':
+                               nmod |= Mod1Mask;
                                i += 3;
                                continue;
                        default:
@@ -101,7 +111,7 @@ string::size_type kb_sequence::parse(string const & s)
                        string::size_type j = i;
                        for (; j < s.length() && s[j] != ' '; ++j)
                                tbuf += s[j];    // (!!!check bounds :-)
-                       
+
                        KeySym key = XStringToKeysym(tbuf.c_str());
                        if (key == NoSymbol) {
                                lyxerr[Debug::KBMAP]
@@ -110,12 +120,12 @@ string::size_type kb_sequence::parse(string const & s)
                                return j;
                        }
                        i = j;
-                       
-                       addkey(key, mod);
+
+                       addkey(key, mod, nmod);
                        mod = 0;
                }
        }
-       
+
        // empty sequence?
        if (!length_)
                return 0;
@@ -129,10 +139,10 @@ string const kb_sequence::print() const
 {
        string buf;
 
-       if (deleted_)
-               return buf;
-       
-       for (std::vector<unsigned int>::size_type i = 0; i < length_; ++i) {
+       //if (deleted_)
+       //      return buf;
+
+       for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
                buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
 
                // append a blank
@@ -149,7 +159,7 @@ string const kb_sequence::printOptions() const
        string buf;
 
        buf += print();
-       
+
        if (!curmap)
                return buf;
 
@@ -177,9 +187,9 @@ char kb_sequence::getiso() const
        unsigned int const c = getsym();
 
        lyxerr[Debug::KBMAP] << "Raw keysym: "
-                            << std::hex << c << std::dec << endl;
+                            << hex << c << dec << endl;
        lyxerr[Debug::KBMAP] << "byte 3: "
-                            << std::hex << (c & 0xff00) << std::dec
+                            << hex << (c & 0xff00) << dec
                             << endl;
        return kb_keymap::getiso(c);
 }