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"
27 // The only modifiers that we handle. We want to throw away things
29 enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
32 kb_action kb_sequence::addkey(unsigned int key, unsigned int mod)
34 // adding a key to a deleted sequence
35 // starts a new sequence
43 modifiers.push_back(mod);
44 sequence.push_back(key);
48 return curmap->lookup(key, mod, this);
51 return LFUN_UNKNOWN_ACTION;
55 string::size_type kb_sequence::parse(string const & s)
57 if (s.empty()) return 1;
59 string::size_type i = 0;
61 while (i < s.length()) {
67 if (i + 1 < s.length() && s[i + 1] == '-') {
84 } else if (i + 2 < s.length() && s[i] == '~'
101 string::size_type j = i;
102 for (; j < s.length() && s[j] != ' '; ++j)
103 tbuf += s[j]; // (!!!check bounds :-)
105 KeySym key = XStringToKeysym(tbuf.c_str());
106 if (key == NoSymbol) {
108 << "kbmap.C: No such keysym: "
123 // everything is fine
128 string const kb_sequence::print() const
135 for (std::vector<unsigned int>::size_type i = 0; i < length_; ++i) {
136 buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
139 if (i + 1 < length_) {
147 string const kb_sequence::printOptions() const
156 buf += _(" options: ");
157 buf += curmap->print();
162 void kb_sequence::mark_deleted()
168 unsigned int kb_sequence::getsym() const
170 if (length_ == 0) return NoSymbol;
171 return sequence[length_ - 1];
175 char kb_sequence::getiso() const
177 unsigned int const c = getsym();
179 lyxerr[Debug::KBMAP] << "Raw keysym: "
180 << std::hex << c << std::dec << endl;
181 lyxerr[Debug::KBMAP] << "byte 3: "
182 << std::hex << (c & 0xff00) << std::dec
184 return kb_keymap::getiso(c);
188 void kb_sequence::reset()
194 void kb_sequence::clear()