lyx_mirror/src/kbsequence.h
Jean-Marc Lasgouttes 4c1fb15143 Make the shortcuts work correctly with the mac.
* src/frontends/LyXKeySym.h:
	* src/frontends/qt4/QLyXKeySym.h:
	* src/frontends/qt4/QLyXKeySym.C (print): add a forgui boolean that 
	tells whether the string should used localized names and special 
	characters.

	* src/MenuBackend.C (binding): 
	* src/kbmap.C (print): 
	* src/kbsequence.C (print, printOptions): add forgui parameter.

	* src/frontends/qt4/QLPopupMenu.C (addBinding): use a non-localaized 
	binding for Qt/Mac (because it needs to be parsed back) and a 
	localized one for the others (so that it looks good).

	* src/kbmap.C (defkey,printbindings): 
	* src/lyxfunc.C (processKeySym,dispatch,viewStatusMessage): adapt to 
	above changes.

	* src/kbmap.C (printKey): remove.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16510 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-04 17:10:24 +00:00

125 lines
2.9 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// -*- C++ -*-
/**
* \file kbsequence.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef KBSEQUENCE_H
#define KBSEQUENCE_H
#include "frontends/key_state.h"
#include "frontends/LyXKeySym.h"
#include <string>
#include <vector>
namespace lyx {
class kb_keymap;
class FuncRequest;
/// Holds a key sequence and the current and standard keymaps
class kb_sequence {
public:
typedef std::vector<LyXKeySymPtr> KeySequence;
friend class kb_keymap;
///
kb_sequence(kb_keymap * std, kb_keymap * cur)
: stdmap(std), curmap(cur), deleted_(false) {}
/**
* Add a key to the key sequence and look it up in the curmap
* if the latter is defined.
* @param keysym the key to add
* @param mod modifier mask
* @param nmod which modifiers to mask out for equality test
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
*/
FuncRequest const &
addkey(LyXKeySymPtr keysym, key_modifier::state mod,
key_modifier::state nmod = key_modifier::none);
/**
* 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, f.ex.
* "Space", "a", "Return", ...
* Prefixes are S-, C-, M- for shift, control, meta
* Prefixes can also be ignored by using the Tilde "~"
* f.ex.: "~S-Space".
*/
std::string::size_type parse(std::string const & s);
/**
* Return the current sequence as a string.
* @param forgui true if the string should use translations and
* special characters.
* @see parse()
*/
docstring const print(bool forgui) const;
/**
* Return the current sequence and available options as
* a string. No options are added if no curmap kb map exists.
* @param forgui true if the string should use translations and
* special characters.
*/
docstring const printOptions(bool forgui) const;
/// Mark the sequence as deleted.
void mark_deleted();
/// Reset sequence to become "deleted"
void reset();
/// clear in full
void clear();
bool deleted() const {
return deleted_;
}
/// length of sequence
KeySequence::size_type length() const {
return sequence.size();
}
/// Keymap to use if a new sequence is starting
kb_keymap * stdmap;
/// Keymap to use for the next key
kb_keymap * curmap;
private:
/**
* Array holding the current key sequence as KeySyms.
* If sequence[length - 1] < 0xff it can be used as ISO8859 char
*/
KeySequence sequence;
typedef std::pair<key_modifier::state, key_modifier::state>
modifier_pair;
/// modifiers for keys in the sequence
std::vector<modifier_pair> modifiers;
/// is keysequence deleted ?
bool deleted_;
};
} // namespace lyx
#endif