rename LyXKeySym into KeySymbol

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18059 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-04-27 08:43:38 +00:00
parent e870207601
commit 50016ccf3a
17 changed files with 76 additions and 105 deletions

View File

@ -20,7 +20,7 @@
#include "LyXAction.h" #include "LyXAction.h"
#include "Lexer.h" #include "Lexer.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -36,7 +36,7 @@ using std::endl;
using std::string; using std::string;
string const KeyMap::printKeySym(LyXKeySym const & key, string const KeyMap::printKeySym(KeySymbol const & key,
key_modifier::state mod) key_modifier::state mod)
{ {
string buf; string buf;
@ -171,7 +171,7 @@ bool KeyMap::read(string const & bind_file)
FuncRequest const & FuncRequest const &
KeyMap::lookup(LyXKeySymPtr key, KeyMap::lookup(KeySymbolPtr key,
key_modifier::state mod, KeySequence * seq) const key_modifier::state mod, KeySequence * seq) const
{ {
static FuncRequest const unknown(LFUN_UNKNOWN_ACTION); static FuncRequest const unknown(LFUN_UNKNOWN_ACTION);
@ -226,7 +226,7 @@ docstring const KeyMap::print(bool forgui) const
void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r) void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r)
{ {
LyXKeySymPtr code = seq->sequence[r]; KeySymbolPtr code = seq->sequence[r];
if (!code->isOK()) if (!code->isOK())
return; return;
@ -322,7 +322,7 @@ KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func,
} }
std::pair<LyXKeySym const *, key_modifier::state> std::pair<KeySymbol const *, key_modifier::state>
KeyMap::find1keybinding(FuncRequest const & func) const KeyMap::find1keybinding(FuncRequest const & func) const
{ {
Table::const_iterator end = table.end(); Table::const_iterator end = table.end();
@ -332,7 +332,7 @@ KeyMap::find1keybinding(FuncRequest const & func) const
return std::make_pair(cit->code.get(), cit->mod.first); return std::make_pair(cit->code.get(), cit->mod.first);
} }
return std::make_pair<LyXKeySym const *, key_modifier::state>(0, key_modifier::none); return std::make_pair<KeySymbol const *, key_modifier::state>(0, key_modifier::none);
} }

View File

@ -17,7 +17,7 @@
#include "FuncRequest.h" #include "FuncRequest.h"
#include "frontends/key_state.h" #include "frontends/key_state.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include "support/docstream.h" #include "support/docstream.h"
@ -60,7 +60,7 @@ public:
* @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION * @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
*/ */
FuncRequest const & FuncRequest const &
lookup(LyXKeySymPtr key, lookup(KeySymbolPtr key,
key_modifier::state mod, KeySequence * seq) const; key_modifier::state mod, KeySequence * seq) const;
/// ///
@ -74,10 +74,10 @@ public:
/** /**
* Given an action, find the first 1-key binding (if it exists). * Given an action, find the first 1-key binding (if it exists).
* The LyXKeySym pointer is 0 is no key is found. * The KeySymbol pointer is 0 is no key is found.
* [only used by the Qt/Mac frontend] * [only used by the Qt/Mac frontend]
*/ */
std::pair<LyXKeySym const *, key_modifier::state> std::pair<KeySymbol const *, key_modifier::state>
find1keybinding(FuncRequest const & func) const; find1keybinding(FuncRequest const & func) const;
@ -86,7 +86,7 @@ public:
* @param key the key as a keysym * @param key the key as a keysym
* @param mod the modifiers * @param mod the modifiers
*/ */
static std::string const printKeySym(LyXKeySym const & key, static std::string const printKeySym(KeySymbol const & key,
key_modifier::state mod); key_modifier::state mod);
typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair; typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
@ -95,7 +95,7 @@ private:
/// ///
struct Key { struct Key {
/// Keysym /// Keysym
LyXKeySymPtr code; KeySymbolPtr code;
/// Modifier masks /// Modifier masks
modifier_pair mod; modifier_pair mod;

View File

@ -18,8 +18,7 @@
#include "KeyMap.h" #include "KeyMap.h"
#include "lfuns.h" #include "lfuns.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include "frontends/LyXKeySymFactory.h"
namespace lyx { namespace lyx {
@ -29,7 +28,7 @@ using std::string;
FuncRequest const & FuncRequest const &
KeySequence::addkey(LyXKeySymPtr key, KeySequence::addkey(KeySymbolPtr key,
key_modifier::state mod, key_modifier::state nmod) key_modifier::state mod, key_modifier::state nmod)
{ {
// adding a key to a deleted sequence // adding a key to a deleted sequence
@ -108,7 +107,7 @@ size_t KeySequence::parse(string const & s)
for (; j < s.length() && s[j] != ' '; ++j) for (; j < s.length() && s[j] != ' '; ++j)
tbuf += s[j]; // (!!!check bounds :-) tbuf += s[j]; // (!!!check bounds :-)
LyXKeySymPtr key(LyXKeySymFactory::create()); KeySymbolPtr key(createKeySymbol());
key->init(tbuf); key->init(tbuf);
if (!key->isOK()) if (!key->isOK())

View File

@ -14,7 +14,7 @@
#define KB_SEQUENCE_H #define KB_SEQUENCE_H
#include "frontends/key_state.h" #include "frontends/key_state.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include <string> #include <string>
#include <vector> #include <vector>
@ -28,7 +28,7 @@ class FuncRequest;
/// Holds a key sequence and the current and standard keymaps /// Holds a key sequence and the current and standard keymaps
class KeySequence { class KeySequence {
public: public:
typedef std::vector<LyXKeySymPtr> Sequence; typedef std::vector<KeySymbolPtr> Sequence;
friend class KeyMap; friend class KeyMap;
@ -45,7 +45,7 @@ public:
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
*/ */
FuncRequest const & FuncRequest const &
addkey(LyXKeySymPtr keysym, key_modifier::state mod, addkey(KeySymbolPtr keysym, key_modifier::state mod,
key_modifier::state nmod = key_modifier::none); key_modifier::state nmod = key_modifier::none);
/** /**

View File

@ -80,7 +80,7 @@
#include "frontends/FileDialog.h" #include "frontends/FileDialog.h"
#include "frontends/FontLoader.h" #include "frontends/FontLoader.h"
#include "frontends/Gui.h" #include "frontends/Gui.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Menubar.h" #include "frontends/Menubar.h"
#include "frontends/Toolbars.h" #include "frontends/Toolbars.h"
@ -275,7 +275,7 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
} }
void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state) void LyXFunc::processKeySym(KeySymbolPtr keysym, key_modifier::state state)
{ {
LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl; LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;

View File

@ -28,7 +28,7 @@ namespace lyx {
class BufferView; class BufferView;
class FuncRequest; class FuncRequest;
class FuncStatus; class FuncStatus;
class LyXKeySym; class KeySymbol;
class LyXText; class LyXText;
class LyXView; class LyXView;
@ -57,7 +57,7 @@ public:
docstring const viewStatusMessage(); docstring const viewStatusMessage();
/// ///
void processKeySym(LyXKeySymPtr key, key_modifier::state state); void processKeySym(KeySymbolPtr key, key_modifier::state state);
/// ///
FuncStatus getStatus(FuncRequest const & action) const; FuncStatus getStatus(FuncRequest const & action) const;

View File

@ -1,6 +1,6 @@
// -*- C++ -*- // -*- C++ -*-
/** /**
* \file LyXKeySym.h * \file KeySymbol.h
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -9,8 +9,8 @@
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
#ifndef LYXKEYSYM_H #ifndef KEYSYMBOL_H
#define LYXKEYSYM_H #define KEYSYMBOL_H
#include <string> #include <string>
@ -29,14 +29,14 @@ namespace lyx {
* the functionality that LyX needs in regards to * the functionality that LyX needs in regards to
* key presses. * key presses.
*/ */
class LyXKeySym { class KeySymbol {
public: public:
LyXKeySym() {} KeySymbol() {}
virtual ~LyXKeySym() {} virtual ~KeySymbol() {}
/// ///
virtual bool operator==(LyXKeySym const& ks) const = 0; virtual bool operator==(KeySymbol const& ks) const = 0;
/// Initialize with the name of a key. F. ex. "space" or "a" /// Initialize with the name of a key. F. ex. "space" or "a"
virtual void init(std::string const & symbolname) = 0; virtual void init(std::string const & symbolname) = 0;
@ -55,7 +55,7 @@ public:
/** /**
* Return the value of the keysym into the UCS-4 encoding. * Return the value of the keysym into the UCS-4 encoding.
* This converts the LyXKeySym to a 32-bit encoded character. * This converts the KeySymbol to a 32-bit encoded character.
*/ */
virtual char_type getUCSEncoded() const = 0; virtual char_type getUCSEncoded() const = 0;
@ -67,7 +67,14 @@ public:
}; };
typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr; typedef boost::shared_ptr<KeySymbol> KeySymbolPtr;
/**
* Make a KeySymbol. Used because we want to
* generate a toolkit-specific instance.
*/
KeySymbol * createKeySymbol();
} // namespace lyx } // namespace lyx

View File

@ -1,29 +0,0 @@
// -*- C++ -*-
/**
* \file LyXKeySymFactory.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Asger & Jürgen
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LYXKEYSYMFACTORY_H
#define LYXKEYSYMFACTORY_H
namespace lyx {
class LyXKeySym;
namespace LyXKeySymFactory {
/**
* Make a LyXKeySym. Used because we want to
* generate a toolkit-specific instance.
*/
LyXKeySym * create();
}
} // namespace lyx
#endif // LYXKEYSYM_FACTORY_H

View File

@ -25,8 +25,8 @@ libfrontends_la_SOURCES = \
FileDialog.h \ FileDialog.h \
FontLoader.h \ FontLoader.h \
FontMetrics.h \ FontMetrics.h \
LyXKeySym.h \ KeySymbol.h \
LyXKeySymFactory.h \ KeySymbolFactory.h \
LyXView.cpp \ LyXView.cpp \
LyXView.h \ LyXView.h \
Menubar.h \ Menubar.h \

View File

@ -165,7 +165,7 @@ void WorkArea::redraw()
} }
void WorkArea::processKeySym(LyXKeySymPtr key, key_modifier::state state) void WorkArea::processKeySym(KeySymbolPtr key, key_modifier::state state)
{ {
// In order to avoid bad surprise in the middle of an operation, we better stop // In order to avoid bad surprise in the middle of an operation, we better stop
// the blinking cursor. // the blinking cursor.

View File

@ -15,7 +15,7 @@
#define BASE_WORKAREA_H #define BASE_WORKAREA_H
#include "frontends/key_state.h" #include "frontends/key_state.h"
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include "frontends/Timeout.h" #include "frontends/Timeout.h"
#include "support/docstring.h" #include "support/docstring.h"
@ -93,7 +93,7 @@ public:
/// Process Key pressed event. /// Process Key pressed event.
/// This needs to be public because it is accessed externally by GuiView. /// This needs to be public because it is accessed externally by GuiView.
void processKeySym(LyXKeySymPtr key, key_modifier::state state); void processKeySym(KeySymbolPtr key, key_modifier::state state);
protected: protected:
/// cause the display of the given area of the work area /// cause the display of the given area of the work area
virtual void expose(int x, int y, int w, int h) = 0; virtual void expose(int x, int y, int w, int h) = 0;

View File

@ -17,7 +17,7 @@
#include "GuiImplementation.h" #include "GuiImplementation.h"
#include "GuiWorkArea.h" #include "GuiWorkArea.h"
#include "QLyXKeySym.h" #include "QKeySymbol.h"
#include "QLMenubar.h" #include "QLMenubar.h"
#include "QLToolbar.h" #include "QLToolbar.h"
#include "QCommandBuffer.h" #include "QCommandBuffer.h"
@ -650,7 +650,7 @@ bool GuiView::event(QEvent * e)
if (e->type() == QEvent::ShortcutOverride) { if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent * ke = static_cast<QKeyEvent*>(e); QKeyEvent * ke = static_cast<QKeyEvent*>(e);
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) { if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym); boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
sym->set(ke); sym->set(ke);
BOOST_ASSERT(work_area_); BOOST_ASSERT(work_area_);
work_area_->processKeySym(sym, key_modifier::none); work_area_->processKeySym(sym, key_modifier::none);

View File

@ -15,7 +15,7 @@
#include "GuiApplication.h" #include "GuiApplication.h"
#include "QLPainter.h" #include "QLPainter.h"
#include "QLyXKeySym.h" #include "QKeySymbol.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "LyXView.h" #include "LyXView.h"
@ -421,7 +421,7 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e)
<< " key=" << e->key() << " key=" << e->key()
<< endl; << endl;
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym); boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
sym->set(e); sym->set(e);
processKeySym(sym, q_key_state(e->modifiers())); processKeySym(sym, q_key_state(e->modifiers()));
} }

View File

@ -1,5 +1,5 @@
/** /**
* \file qt4/LyXKeySymFactory.cpp * \file qt4/KeySymbolFactory.cpp
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -10,21 +10,15 @@
#include <config.h> #include <config.h>
#include "frontends/LyXKeySymFactory.h" #include "frontends/KeySymbol.h"
#include "QLyXKeySym.h"
#include "QKeySymbol.h"
namespace lyx { namespace lyx {
namespace LyXKeySymFactory { KeySymbol * createKeySymbol()
LyXKeySym * create()
{ {
return new QLyXKeySym; return new QKeySymbol;
} }
} // namespace LyXKeySymFactory
} // namespace lyx } // namespace lyx

View File

@ -39,7 +39,7 @@ libqt4_la_SOURCES = \
GuiFontLoader.h GuiFontLoader.cpp \ GuiFontLoader.h GuiFontLoader.cpp \
GuiFontMetrics.h GuiFontMetrics.cpp \ GuiFontMetrics.h GuiFontMetrics.cpp \
GuiSelection.h GuiSelection.cpp \ GuiSelection.h GuiSelection.cpp \
LyXKeySymFactory.cpp \ KeySymbol.cpp \
QLMenubar.cpp QLMenubar.h \ QLMenubar.cpp QLMenubar.h \
QBox.cpp QBox.h \ QBox.cpp QBox.h \
QBranches.cpp QBranches.h \ QBranches.cpp QBranches.h \
@ -50,7 +50,7 @@ libqt4_la_SOURCES = \
QLImage.cpp QLImage.h \ QLImage.cpp QLImage.h \
QViewSource.cpp QViewSource.h \ QViewSource.cpp QViewSource.h \
QLPainter.cpp QLPainter.h \ QLPainter.cpp QLPainter.h \
QLyXKeySym.cpp QLyXKeySym.h \ QKeySymbol.cpp QKeySymbol.h \
QPrint.cpp QPrint.h \ QPrint.cpp QPrint.h \
Qt2BC.cpp Qt2BC.h \ Qt2BC.cpp Qt2BC.h \
CheckedLineEdit.cpp CheckedLineEdit.h \ CheckedLineEdit.cpp CheckedLineEdit.h \

View File

@ -1,5 +1,5 @@
/** /**
* \file QLyXKeySym.cpp * \file QKeySymbol.cpp
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -11,7 +11,7 @@
#include <config.h> #include <config.h>
#include "QLyXKeySym.h" #include "QKeySymbol.h"
#include "qlkey.h" #include "qlkey.h"
#include "qt_helpers.h" #include "qt_helpers.h"
@ -78,13 +78,13 @@ char const encode(string const & encoding, QString const & str)
} }
QLyXKeySym::QLyXKeySym() QKeySymbol::QKeySymbol()
: LyXKeySym(), key_(0) : KeySymbol(), key_(0)
{ {
} }
void QLyXKeySym::set(QKeyEvent * ev) void QKeySymbol::set(QKeyEvent * ev)
{ {
key_ = ev->key(); key_ = ev->key();
if (ev->text().isNull()) { if (ev->text().isNull()) {
@ -97,7 +97,7 @@ void QLyXKeySym::set(QKeyEvent * ev)
} }
void QLyXKeySym::init(string const & symbolname) void QKeySymbol::init(string const & symbolname)
{ {
key_ = string_to_qkey(symbolname); key_ = string_to_qkey(symbolname);
text_ = toqstr(symbolname); text_ = toqstr(symbolname);
@ -105,7 +105,7 @@ void QLyXKeySym::init(string const & symbolname)
} }
bool QLyXKeySym::isOK() const bool QKeySymbol::isOK() const
{ {
bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown)); bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
LYXERR(Debug::KEY) << "isOK is " << ok << endl; LYXERR(Debug::KEY) << "isOK is " << ok << endl;
@ -113,7 +113,7 @@ bool QLyXKeySym::isOK() const
} }
bool QLyXKeySym::isModifier() const bool QKeySymbol::isModifier() const
{ {
bool const mod(q_is_modifier(key_)); bool const mod(q_is_modifier(key_));
LYXERR(Debug::KEY) << "isMod is " << mod << endl; LYXERR(Debug::KEY) << "isMod is " << mod << endl;
@ -121,7 +121,7 @@ bool QLyXKeySym::isModifier() const
} }
string QLyXKeySym::getSymbolName() const string QKeySymbol::getSymbolName() const
{ {
string sym(qkey_to_string(key_)); string sym(qkey_to_string(key_));
@ -133,7 +133,7 @@ string QLyXKeySym::getSymbolName() const
} }
char_type QLyXKeySym::getUCSEncoded() const char_type QKeySymbol::getUCSEncoded() const
{ {
if (text_.isEmpty()) if (text_.isEmpty())
return 0; return 0;
@ -143,7 +143,7 @@ char_type QLyXKeySym::getUCSEncoded() const
if (lyxerr.debugging() && text_.size() > 1) { if (lyxerr.debugging() && text_.size() > 1) {
// We don't know yet how well support the full ucs4 range. // We don't know yet how well support the full ucs4 range.
LYXERR(Debug::KEY) << "QLyXKeySym::getUCSEncoded()" << endl; LYXERR(Debug::KEY) << "QKeySymbol::getUCSEncoded()" << endl;
for (int i = 0; i < text_.size(); ++i) { for (int i = 0; i < text_.size(); ++i) {
LYXERR(Debug::KEY) << "char " << i << ": " LYXERR(Debug::KEY) << "char " << i << ": "
<< text_[i].unicode() << endl; << text_[i].unicode() << endl;
@ -156,7 +156,7 @@ char_type QLyXKeySym::getUCSEncoded() const
} }
docstring const QLyXKeySym::print(key_modifier::state mod, bool forgui) const docstring const QKeySymbol::print(key_modifier::state mod, bool forgui) const
{ {
int tmpkey = key_; int tmpkey = key_;
@ -174,7 +174,7 @@ docstring const QLyXKeySym::print(key_modifier::state mod, bool forgui) const
} }
bool QLyXKeySym::isText() const bool QKeySymbol::isText() const
{ {
if (text_.isEmpty()) { if (text_.isEmpty()) {
LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl; LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
@ -185,9 +185,9 @@ bool QLyXKeySym::isText() const
} }
bool QLyXKeySym::operator==(LyXKeySym const & ks) const bool QKeySymbol::operator==(KeySymbol const & ks) const
{ {
QLyXKeySym const & qks = static_cast<QLyXKeySym const &>(ks); QKeySymbol const & qks = static_cast<QKeySymbol const &>(ks);
// we do not have enough info for a fair comparison, so return // we do not have enough info for a fair comparison, so return
// false. This works out OK because unknown text from Qt will // false. This works out OK because unknown text from Qt will

View File

@ -1,6 +1,6 @@
// -*- C++ -*- // -*- C++ -*-
/** /**
* \file QLyXKeySym.h * \file QKeySymbol.h
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -13,7 +13,7 @@
#ifndef QLYXKEYSYM_H #ifndef QLYXKEYSYM_H
#define QLYXKEYSYM_H #define QLYXKEYSYM_H
#include "frontends/LyXKeySym.h" #include "frontends/KeySymbol.h"
#include <QString> #include <QString>
#include <QKeyEvent> #include <QKeyEvent>
@ -28,16 +28,16 @@ namespace lyx {
* *
* This is some really sick stuff. * This is some really sick stuff.
*/ */
class QLyXKeySym : public LyXKeySym { class QKeySymbol : public KeySymbol {
public: public:
QLyXKeySym(); QKeySymbol();
virtual ~QLyXKeySym() {} virtual ~QKeySymbol() {}
/// . /// .
/// inlined out because of profiling results under linux when /// inlined out because of profiling results under linux when
/// opening a document. /// opening a document.
inline bool operator==(LyXKeySym const& ks) const; inline bool operator==(KeySymbol const& ks) const;
/// delayed constructor /// delayed constructor
void set(QKeyEvent * ev); void set(QKeyEvent * ev);
@ -59,7 +59,7 @@ public:
/** /**
* Return the value of the keysym into the UCS-4 encoding. * Return the value of the keysym into the UCS-4 encoding.
* This converts the LyXKeySym to a 32-bit encoded character. * This converts the KeySymbol to a 32-bit encoded character.
*/ */
virtual char_type getUCSEncoded() const; virtual char_type getUCSEncoded() const;