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.
17 #include "frontends/mouse_state.h"
18 #include "frontends/LyXKeySymFactory.h"
19 #include "kbsequence.h"
27 int kb_sequence::addkey(LyXKeySymPtr key,
28 key_modifier::state mod, key_modifier::state nmod)
30 // adding a key to a deleted sequence
31 // starts a new sequence
38 modifiers.push_back(make_pair(mod, nmod));
39 sequence.push_back(key);
42 return curmap->lookup(key, mod, this);
45 return LFUN_UNKNOWN_ACTION;
49 string::size_type kb_sequence::parse(string const & s)
51 if (s.empty()) return 1;
53 string::size_type i = 0;
54 key_modifier::state mod = key_modifier::none;
55 key_modifier::state nmod = key_modifier::none;
57 while (i < s.length()) {
63 if (i + 1 < s.length() && s[i + 1] == '-') {
66 mod |= key_modifier::shift;
70 mod |= key_modifier::ctrl;
74 mod |= key_modifier::alt;
80 } else if (i + 2 < s.length() && s[i] == '~'
84 nmod |= key_modifier::shift;
88 nmod |= key_modifier::ctrl;
92 nmod |= key_modifier::alt;
100 string::size_type j = i;
101 for (; j < s.length() && s[j] != ' '; ++j)
102 tbuf += s[j]; // (!!!check bounds :-)
104 LyXKeySymPtr key(LyXKeySymFactory::create());
107 if ( ! key->isOK() ) {
113 addkey(key, mod, nmod);
114 mod = key_modifier::none;
119 if (sequence.size() == 0)
122 // everything is fine
127 string const kb_sequence::print() const
134 KeySequence::size_type i, length = sequence.size();
136 for (i = 0; i < length; ++i) {
137 buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
140 if (i + 1 < length) {
148 string const kb_sequence::printOptions() const
157 buf += _(" options: ");
158 buf += curmap->print();
163 void kb_sequence::mark_deleted()
169 void kb_sequence::reset()
175 void kb_sequence::clear()