-/* This file is part of
- * ======================================================
+/**
+ * \file kbsequence.C
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
*
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
#include <config.h>
-//#include <cstring>
-#include <X11/Xlib.h>
#include "gettext.h"
#pragma implementation
#endif
+#include "frontends/mouse_state.h"
#include "kbsequence.h"
#include "kbmap.h"
#include "commandtags.h"
#include "debug.h"
+#include <X11/Xlib.h>
+using std::make_pair;
using std::vector;
using std::endl;
using std::hex;
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
+int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod)
{
// adding a key to a deleted sequence
// starts a new sequence
modifiers.clear();
}
- modifiers.push_back(mod + (nmod << 16));
+ modifiers.push_back(make_pair(mod, nmod));
sequence.push_back(key);
++length_;
if (curmap) {
return curmap->lookup(key, mod, this);
}
-
+
return LFUN_UNKNOWN_ACTION;
}
if (s.empty()) return 1;
string::size_type i = 0;
- unsigned int mod = 0;
- unsigned int nmod = 0;
+ key_modifier::state mod = key_modifier::none;
+ key_modifier::state nmod = key_modifier::none;
+
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':
- mod |= ShiftMask;
+ mod |= key_modifier::shift;
i += 2;
continue;
case 'c': case 'C':
- mod |= ControlMask;
+ mod |= key_modifier::ctrl;
i += 2;
continue;
case 'm': case 'M':
- mod |= Mod1Mask;
+ mod |= key_modifier::alt;
i += 2;
continue;
default:
&& s[i + 2] == '-') {
switch (s[i + 1]) {
case 's': case 'S':
- nmod |= ShiftMask;
+ nmod |= key_modifier::shift;
i += 3;
continue;
case 'c': case 'C':
- nmod |= ControlMask;
+ nmod |= key_modifier::ctrl;
i += 3;
continue;
case 'm': case 'M':
- nmod |= Mod1Mask;
+ nmod |= key_modifier::alt;
i += 3;
continue;
default:
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]
return j;
}
i = j;
-
+
addkey(key, mod, nmod);
- mod = 0;
+ mod = key_modifier::none;
}
}
-
+
// empty sequence?
if (!length_)
return 0;
//if (deleted_)
// return buf;
-
+
for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
- buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
+ buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
// append a blank
if (i + 1 < length_) {