2 * \file KeySequence.cpp
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 "KeySequence.h"
21 #include "frontends/LyXKeySym.h"
22 #include "frontends/LyXKeySymFactory.h"
32 KeySequence::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 size_t KeySequence::parse(string const & s)
61 key_modifier::state mod = key_modifier::none;
62 key_modifier::state nmod = key_modifier::none;
64 while (i < s.length()) {
70 if (i + 1 < s.length() && s[i + 1] == '-') {
73 mod |= key_modifier::shift;
77 mod |= key_modifier::ctrl;
81 mod |= key_modifier::alt;
87 } else if (i + 2 < s.length() && s[i] == '~'
91 nmod |= key_modifier::shift;
95 nmod |= key_modifier::ctrl;
99 nmod |= key_modifier::alt;
108 for (; j < s.length() && s[j] != ' '; ++j)
109 tbuf += s[j]; // (!!!check bounds :-)
111 LyXKeySymPtr key(LyXKeySymFactory::create());
119 addkey(key, mod, nmod);
120 mod = key_modifier::none;
125 if (sequence.size() == 0)
128 // everything is fine
133 docstring const KeySequence::print(bool forgui) const
137 size_t const length = sequence.size();
139 for (size_t i = 0; i < length; ++i) {
140 buf += sequence[i]->print(modifiers[i].first, forgui);
149 docstring const KeySequence::printOptions(bool forgui) const
153 buf += print(forgui);
158 buf += _(" options: ");
159 buf += curmap->print(forgui);
164 void KeySequence::mark_deleted()
170 void KeySequence::reset()
176 void KeySequence::clear()