1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
18 #pragma implementation
21 #include "kbsequence.h"
23 #include "commandtags.h"
28 // The only modifiers that we handle. We want to throw away things
30 enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
33 int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
35 // adding a key to a deleted sequence
36 // starts a new sequence
44 modifiers.push_back(mod + (nmod << 16));
45 sequence.push_back(key);
49 return curmap->lookup(key, mod, this);
52 return LFUN_UNKNOWN_ACTION;
56 string::size_type kb_sequence::parse(string const & s)
58 if (s.empty()) return 1;
60 string::size_type i = 0;
62 unsigned int nmod = 0;
63 while (i < s.length()) {
69 if (i + 1 < s.length() && s[i + 1] == '-') {
86 } else if (i + 2 < s.length() && s[i] == '~'
106 string::size_type j = i;
107 for (; j < s.length() && s[j] != ' '; ++j)
108 tbuf += s[j]; // (!!!check bounds :-)
110 KeySym key = XStringToKeysym(tbuf.c_str());
111 if (key == NoSymbol) {
113 << "kbmap.C: No such keysym: "
119 addkey(key, mod, nmod);
128 // everything is fine
133 string const kb_sequence::print() const
140 for (std::vector<unsigned int>::size_type i = 0; i < length_; ++i) {
141 buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
144 if (i + 1 < length_) {
152 string const kb_sequence::printOptions() const
161 buf += _(" options: ");
162 buf += curmap->print();
167 void kb_sequence::mark_deleted()
173 unsigned int kb_sequence::getsym() const
175 if (length_ == 0) return NoSymbol;
176 return sequence[length_ - 1];
180 char kb_sequence::getiso() const
182 unsigned int const c = getsym();
184 lyxerr[Debug::KBMAP] << "Raw keysym: "
185 << std::hex << c << std::dec << endl;
186 lyxerr[Debug::KBMAP] << "byte 3: "
187 << std::hex << (c & 0xff00) << std::dec
189 return kb_keymap::getiso(c);
193 void kb_sequence::reset()
199 void kb_sequence::clear()