2000-02-04 09:38:32 +00:00
|
|
|
|
//<2F>-*- C++ -*-
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file kbsequence.h
|
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
|
|
|
|
*/
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
|
|
#ifndef KBSEQUENCE_H
|
|
|
|
|
#define KBSEQUENCE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-11-15 14:53:04 +00:00
|
|
|
|
#include <vector>
|
2000-02-04 09:38:32 +00:00
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
|
|
class kb_keymap;
|
|
|
|
|
|
|
|
|
|
/// Holds a key sequence and the current and standard keymaps
|
|
|
|
|
class kb_sequence {
|
|
|
|
|
public:
|
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)
|
|
|
|
|
: stdmap(std), curmap(cur), length_(0), deleted_(false) {}
|
2000-11-15 14:53:04 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
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.
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
2002-01-12 20:00:47 +00:00
|
|
|
|
int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
|
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;
|
|
|
|
|
* Use the keysym names used by XStringToKeysym
|
|
|
|
|
* Prefixes are S-, C-, M- for shift, control, meta
|
|
|
|
|
*/
|
|
|
|
|
string::size_type parse(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()
|
|
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
/// Return the ISO value of the last keysym in sequence, or 0
|
2000-02-04 09:38:32 +00:00
|
|
|
|
char getiso() const;
|
2002-03-21 17:27:08 +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
|
|
|
|
|
std::vector<unsigned int>::size_type length() const {
|
|
|
|
|
return length_;
|
|
|
|
|
}
|
|
|
|
|
|
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:
|
|
|
|
|
/// get the keysym of last in sequence
|
|
|
|
|
unsigned int getsym() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Array holding the current key sequence.
|
|
|
|
|
* If sequence[length-1] < 0xff it can be used as ISO8859 char
|
|
|
|
|
*/
|
2000-11-15 14:53:04 +00:00
|
|
|
|
std::vector<unsigned int> sequence;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
/// modifiers for keys in the sequence
|
2000-11-15 14:53:04 +00:00
|
|
|
|
std::vector<unsigned int> modifiers;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
/// Current length of key sequence
|
2001-11-30 13:25:38 +00:00
|
|
|
|
std::vector<unsigned int>::size_type length_;
|
|
|
|
|
|
|
|
|
|
/// is keysequence deleted ?
|
|
|
|
|
bool deleted_;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|