Angus Leeming wrote:
> The patch is nice in that it returns a container of kb_sequences when
> youask for a container of kb_sequences, rather than some stringified
> version of the same.
>
> If you're interested in reading the contents of kb_sequence, then why not
> add to kb_sequence:
Actually, the attached patch is working code ;-)
--
Angus
Index: src/kbsequence.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.C,v
retrieving revision 1.37
diff -u -p -r1.37 kbsequence.C
--- src/kbsequence.C 26 Mar 2004 15:12:34 -0000 1.37
+++ src/kbsequence.C 30 Jun 2004 10:48:18 -0000
@@ -13,6 +13,7 @@
#include <config.h>
#include "kbsequence.h"
+#include "debug.h" // temporary
#include "gettext.h"
#include "kbmap.h"
@@ -131,6 +132,9 @@ string const kb_sequence::print() const
{
string buf;
+ const_keysym_iterator const end = end_sequence();
+ for (const_keysym_iterator it = begin_sequence(); it != end; ++it)
+ lyxerr << it->getSymbolName() << std::endl;
//if (deleted_)
// return buf;
Index: src/kbsequence.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.h,v
retrieving revision 1.20
diff -u -p -r1.20 kbsequence.h
--- src/kbsequence.h 6 Oct 2003 15:42:18 -0000 1.20
+++ src/kbsequence.h 30 Jun 2004 10:48:18 -0000
@@ -16,6 +16,7 @@
#include "frontends/key_state.h"
#include <boost/shared_ptr.hpp>
+#include <boost/iterator/indirect_iterator.hpp>
#include <string>
#include <vector>
@@ -96,6 +97,25 @@ public:
/// Keymap to use for the next key
kb_keymap * curmap;
+
+ // This iterator, when de-referenced,
+ // returns 'LyXKeySym const &', which is exactly what
+ // you're interested in. Moreover, the returned data is
+ // immutable, also something that's good here.
+ typedef boost::indirect_iterator<
+ KeySequence::const_iterator,
+ LyXKeySym const &>
+ const_keysym_iterator;
+
+ const_keysym_iterator begin_sequence() const
+ {
+ return boost::make_indirect_iterator(sequence.begin());
+ }
+
+ const_keysym_iterator end_sequence() const
+ {
+ return boost::make_indirect_iterator(sequence.end());
+ }
private:
/**