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 docstring const kb_sequence::print(bool forgui) const
137 const KeySequence::size_type length = sequence.size();
139 for (KeySequence::size_type i = 0; i < length; ++i) {
140 buf += sequence[i]->print(modifiers[i].first, forgui);
143 if (i + 1 < length) {
151 docstring const kb_sequence::printOptions(bool forgui) const
155 buf += print(forgui);
160 buf += _(" options: ");
161 buf += curmap->print(forgui);
166 void kb_sequence::mark_deleted()
172 void kb_sequence::reset()
178 void kb_sequence::clear()