diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp index 354a8d62bf..bef688fe54 100644 --- a/src/KeyMap.cpp +++ b/src/KeyMap.cpp @@ -16,7 +16,7 @@ #include "KeyMap.h" #include "debug.h" -#include "kb_sequence.h" +#include "KeySequence.h" #include "LyXAction.h" #include "Lexer.h" @@ -61,7 +61,7 @@ size_t KeyMap::bind(string const & seq, FuncRequest const & func) << seq << "' Action `" << func.action << '\'' << endl; - kb_sequence k(0, 0); + KeySequence k(0, 0); string::size_type const res = k.parse(seq); if (res == string::npos) { @@ -172,7 +172,7 @@ bool KeyMap::read(string const & bind_file) FuncRequest const & KeyMap::lookup(LyXKeySymPtr key, - key_modifier::state mod, kb_sequence * seq) const + key_modifier::state mod, KeySequence * seq) const { static FuncRequest const unknown(LFUN_UNKNOWN_ACTION); @@ -224,7 +224,7 @@ docstring const KeyMap::print(bool forgui) const } -void KeyMap::defkey(kb_sequence * seq, FuncRequest const & func, unsigned int r) +void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r) { LyXKeySymPtr code = seq->sequence[r]; if (!code->isOK()) @@ -292,12 +292,12 @@ docstring const KeyMap::printbindings(FuncRequest const & func) const KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func) const { - return findbindings(func, kb_sequence(0, 0)); + return findbindings(func, KeySequence(0, 0)); } KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func, - kb_sequence const & prefix) const + KeySequence const & prefix) const { Bindings res; if (table.empty()) return res; @@ -306,13 +306,13 @@ KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func, for (Table::const_iterator cit = table.begin(); cit != end; ++cit) { if (cit->table.get()) { - kb_sequence seq = prefix; + KeySequence seq = prefix; seq.addkey(cit->code, cit->mod.first); Bindings res2 = cit->table->findbindings(func, seq); res.insert(res.end(), res2.begin(), res2.end()); } else if (cit->func == func) { - kb_sequence seq = prefix; + KeySequence seq = prefix; seq.addkey(cit->code, cit->mod.first); res.push_back(seq); } diff --git a/src/KeyMap.h b/src/KeyMap.h index 97687a7c60..eaf1006e40 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -29,7 +29,7 @@ namespace lyx { -class kb_sequence; +class KeySequence; /// Defines key maps and actions for key sequences class KeyMap { @@ -38,7 +38,7 @@ public: * Bind a key sequence to an action. * @return 0 on success, or position in string seq where error * occurs. - * See kb_sequence::parse for the syntax of the seq string + * See KeySequence::parse for the syntax of the seq string */ size_t bind(std::string const & seq, FuncRequest const & func); @@ -61,10 +61,10 @@ public: */ FuncRequest const & lookup(LyXKeySymPtr key, - key_modifier::state mod, kb_sequence * seq) const; + key_modifier::state mod, KeySequence * seq) const; /// - typedef std::deque Bindings; + typedef std::deque Bindings; /// Given an action, find all keybindings. Bindings findbindings(FuncRequest const & func) const; @@ -111,7 +111,7 @@ private: * Define an action for a key sequence. * @param r internal recursion level */ - void defkey(kb_sequence * seq, FuncRequest const & func, + void defkey(KeySequence * seq, FuncRequest const & func, unsigned int r = 0); /** @@ -120,7 +120,7 @@ private: * @param prefix a sequence to prepend the results */ Bindings findbindings(FuncRequest const & func, - kb_sequence const & prefix) const; + KeySequence const & prefix) const; /// is the table empty ? bool empty() const { return table.empty(); } diff --git a/src/kb_sequence.cpp b/src/KeySequence.cpp similarity index 81% rename from src/kb_sequence.cpp rename to src/KeySequence.cpp index 145fffe7ad..c13c41ecdf 100644 --- a/src/kb_sequence.cpp +++ b/src/KeySequence.cpp @@ -1,5 +1,5 @@ /** - * \file kb_sequence.cpp + * \file KeySequence.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -12,7 +12,7 @@ #include -#include "kb_sequence.h" +#include "KeySequence.h" #include "gettext.h" #include "KeyMap.h" @@ -29,7 +29,7 @@ using std::string; FuncRequest const & -kb_sequence::addkey(LyXKeySymPtr key, +KeySequence::addkey(LyXKeySymPtr key, key_modifier::state mod, key_modifier::state nmod) { // adding a key to a deleted sequence @@ -52,11 +52,12 @@ kb_sequence::addkey(LyXKeySymPtr key, } -string::size_type kb_sequence::parse(string const & s) +size_t KeySequence::parse(string const & s) { - if (s.empty()) return 1; + if (s.empty()) + return 1; - string::size_type i = 0; + size_t i = 0; key_modifier::state mod = key_modifier::none; key_modifier::state nmod = key_modifier::none; @@ -103,16 +104,15 @@ string::size_type kb_sequence::parse(string const & s) } } else { string tbuf; - string::size_type j = i; + size_t j = i; for (; j < s.length() && s[j] != ' '; ++j) tbuf += s[j]; // (!!!check bounds :-) LyXKeySymPtr key(LyXKeySymFactory::create()); key->init(tbuf); - if ( ! key->isOK() ) { + if (!key->isOK()) return j; - } i = j; @@ -130,25 +130,23 @@ string::size_type kb_sequence::parse(string const & s) } -docstring const kb_sequence::print(bool forgui) const +docstring const KeySequence::print(bool forgui) const { docstring buf; - const KeySequence::size_type length = sequence.size(); + size_t const length = sequence.size(); - for (KeySequence::size_type i = 0; i < length; ++i) { + for (size_t i = 0; i < length; ++i) { buf += sequence[i]->print(modifiers[i].first, forgui); - // append a blank - if (i + 1 < length) { + if (i + 1 < length) buf += ' '; - } } return buf; } -docstring const kb_sequence::printOptions(bool forgui) const +docstring const KeySequence::printOptions(bool forgui) const { docstring buf; @@ -163,19 +161,19 @@ docstring const kb_sequence::printOptions(bool forgui) const } -void kb_sequence::mark_deleted() +void KeySequence::mark_deleted() { deleted_ = true; } -void kb_sequence::reset() +void KeySequence::reset() { mark_deleted(); curmap = stdmap; } -void kb_sequence::clear() +void KeySequence::clear() { sequence.clear(); reset(); diff --git a/src/kb_sequence.h b/src/KeySequence.h similarity index 88% rename from src/kb_sequence.h rename to src/KeySequence.h index 9c12e3bd9d..3aead2826c 100644 --- a/src/kb_sequence.h +++ b/src/KeySequence.h @@ -1,6 +1,6 @@ -// -*- C++ -*- +// -*- C++ -*- /** - * \file kb_sequence.h + * \file KeySequence.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -26,14 +26,14 @@ class KeyMap; class FuncRequest; /// Holds a key sequence and the current and standard keymaps -class kb_sequence { +class KeySequence { public: - typedef std::vector KeySequence; + typedef std::vector Sequence; friend class KeyMap; /// - kb_sequence(KeyMap * std, KeyMap * cur) + KeySequence(KeyMap * std, KeyMap * cur) : stdmap(std), curmap(cur), deleted_(false) {} /** @@ -59,7 +59,7 @@ public: * Prefixes can also be ignored by using the Tilde "~" * f.ex.: "~S-Space". */ - std::string::size_type parse(std::string const & s); + size_t parse(std::string const & s); /** * Return the current sequence as a string. @@ -86,14 +86,10 @@ public: /// clear in full void clear(); - bool deleted() const { - return deleted_; - } + bool deleted() const { return deleted_; } /// length of sequence - KeySequence::size_type length() const { - return sequence.size(); - } + size_t length() const { return sequence.size(); } /// Keymap to use if a new sequence is starting KeyMap * stdmap; @@ -106,7 +102,7 @@ private: * Array holding the current key sequence as KeySyms. * If sequence[length - 1] < 0xff it can be used as ISO8859 char */ - KeySequence sequence; + Sequence sequence; typedef std::pair modifier_pair; diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index c1355cc70a..cf78d14234 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -209,8 +209,8 @@ LyXFunc::LyXFunc() void LyXFunc::initKeySequences(KeyMap * kb) { - keyseq.reset(new kb_sequence(kb, kb)); - cancel_meta_seq.reset(new kb_sequence(kb, kb)); + keyseq.reset(new KeySequence(kb, kb)); + cancel_meta_seq.reset(new KeySequence(kb, kb)); } diff --git a/src/LyXFunc.h b/src/LyXFunc.h index 370ce6ab7f..12e9ce3e04 100644 --- a/src/LyXFunc.h +++ b/src/LyXFunc.h @@ -15,7 +15,7 @@ #ifndef LYXFUNC_H #define LYXFUNC_H -#include "kb_sequence.h" +#include "KeySequence.h" #include "lfuns.h" #include "support/docstring.h" @@ -92,9 +92,9 @@ private: char_type encoded_last_key; /// - boost::scoped_ptr keyseq; + boost::scoped_ptr keyseq; /// - boost::scoped_ptr cancel_meta_seq; + boost::scoped_ptr cancel_meta_seq; /// key_modifier::state meta_fake_bit; diff --git a/src/Makefile.am b/src/Makefile.am index d0df97ba1a..ca8e8b7937 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -148,8 +148,8 @@ lyx_SOURCES = \ Intl.h \ KeyMap.cpp \ KeyMap.h \ - kb_sequence.cpp \ - kb_sequence.h \ + KeySequence.cpp \ + KeySequence.h \ KmodInfo.h \ Language.cpp \ Language.h \