3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
15 #include "kbsequence.h"
21 #include "frontends/LyXKeySym.h"
22 #include "frontends/LyXKeySymFactory.h"
29 kb_sequence::addkey(LyXKeySymPtr key,
30 key_modifier::state mod, key_modifier::state nmod)
32 // adding a key to a deleted sequence
33 // starts a new sequence
40 modifiers.push_back(make_pair(mod, nmod));
41 sequence.push_back(key);
44 return curmap->lookup(key, mod, this);
47 static FuncRequest unknown(LFUN_UNKNOWN_ACTION);
52 string::size_type kb_sequence::parse(string const & s)
54 if (s.empty()) return 1;
56 string::size_type i = 0;
57 key_modifier::state mod = key_modifier::none;
58 key_modifier::state nmod = key_modifier::none;
60 while (i < s.length()) {
66 if (i + 1 < s.length() && s[i + 1] == '-') {
69 mod |= key_modifier::shift;
73 mod |= key_modifier::ctrl;
77 mod |= key_modifier::alt;
83 } else if (i + 2 < s.length() && s[i] == '~'
87 nmod |= key_modifier::shift;
91 nmod |= key_modifier::ctrl;
95 nmod |= key_modifier::alt;
103 string::size_type j = i;
104 for (; j < s.length() && s[j] != ' '; ++j)
105 tbuf += s[j]; // (!!!check bounds :-)
107 LyXKeySymPtr key(LyXKeySymFactory::create());
110 if ( ! key->isOK() ) {
116 addkey(key, mod, nmod);
117 mod = key_modifier::none;
122 if (sequence.size() == 0)
125 // everything is fine
130 string const kb_sequence::print() const
137 KeySequence::size_type i, length = sequence.size();
139 for (i = 0; i < length; ++i) {
140 buf += sequence[i]->print(modifiers[i].first);
143 if (i + 1 < length) {
151 string const kb_sequence::printOptions() const
160 buf += lyx::to_utf8(_(" options: "));
161 buf += curmap->print();
166 void kb_sequence::mark_deleted()
172 void kb_sequence::reset()
178 void kb_sequence::clear()