2000-02-04 09:38:32 +00:00
|
|
|
|
//<2F>-*- C++ -*-
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file kbsequence.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-11-30 13:25:38 +00:00
|
|
|
|
*/
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
|
|
#ifndef KBSEQUENCE_H
|
|
|
|
|
#define KBSEQUENCE_H
|
|
|
|
|
|
2002-05-26 17:33:14 +00:00
|
|
|
|
#include "frontends/key_state.h"
|
2006-04-13 12:18:42 +00:00
|
|
|
|
#include "frontends/LyXKeySym.h"
|
2003-09-06 20:08:10 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
2002-05-26 17:33:14 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
class kb_keymap;
|
2003-09-21 23:00:47 +00:00
|
|
|
|
class FuncRequest;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
|
|
/// Holds a key sequence and the current and standard keymaps
|
|
|
|
|
class kb_sequence {
|
|
|
|
|
public:
|
2002-06-18 15:44:30 +00:00
|
|
|
|
typedef std::vector<LyXKeySymPtr> KeySequence;
|
2002-08-11 16:27:10 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
friend class kb_keymap;
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
///
|
2001-11-30 13:25:38 +00:00
|
|
|
|
kb_sequence(kb_keymap * std, kb_keymap * cur)
|
2002-06-18 15:44:30 +00:00
|
|
|
|
: stdmap(std), curmap(cur), deleted_(false) {}
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Add a key to the key sequence and look it up in the curmap
|
|
|
|
|
* if the latter is defined.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
* @param keysym the key to add
|
2001-11-30 13:25:38 +00:00
|
|
|
|
* @param mod modifier mask
|
2001-12-10 15:59:20 +00:00
|
|
|
|
* @param nmod which modifiers to mask out for equality test
|
2001-11-30 13:25:38 +00:00
|
|
|
|
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
|
|
|
|
|
*/
|
2003-09-21 23:00:47 +00:00
|
|
|
|
FuncRequest const &
|
|
|
|
|
addkey(LyXKeySymPtr keysym, key_modifier::state mod,
|
|
|
|
|
key_modifier::state nmod = key_modifier::none);
|
2001-11-30 13:25:38 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a sequence of keys from a string to the sequence
|
|
|
|
|
* @return string::npos if OK, else error position in string
|
|
|
|
|
*
|
|
|
|
|
* Keys in the string must be separated with whitespace;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
* Use the keysym names used by XStringToKeysym, f.ex.
|
|
|
|
|
* "Space", "a", "Return", ...
|
2001-11-30 13:25:38 +00:00
|
|
|
|
* Prefixes are S-, C-, M- for shift, control, meta
|
2002-06-18 15:44:30 +00:00
|
|
|
|
* Prefixes can also be ignored by using the Tilde "~"
|
|
|
|
|
* f.ex.: "~S-Space".
|
2001-11-30 13:25:38 +00:00
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string::size_type parse(std::string const & s);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Return the current sequence as a string.
|
|
|
|
|
* @see parse()
|
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const print() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Return the current sequence and available options as
|
|
|
|
|
* a string. No options are added if no curmap kb map exists.
|
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const printOptions() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// Mark the sequence as deleted.
|
|
|
|
|
void mark_deleted();
|
2001-05-16 07:53:23 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// Reset sequence to become "deleted"
|
2000-02-04 09:38:32 +00:00
|
|
|
|
void reset();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// clear in full
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
bool deleted() const {
|
|
|
|
|
return deleted_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// length of sequence
|
2002-06-18 15:44:30 +00:00
|
|
|
|
KeySequence::size_type length() const {
|
|
|
|
|
return sequence.size();
|
2001-11-30 13:25:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
/// Keymap to use if a new sequence is starting
|
|
|
|
|
kb_keymap * stdmap;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
/// Keymap to use for the next key
|
|
|
|
|
kb_keymap * curmap;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
private:
|
|
|
|
|
/**
|
2002-06-18 15:44:30 +00:00
|
|
|
|
* Array holding the current key sequence as KeySyms.
|
2002-08-11 16:27:10 +00:00
|
|
|
|
* If sequence[length - 1] < 0xff it can be used as ISO8859 char
|
2001-11-30 13:25:38 +00:00
|
|
|
|
*/
|
2002-06-18 15:44:30 +00:00
|
|
|
|
KeySequence sequence;
|
|
|
|
|
|
|
|
|
|
typedef std::pair<key_modifier::state, key_modifier::state>
|
|
|
|
|
modifier_pair;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// modifiers for keys in the sequence
|
2002-05-26 17:33:14 +00:00
|
|
|
|
std::vector<modifier_pair> modifiers;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// is keysequence deleted ?
|
|
|
|
|
bool deleted_;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|