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"
33 // The only modifiers that we handle. We want to throw away things
35 enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
38 int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
40 // adding a key to a deleted sequence
41 // starts a new sequence
49 modifiers.push_back(mod + (nmod << 16));
50 sequence.push_back(key);
54 return curmap->lookup(key, mod, this);
57 return LFUN_UNKNOWN_ACTION;
61 string::size_type kb_sequence::parse(string const & s)
63 if (s.empty()) return 1;
65 string::size_type i = 0;
67 unsigned int nmod = 0;
68 while (i < s.length()) {
74 if (i + 1 < s.length() && s[i + 1] == '-') {
91 } else if (i + 2 < s.length() && s[i] == '~'
111 string::size_type j = i;
112 for (; j < s.length() && s[j] != ' '; ++j)
113 tbuf += s[j]; // (!!!check bounds :-)
115 KeySym key = XStringToKeysym(tbuf.c_str());
116 if (key == NoSymbol) {
118 << "kbmap.C: No such keysym: "
124 addkey(key, mod, nmod);
133 // everything is fine
138 string const kb_sequence::print() const
145 for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
146 buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
149 if (i + 1 < length_) {
157 string const kb_sequence::printOptions() const
166 buf += _(" options: ");
167 buf += curmap->print();
172 void kb_sequence::mark_deleted()
178 unsigned int kb_sequence::getsym() const
180 if (length_ == 0) return NoSymbol;
181 return sequence[length_ - 1];
185 char kb_sequence::getiso() const
187 unsigned int const c = getsym();
189 lyxerr[Debug::KBMAP] << "Raw keysym: "
190 << hex << c << dec << endl;
191 lyxerr[Debug::KBMAP] << "byte 3: "
192 << hex << (c & 0xff00) << dec
194 return kb_keymap::getiso(c);
198 void kb_sequence::reset()
204 void kb_sequence::clear()