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/KeySymbol.h"
29 FuncRequest
const & KeySequence::addkey(KeySymbol
const & key
,
30 KeyModifier mod
, KeyModifier 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 size_t KeySequence::parse(string
const & s
)
58 KeyModifier mod
= NoModifier
;
59 KeyModifier nmod
= NoModifier
;
61 while (i
< s
.length()) {
67 if (i
+ 1 < s
.length() && s
[i
+ 1] == '-') {
74 mod
|= ControlModifier
;
84 } else if (i
+ 2 < s
.length() && s
[i
] == '~'
88 nmod
|= ShiftModifier
;
92 nmod
|= ControlModifier
;
105 for (; j
< s
.length() && s
[j
] != ' '; ++j
)
106 tbuf
+= s
[j
]; // (!!!check bounds :-)
116 addkey(key
, mod
, nmod
);
122 if (sequence
.size() == 0)
125 // everything is fine
130 docstring
const KeySequence::print(outputFormat format
) const
134 size_t const length
= sequence
.size();
136 for (size_t i
= 0; i
!= length
; ++i
) {
139 buf
+= sequence
[i
].print(modifiers
[i
].first
, false);
142 buf
+= sequence
[i
].print(modifiers
[i
].first
, true);
145 KeyModifier mod
= modifiers
[i
].first
;
146 if (mod
& ShiftModifier
)
148 if (mod
& ControlModifier
)
150 if (mod
& AltModifier
)
153 buf
+= from_utf8(sequence
[i
].getSymbolName());
164 docstring
const KeySequence::printOptions(bool forgui
) const
166 docstring buf
= print(forgui
? ForGui
: Portable
);
171 buf
+= _(" options: ");
172 buf
+= curmap
->print(forgui
? ForGui
: Portable
);
177 void KeySequence::mark_deleted()
183 void KeySequence::reset()
190 void KeySequence::clear()