mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
rename kb_sequence into KeySequence
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18057 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1d6c4787f9
commit
5265a8c02c
@ -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);
|
||||
}
|
||||
|
12
src/KeyMap.h
12
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<kb_sequence> Bindings;
|
||||
typedef std::deque<KeySequence> 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(); }
|
||||
|
@ -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 <config.h>
|
||||
|
||||
#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();
|
@ -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<LyXKeySymPtr> KeySequence;
|
||||
typedef std::vector<LyXKeySymPtr> 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<key_modifier::state, key_modifier::state>
|
||||
modifier_pair;
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<kb_sequence> keyseq;
|
||||
boost::scoped_ptr<KeySequence> keyseq;
|
||||
///
|
||||
boost::scoped_ptr<kb_sequence> cancel_meta_seq;
|
||||
boost::scoped_ptr<KeySequence> cancel_meta_seq;
|
||||
///
|
||||
key_modifier::state meta_fake_bit;
|
||||
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user