mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
simplify KeySymbol stuff. which hopefully works...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20322 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
85f83a9df8
commit
f86525fc2e
@ -170,8 +170,7 @@ bool KeyMap::read(string const & bind_file)
|
||||
}
|
||||
|
||||
|
||||
FuncRequest const &
|
||||
KeyMap::lookup(KeySymbolPtr key,
|
||||
FuncRequest const & KeyMap::lookup(KeySymbol const &key,
|
||||
key_modifier::state mod, KeySequence * seq) const
|
||||
{
|
||||
static FuncRequest const unknown(LFUN_UNKNOWN_ACTION);
|
||||
@ -188,7 +187,7 @@ KeyMap::lookup(KeySymbolPtr key,
|
||||
key_modifier::state check =
|
||||
static_cast<key_modifier::state>(mod & ~mask);
|
||||
|
||||
if (*(cit->code) == *key && cit->mod.first == check) {
|
||||
if (cit->code == key && cit->mod.first == check) {
|
||||
// match found
|
||||
if (cit->table.get()) {
|
||||
// this is a prefix key - set new map
|
||||
@ -217,7 +216,7 @@ docstring const KeyMap::print(bool forgui) const
|
||||
docstring buf;
|
||||
Table::const_iterator end = table.end();
|
||||
for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
|
||||
buf += cit->code->print(cit->mod.first, forgui);
|
||||
buf += cit->code.print(cit->mod.first, forgui);
|
||||
buf += ' ';
|
||||
}
|
||||
return buf;
|
||||
@ -226,8 +225,8 @@ docstring const KeyMap::print(bool forgui) const
|
||||
|
||||
void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r)
|
||||
{
|
||||
KeySymbolPtr code = seq->sequence[r];
|
||||
if (!code->isOK())
|
||||
KeySymbol code = seq->sequence[r];
|
||||
if (!code.isOK())
|
||||
return;
|
||||
|
||||
key_modifier::state const mod1 = seq->modifiers[r].first;
|
||||
@ -236,7 +235,7 @@ void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r)
|
||||
// check if key is already there
|
||||
Table::iterator end = table.end();
|
||||
for (Table::iterator it = table.begin(); it != end; ++it) {
|
||||
if (*(code) == *(it->code)
|
||||
if (code == it->code
|
||||
&& mod1 == it->mod.first
|
||||
&& mod2 == it->mod.second) {
|
||||
// overwrite binding
|
||||
@ -322,18 +321,4 @@ KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func,
|
||||
}
|
||||
|
||||
|
||||
std::pair<KeySymbol const *, key_modifier::state>
|
||||
KeyMap::find1keybinding(FuncRequest const & func) const
|
||||
{
|
||||
Table::const_iterator end = table.end();
|
||||
for (Table::const_iterator cit = table.begin();
|
||||
cit != end; ++cit) {
|
||||
if (!cit->table.get() && cit->func == func)
|
||||
return std::make_pair(cit->code.get(), cit->mod.first);
|
||||
}
|
||||
|
||||
return std::make_pair<KeySymbol const *, key_modifier::state>(0, key_modifier::none);
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
* @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
|
||||
*/
|
||||
FuncRequest const &
|
||||
lookup(KeySymbolPtr key,
|
||||
lookup(KeySymbol const & key,
|
||||
key_modifier::state mod, KeySequence * seq) const;
|
||||
|
||||
///
|
||||
@ -77,7 +77,7 @@ public:
|
||||
* The KeySymbol pointer is 0 is no key is found.
|
||||
* [only used by the Qt/Mac frontend]
|
||||
*/
|
||||
std::pair<KeySymbol const *, key_modifier::state>
|
||||
std::pair<KeySymbol, key_modifier::state>
|
||||
find1keybinding(FuncRequest const & func) const;
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ private:
|
||||
///
|
||||
struct Key {
|
||||
/// Keysym
|
||||
KeySymbolPtr code;
|
||||
KeySymbol code;
|
||||
|
||||
/// Modifier masks
|
||||
modifier_pair mod;
|
||||
|
@ -26,10 +26,8 @@ using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
FuncRequest const &
|
||||
KeySequence::addkey(KeySymbolPtr key,
|
||||
key_modifier::state mod, key_modifier::state nmod)
|
||||
FuncRequest const & KeySequence::addkey(KeySymbol const & key,
|
||||
key_modifier::state mod, key_modifier::state nmod)
|
||||
{
|
||||
// adding a key to a deleted sequence
|
||||
// starts a new sequence
|
||||
@ -107,10 +105,10 @@ size_t KeySequence::parse(string const & s)
|
||||
for (; j < s.length() && s[j] != ' '; ++j)
|
||||
tbuf += s[j]; // (!!!check bounds :-)
|
||||
|
||||
KeySymbolPtr key(createKeySymbol());
|
||||
key->init(tbuf);
|
||||
KeySymbol key;
|
||||
key.init(tbuf);
|
||||
|
||||
if (!key->isOK())
|
||||
if (!key.isOK())
|
||||
return j;
|
||||
|
||||
i = j;
|
||||
@ -135,10 +133,10 @@ docstring const KeySequence::print(bool forgui) const
|
||||
|
||||
size_t const length = sequence.size();
|
||||
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
buf += sequence[i]->print(modifiers[i].first, forgui);
|
||||
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;
|
||||
|
@ -28,7 +28,7 @@ class FuncRequest;
|
||||
/// Holds a key sequence and the current and standard keymaps
|
||||
class KeySequence {
|
||||
public:
|
||||
typedef std::vector<KeySymbolPtr> Sequence;
|
||||
typedef std::vector<KeySymbol> Sequence;
|
||||
|
||||
friend class KeyMap;
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
|
||||
*/
|
||||
FuncRequest const &
|
||||
addkey(KeySymbolPtr keysym, key_modifier::state mod,
|
||||
addkey(KeySymbol const & keysym, key_modifier::state mod,
|
||||
key_modifier::state nmod = key_modifier::none);
|
||||
|
||||
/**
|
||||
|
@ -293,27 +293,28 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
|
||||
}
|
||||
|
||||
|
||||
void LyXFunc::processKeySym(KeySymbolPtr keysym, key_modifier::state state)
|
||||
void LyXFunc::processKeySym(KeySymbol const & keysym,
|
||||
key_modifier::state state)
|
||||
{
|
||||
LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;
|
||||
LYXERR(Debug::KEY) << "KeySym is " << keysym.getSymbolName() << endl;
|
||||
|
||||
// Do nothing if we have nothing (JMarc)
|
||||
if (!keysym->isOK()) {
|
||||
if (!keysym.isOK()) {
|
||||
LYXERR(Debug::KEY) << "Empty kbd action (probably composing)"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (keysym->isModifier()) {
|
||||
if (keysym.isModifier()) {
|
||||
LYXERR(Debug::KEY) << "isModifier true" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//Encoding const * encoding = view()->cursor().getEncoding();
|
||||
//encoded_last_key = keysym->getISOEncoded(encoding ? encoding->name() : "");
|
||||
//encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
|
||||
// FIXME: encoded_last_key shadows the member variable of the same
|
||||
// name. Is that intended?
|
||||
char_type encoded_last_key = keysym->getUCSEncoded();
|
||||
char_type encoded_last_key = keysym.getUCSEncoded();
|
||||
|
||||
// Do a one-deep top-level lookup for
|
||||
// cancel and meta-fake keys. RVDK_PATCH_5
|
||||
@ -371,7 +372,7 @@ void LyXFunc::processKeySym(KeySymbolPtr keysym, key_modifier::state state)
|
||||
// Hmm, we didn't match any of the keysequences. See
|
||||
// if it's normal insertable text not already covered
|
||||
// by a binding
|
||||
if (keysym->isText() && keyseq->length() == 1) {
|
||||
if (keysym.isText() && keyseq->length() == 1) {
|
||||
LYXERR(Debug::KEY) << "isText() is true, inserting." << endl;
|
||||
func = FuncRequest(LFUN_SELF_INSERT,
|
||||
FuncRequest::KEYBOARD);
|
||||
@ -804,7 +805,7 @@ void showPrintError(string const & name)
|
||||
}
|
||||
|
||||
|
||||
void loadTextclass(string const & name)
|
||||
void loadTextClass(string const & name)
|
||||
{
|
||||
std::pair<bool, textclass_type> const tc_pair =
|
||||
textclasslist.numberOfClass(name);
|
||||
@ -1813,7 +1814,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
Buffer * buffer = lyx_view_->buffer();
|
||||
|
||||
loadTextclass(argument);
|
||||
loadTextClass(argument);
|
||||
|
||||
std::pair<bool, textclass_type> const tc_pair =
|
||||
textclasslist.numberOfClass(argument);
|
||||
@ -1850,7 +1851,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_TEXTCLASS_LOAD:
|
||||
loadTextclass(argument);
|
||||
loadTextClass(argument);
|
||||
break;
|
||||
|
||||
case LFUN_LYXRC_APPLY: {
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
docstring const viewStatusMessage();
|
||||
|
||||
///
|
||||
void processKeySym(KeySymbolPtr key, key_modifier::state state);
|
||||
void processKeySym(KeySymbol const & key, key_modifier::state state);
|
||||
|
||||
///
|
||||
FuncStatus getStatus(FuncRequest const & action) const;
|
||||
|
@ -18,65 +18,64 @@
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/**
|
||||
* This is a base class for representing a keypress.
|
||||
* Each frontend has to implement this to provide
|
||||
* the functionality that LyX needs in regards to
|
||||
* key presses.
|
||||
* This is a class representing a keypress.
|
||||
*/
|
||||
class KeySymbol {
|
||||
class KeySymbol
|
||||
{
|
||||
public:
|
||||
KeySymbol() {}
|
||||
|
||||
virtual ~KeySymbol() {}
|
||||
KeySymbol() : key_(0) {}
|
||||
|
||||
///
|
||||
virtual bool operator==(KeySymbol const& ks) const = 0;
|
||||
bool operator==(KeySymbol const & ks) const;
|
||||
|
||||
/// Initialize with the name of a key. F. ex. "space" or "a"
|
||||
virtual void init(std::string const & symbolname) = 0;
|
||||
void init(std::string const & symbolname);
|
||||
|
||||
/// Is this a valid key?
|
||||
virtual bool isOK() const = 0;
|
||||
bool isOK() const;
|
||||
|
||||
/// Is this a modifier key only?
|
||||
virtual bool isModifier() const = 0;
|
||||
bool isModifier() const;
|
||||
|
||||
/// Is this normal insertable text ? (last ditch attempt only)
|
||||
virtual bool isText() const = 0;
|
||||
bool isText() const;
|
||||
|
||||
/// What is the symbolic name of this key? F.ex. "Return" or "c"
|
||||
virtual std::string getSymbolName() const = 0;
|
||||
std::string getSymbolName() const;
|
||||
|
||||
/**
|
||||
* Return the value of the keysym into the UCS-4 encoding.
|
||||
* This converts the KeySymbol to a 32-bit encoded character.
|
||||
*/
|
||||
virtual char_type getUCSEncoded() const = 0;
|
||||
char_type getUCSEncoded() const;
|
||||
|
||||
/**
|
||||
* Return a string describing the KeySym with modifier mod.
|
||||
* Use the native UI format when \c forgui is true.
|
||||
* i.e. (translated and with special characters for Mac OS X)
|
||||
*/
|
||||
virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
|
||||
docstring const print(key_modifier::state mod, bool forgui) const;
|
||||
|
||||
///
|
||||
int key() const { return key_; }
|
||||
///
|
||||
void setKey(int key) { key_ = key; }
|
||||
///
|
||||
docstring text() const { return text_; }
|
||||
///
|
||||
void setText(docstring const & text) { text_ = text; }
|
||||
private:
|
||||
/// some platform specific sym value
|
||||
int key_;
|
||||
/// the event string value
|
||||
docstring text_;
|
||||
};
|
||||
|
||||
|
||||
typedef boost::shared_ptr<KeySymbol> KeySymbolPtr;
|
||||
|
||||
|
||||
/**
|
||||
* Make a KeySymbol. Used because we want to
|
||||
* generate a toolkit-specific instance.
|
||||
*/
|
||||
KeySymbol * createKeySymbol();
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "debug.h"
|
||||
#include "Font.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "KeySymbol.h"
|
||||
#include "Language.h"
|
||||
#include "LyXFunc.h"
|
||||
#include "LyXRC.h"
|
||||
@ -170,7 +171,7 @@ void WorkArea::redraw()
|
||||
}
|
||||
|
||||
|
||||
void WorkArea::processKeySym(KeySymbolPtr key, key_modifier::state state)
|
||||
void WorkArea::processKeySym(KeySymbol const & key, key_modifier::state state)
|
||||
{
|
||||
// In order to avoid bad surprise in the middle of an operation, we better stop
|
||||
// the blinking cursor.
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define BASE_WORKAREA_H
|
||||
|
||||
#include "frontends/key_state.h"
|
||||
#include "frontends/KeySymbol.h"
|
||||
|
||||
#include "support/Timeout.h"
|
||||
#include "support/docstring.h"
|
||||
@ -25,9 +24,11 @@
|
||||
#undef CursorShape
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
class FuncRequest;
|
||||
class KeySymbol;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -97,7 +98,7 @@ public:
|
||||
|
||||
/// Process Key pressed event.
|
||||
/// This needs to be public because it is accessed externally by GuiView.
|
||||
void processKeySym(KeySymbolPtr key, key_modifier::state state);
|
||||
void processKeySym(KeySymbol const & key, key_modifier::state state);
|
||||
|
||||
protected:
|
||||
/// cause the display of the given area of the work area
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "frontends/KeySymbol.h"
|
||||
|
||||
#include "GuiKeySymbol.h"
|
||||
#include "KeySymbol.h"
|
||||
|
||||
#include "qlkey.h"
|
||||
#include "qt_helpers.h"
|
||||
@ -43,12 +43,6 @@ using lyx::support::contains;
|
||||
using lyx::support::getEnv;
|
||||
|
||||
|
||||
KeySymbol * createKeySymbol()
|
||||
{
|
||||
return new GuiKeySymbol;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
char encode(string const & encoding, QString const & str)
|
||||
@ -85,42 +79,39 @@ char encode(string const & encoding, QString const & str)
|
||||
|
||||
} // anon namespace
|
||||
|
||||
GuiKeySymbol::GuiKeySymbol()
|
||||
: KeySymbol(), key_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GuiKeySymbol::set(QKeyEvent * ev)
|
||||
void setKeySymbol(KeySymbol * sym, QKeyEvent * ev)
|
||||
{
|
||||
key_ = ev->key();
|
||||
sym->setKey(ev->key());
|
||||
if (ev->text().isNull()) {
|
||||
LYXERR(Debug::KEY) << "keyevent has isNull() text !" << endl;
|
||||
text_ = "";
|
||||
sym->setText(docstring());
|
||||
return;
|
||||
}
|
||||
text_ = ev->text();
|
||||
LYXERR(Debug::KEY) << "Setting key to " << key_ << ", " << fromqstr(text_) << endl;
|
||||
sym->setText(qstring_to_ucs4(ev->text()));
|
||||
LYXERR(Debug::KEY) << "Setting key to " << sym->key() << ", "
|
||||
<< to_utf8(sym->text()) << endl;
|
||||
}
|
||||
|
||||
|
||||
void GuiKeySymbol::init(string const & symbolname)
|
||||
void KeySymbol::init(string const & symbolname)
|
||||
{
|
||||
key_ = string_to_qkey(symbolname);
|
||||
text_ = toqstr(symbolname);
|
||||
LYXERR(Debug::KEY) << "Init key to " << key_ << ", " << fromqstr(text_) << endl;
|
||||
text_ = from_utf8(symbolname);
|
||||
LYXERR(Debug::KEY) << "Init key to " << key_ << ", "
|
||||
<< to_utf8(text_) << endl;
|
||||
}
|
||||
|
||||
|
||||
bool GuiKeySymbol::isOK() const
|
||||
bool KeySymbol::isOK() const
|
||||
{
|
||||
bool const ok = !(text_.isEmpty() && key_ == Qt::Key_unknown);
|
||||
bool const ok = !(text_.empty() && key_ == Qt::Key_unknown);
|
||||
LYXERR(Debug::KEY) << "isOK is " << ok << endl;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool GuiKeySymbol::isModifier() const
|
||||
bool KeySymbol::isModifier() const
|
||||
{
|
||||
bool const mod = q_is_modifier(key_);
|
||||
LYXERR(Debug::KEY) << "isMod is " << mod << endl;
|
||||
@ -128,21 +119,21 @@ bool GuiKeySymbol::isModifier() const
|
||||
}
|
||||
|
||||
|
||||
string GuiKeySymbol::getSymbolName() const
|
||||
string KeySymbol::getSymbolName() const
|
||||
{
|
||||
string sym = qkey_to_string(key_);
|
||||
string name = qkey_to_string(key_);
|
||||
|
||||
// e.g. A-Za-z, and others
|
||||
if (sym.empty())
|
||||
sym = fromqstr(text_);
|
||||
if (name.empty())
|
||||
name = to_utf8(text_);
|
||||
|
||||
return sym;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
char_type GuiKeySymbol::getUCSEncoded() const
|
||||
char_type KeySymbol::getUCSEncoded() const
|
||||
{
|
||||
if (text_.isEmpty())
|
||||
if (text_.empty())
|
||||
return 0;
|
||||
|
||||
// UTF16 has a maximum of two characters.
|
||||
@ -150,20 +141,18 @@ char_type GuiKeySymbol::getUCSEncoded() const
|
||||
|
||||
if (lyxerr.debugging() && text_.size() > 1) {
|
||||
// We don't know yet how well support the full ucs4 range.
|
||||
LYXERR(Debug::KEY) << "GuiKeySymbol::getUCSEncoded()" << endl;
|
||||
for (int i = 0; i < text_.size(); ++i) {
|
||||
LYXERR(Debug::KEY) << "KeySymbol::getUCSEncoded()" << endl;
|
||||
for (int i = 0; i != int(text_.size()); ++i) {
|
||||
LYXERR(Debug::KEY) << "char " << i << ": "
|
||||
<< text_[i].unicode() << endl;
|
||||
<< int(text_[i]) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Only one UCS4 character at the end.
|
||||
docstring ucs4_text = qstring_to_ucs4(text_);
|
||||
return ucs4_text[0];
|
||||
return text_[0];
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiKeySymbol::print(key_modifier::state mod, bool forgui) const
|
||||
docstring const KeySymbol::print(key_modifier::state mod, bool forgui) const
|
||||
{
|
||||
int tmpkey = key_;
|
||||
|
||||
@ -181,28 +170,23 @@ docstring const GuiKeySymbol::print(key_modifier::state mod, bool forgui) const
|
||||
}
|
||||
|
||||
|
||||
bool GuiKeySymbol::isText() const
|
||||
bool KeySymbol::isText() const
|
||||
{
|
||||
if (text_.isEmpty()) {
|
||||
LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (!text_.empty())
|
||||
return true;
|
||||
LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool GuiKeySymbol::operator==(KeySymbol const & ks) const
|
||||
bool KeySymbol::operator==(KeySymbol const & ks) const
|
||||
{
|
||||
GuiKeySymbol const & qks = static_cast<GuiKeySymbol const &>(ks);
|
||||
|
||||
// we do not have enough info for a fair comparison, so return
|
||||
// false. This works out OK because unknown text from Qt will
|
||||
// get inserted anyway after the isText() check
|
||||
if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
|
||||
if (key_ == Qt::Key_unknown || ks.key_ == Qt::Key_unknown)
|
||||
return false;
|
||||
|
||||
return key_ == qks.key_;
|
||||
return key_ == ks.key_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,69 +15,12 @@
|
||||
|
||||
#include "frontends/KeySymbol.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QKeyEvent;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/**
|
||||
* Qt-specific key press.
|
||||
*
|
||||
* This is some really sick stuff.
|
||||
*/
|
||||
class GuiKeySymbol : public KeySymbol
|
||||
{
|
||||
public:
|
||||
GuiKeySymbol();
|
||||
|
||||
virtual ~GuiKeySymbol() {}
|
||||
|
||||
/// .
|
||||
/// inlined out because of profiling results under linux when
|
||||
/// opening a document.
|
||||
inline bool operator==(KeySymbol const& ks) const;
|
||||
|
||||
/// delayed constructor
|
||||
void set(QKeyEvent * ev);
|
||||
|
||||
/// set from a LyX symbolic name
|
||||
virtual void init(std::string const & symbolname);
|
||||
|
||||
/// Is this a valid key?
|
||||
virtual bool isOK() const;
|
||||
|
||||
/// Is this a modifier key only?
|
||||
virtual bool isModifier() const;
|
||||
|
||||
/// return the LyX symbolic name
|
||||
virtual std::string getSymbolName() const;
|
||||
|
||||
/// Is this normal insertable text ? (last ditch attempt only)
|
||||
virtual bool isText() const;
|
||||
|
||||
/**
|
||||
* Return the value of the keysym into the UCS-4 encoding.
|
||||
* This converts the KeySymbol to a 32-bit encoded character.
|
||||
*/
|
||||
virtual char_type getUCSEncoded() const;
|
||||
|
||||
/**
|
||||
* Return a human-readable version of a key+modifier pair.
|
||||
* This will be the GUI version (translated and with special
|
||||
* characters for Mac OS X) when \c forgui is true.
|
||||
*/
|
||||
virtual docstring const print(key_modifier::state mod, bool forgui) const;
|
||||
|
||||
///
|
||||
int key() const { return key_; }
|
||||
|
||||
private:
|
||||
/// the Qt sym value
|
||||
int key_;
|
||||
/// the event string value
|
||||
QString text_;
|
||||
};
|
||||
/// delayed constructor
|
||||
void setKeySymbol(KeySymbol * sym, QKeyEvent * ev);
|
||||
|
||||
/// return the LyX key state from Qt's
|
||||
key_modifier::state q_key_state(Qt::KeyboardModifiers state);
|
||||
|
@ -63,8 +63,6 @@
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
@ -722,15 +720,15 @@ bool GuiViewBase::event(QEvent * e)
|
||||
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
|
||||
if (d.tab_widget_->count() == 0) {
|
||||
theLyXFunc().setLyXView(this);
|
||||
boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
|
||||
sym->set(ke);
|
||||
KeySymbol sym;
|
||||
setKeySymbol(&sym, ke);
|
||||
theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
|
||||
e->accept();
|
||||
return true;
|
||||
}
|
||||
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
|
||||
boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
|
||||
sym->set(ke);
|
||||
KeySymbol sym;
|
||||
setKeySymbol(&sym, ke);
|
||||
currentWorkArea()->processKeySym(sym, key_modifier::none);
|
||||
e->accept();
|
||||
return true;
|
||||
|
@ -407,32 +407,32 @@ void GuiWorkArea::generateSyntheticMouseEvent()
|
||||
}
|
||||
|
||||
|
||||
void GuiWorkArea::keyPressEvent(QKeyEvent * e)
|
||||
void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
|
||||
{
|
||||
// do nothing if there are other events
|
||||
// (the auto repeated events come too fast)
|
||||
// \todo FIXME: remove hard coded Qt keys, process the key binding
|
||||
#ifdef Q_WS_X11
|
||||
if (XEventsQueued(QX11Info::display(), 0) > 1 && e->isAutoRepeat()
|
||||
if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
|
||||
&& (Qt::Key_PageDown || Qt::Key_PageUp)) {
|
||||
LYXERR(Debug::KEY)
|
||||
<< BOOST_CURRENT_FUNCTION << endl
|
||||
<< "system is busy: scroll key event ignored" << endl;
|
||||
e->ignore();
|
||||
ev->ignore();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
|
||||
<< " count=" << e->count()
|
||||
<< " text=" << fromqstr(e->text())
|
||||
<< " isAutoRepeat=" << e->isAutoRepeat()
|
||||
<< " key=" << e->key()
|
||||
<< " count=" << ev->count()
|
||||
<< " text=" << fromqstr(ev->text())
|
||||
<< " isAutoRepeat=" << ev->isAutoRepeat()
|
||||
<< " key=" << ev->key()
|
||||
<< endl;
|
||||
|
||||
boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
|
||||
sym->set(e);
|
||||
processKeySym(sym, q_key_state(e->modifiers()));
|
||||
KeySymbol sym;
|
||||
setKeySymbol(&sym, ev);
|
||||
processKeySym(sym, q_key_state(ev->modifiers()));
|
||||
}
|
||||
|
||||
|
||||
@ -442,14 +442,14 @@ void GuiWorkArea::doubleClickTimeout()
|
||||
}
|
||||
|
||||
|
||||
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
||||
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * ev)
|
||||
{
|
||||
dc_event_ = double_click(e);
|
||||
dc_event_ = double_click(ev);
|
||||
QTimer::singleShot(QApplication::doubleClickInterval(), this,
|
||||
SLOT(doubleClickTimeout()));
|
||||
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
|
||||
e->x(), e->y(),
|
||||
q_button_state(e->button()));
|
||||
ev->x(), ev->y(),
|
||||
q_button_state(ev->button()));
|
||||
dispatch(cmd);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user