X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fkbsequence.h;h=6dc269a0357687f9f3e343c8927992a5a4036848;hb=e7f4618bcce770369cf46335c2c7f0164b4b8857;hp=46cda83795b31b1da3f2a5998998d147781b2ef4;hpb=97ef9131ba95f605a48d09595bd2ace0f993a55b;p=lyx.git diff --git a/src/kbsequence.h b/src/kbsequence.h index 46cda83795..6dc269a035 100644 --- a/src/kbsequence.h +++ b/src/kbsequence.h @@ -1,76 +1,85 @@ // -*- C++ -*- /** * \file kbsequence.h - * Copyright 2001 the LyX Team - * Read the file COPYING + * 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 -#ifdef __GNUG__ -#pragma interface -#endif - -#include - #include "frontends/key_state.h" -#include "LString.h" +#include "frontends/LyXKeySym.h" +#include #include + +namespace lyx { + class kb_keymap; +class FuncRequest; /// Holds a key sequence and the current and standard keymaps class kb_sequence { public: + typedef std::vector KeySequence; + friend class kb_keymap; /// kb_sequence(kb_keymap * std, kb_keymap * cur) - : stdmap(std), curmap(cur), length_(0), deleted_(false) {} - - + : 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 text the text from the key event + * @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 */ - int addkey(unsigned int text, key_modifier::state mod, - key_modifier::state nmod = key_modifier::none); + 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 + * 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". */ - string::size_type parse(string const & s); + 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() */ - string const print() const; + 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. */ - string const printOptions() const; + docstring const printOptions(bool forgui) const; /// Mark the sequence as deleted. void mark_deleted(); - /// Return the ISO value of the last keysym in sequence, or 0 - char getiso() const; - /// Reset sequence to become "deleted" void reset(); @@ -82,8 +91,8 @@ public: } /// length of sequence - std::vector::size_type length() const { - return length_; + KeySequence::size_type length() const { + return sequence.size(); } /// Keymap to use if a new sequence is starting @@ -93,24 +102,23 @@ public: kb_keymap * curmap; private: - /// get the keysym of last in sequence - unsigned int getsym() const; - /** - * Array holding the current key sequence. - * If sequence[length-1] < 0xff it can be used as ISO8859 char + * Array holding the current key sequence as KeySyms. + * If sequence[length - 1] < 0xff it can be used as ISO8859 char */ - std::vector sequence; + KeySequence sequence; + + typedef std::pair + modifier_pair; - typedef std::pair modifier_pair; /// modifiers for keys in the sequence std::vector modifiers; - /// Current length of key sequence - std::vector::size_type length_; - /// is keysequence deleted ? bool deleted_; }; + +} // namespace lyx + #endif