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, unsigned int nmod)
34 // adding a key to a deleted sequence
35 // starts a new sequence
43 modifiers.push_back(mod + (nmod << 16));
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 unsigned int nmod = 0;
62 while (i < s.length()) {
68 if (i + 1 < s.length() && s[i + 1] == '-') {
85 } else if (i + 2 < s.length() && s[i] == '~'
105 string::size_type j = i;
106 for (; j < s.length() && s[j] != ' '; ++j)
107 tbuf += s[j]; // (!!!check bounds :-)
109 KeySym key = XStringToKeysym(tbuf.c_str());
110 if (key == NoSymbol) {
112 << "kbmap.C: No such keysym: "
118 addkey(key, mod, nmod);
127 // everything is fine
132 string const kb_sequence::print() const
139 for (std::vector<unsigned int>::size_type i = 0; i < length_; ++i) {
140 buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
143 if (i + 1 < length_) {
151 string const kb_sequence::printOptions() const
160 buf += _(" options: ");
161 buf += curmap->print();
166 void kb_sequence::mark_deleted()
172 unsigned int kb_sequence::getsym() const
174 if (length_ == 0) return NoSymbol;
175 return sequence[length_ - 1];
179 char kb_sequence::getiso() const
181 unsigned int const c = getsym();
183 lyxerr[Debug::KBMAP] << "Raw keysym: "
184 << std::hex << c << std::dec << endl;
185 lyxerr[Debug::KBMAP] << "byte 3: "
186 << std::hex << (c & 0xff00) << std::dec
188 return kb_keymap::getiso(c);
192 void kb_sequence::reset()
198 void kb_sequence::clear()