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"
32 kb_sequence::addkey(LyXKeySymPtr key,
33 key_modifier::state mod, key_modifier::state nmod)
35 // adding a key to a deleted sequence
36 // starts a new sequence
43 modifiers.push_back(make_pair(mod, nmod));
44 sequence.push_back(key);
47 return curmap->lookup(key, mod, this);
50 static FuncRequest unknown(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;
60 key_modifier::state mod = key_modifier::none;
61 key_modifier::state nmod = key_modifier::none;
63 while (i < s.length()) {
69 if (i + 1 < s.length() && s[i + 1] == '-') {
72 mod |= key_modifier::shift;
76 mod |= key_modifier::ctrl;
80 mod |= key_modifier::alt;
86 } else if (i + 2 < s.length() && s[i] == '~'
90 nmod |= key_modifier::shift;
94 nmod |= key_modifier::ctrl;
98 nmod |= key_modifier::alt;
106 string::size_type j = i;
107 for (; j < s.length() && s[j] != ' '; ++j)
108 tbuf += s[j]; // (!!!check bounds :-)
110 LyXKeySymPtr key(LyXKeySymFactory::create());
113 if ( ! key->isOK() ) {
119 addkey(key, mod, nmod);
120 mod = key_modifier::none;
125 if (sequence.size() == 0)
128 // everything is fine
133 string const kb_sequence::print() const
140 KeySequence::size_type i, length = sequence.size();
142 for (i = 0; i < length; ++i) {
143 buf += sequence[i]->print(modifiers[i].first);
146 if (i + 1 < length) {
154 string const kb_sequence::printOptions() const
163 buf += to_utf8(_(" options: "));
164 buf += curmap->print();
169 void kb_sequence::mark_deleted()
175 void kb_sequence::reset()
181 void kb_sequence::clear()