mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
incomplete key mapping stuff. Introduces some breakage.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4803 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
69862d12f4
commit
fe6aaf3797
@ -1,3 +1,10 @@
|
||||
2002-07-30 John Levon <levon@movementarian.org>
|
||||
|
||||
* qlkey.h:
|
||||
* QLyXKeySym.h:
|
||||
* QLyXKeySym.C: do our own getISOEncoded() mapping
|
||||
because Qt can't handle it
|
||||
|
||||
2002-07-29 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* several file: strip,frontStrip -> trim,ltrim,rtrim
|
||||
|
@ -114,11 +114,8 @@ void QContentPane::mouseMoveEvent(QMouseEvent * e)
|
||||
|
||||
void QContentPane::keyPressEvent(QKeyEvent * e)
|
||||
{
|
||||
char const * tmp = e->text().latin1();
|
||||
string const text = tmp ? tmp : "";
|
||||
lyxerr[Debug::GUI] << "key text " << text << endl;
|
||||
QLyXKeySym * sym = new QLyXKeySym();
|
||||
sym->set(e->key(), e->text());
|
||||
sym->set(e->key(), bool(e->state() & Qt::ShiftButton));
|
||||
wa_->workAreaKeyPress(LyXKeySymPtr(sym), q_key_state(e->state()));
|
||||
}
|
||||
|
||||
|
@ -15,17 +15,18 @@
|
||||
|
||||
#include "QLyXKeySym.h"
|
||||
#include "qlkey.h"
|
||||
#include "debug.h"
|
||||
|
||||
QLyXKeySym::QLyXKeySym()
|
||||
: LyXKeySym(), key_(0), text_("")
|
||||
: LyXKeySym(), key_(0), shift_(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QLyXKeySym::set(int key, QString const & text)
|
||||
void QLyXKeySym::set(int key, bool shift)
|
||||
{
|
||||
key_ = key;
|
||||
text_ = text;
|
||||
shift_ = shift;
|
||||
}
|
||||
|
||||
|
||||
@ -50,16 +51,18 @@ bool QLyXKeySym::isModifier() const
|
||||
|
||||
string QLyXKeySym::getSymbolName() const
|
||||
{
|
||||
return qkey_to_string(key_);
|
||||
return qkey_to_string(key_, shift_);
|
||||
}
|
||||
|
||||
|
||||
char QLyXKeySym::getISOEncoded() const
|
||||
{
|
||||
if (!text_.length())
|
||||
return 0;
|
||||
// FIXME
|
||||
return text_.latin1()[0];
|
||||
/* Even though we could try to use QKeyEvent->text(),
|
||||
* it won't work, because it returns something other
|
||||
* than 'Z' for things like C-S-z. Do not ask me why,
|
||||
* just more Qt bullshit.
|
||||
*/
|
||||
return qkey_to_char(key_, shift_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
#include "LString.h"
|
||||
#include "frontends/LyXKeySym.h"
|
||||
|
||||
#include <qstring.h>
|
||||
|
||||
/**
|
||||
* Qt-specific key press.
|
||||
*
|
||||
* This is some really sick stuff.
|
||||
*/
|
||||
class QLyXKeySym : public LyXKeySym {
|
||||
public:
|
||||
@ -30,7 +30,7 @@ public:
|
||||
virtual ~QLyXKeySym() {}
|
||||
|
||||
/// delayed constructor
|
||||
void set(int key, QString const & text);
|
||||
void set(int key, bool shift);
|
||||
|
||||
/// set from a LyX symbolic name
|
||||
virtual void init(string const & symbolname);
|
||||
@ -56,13 +56,8 @@ public:
|
||||
private:
|
||||
/// the Qt sym value
|
||||
int key_;
|
||||
|
||||
/**
|
||||
* The generated text from the symbol. This will only be
|
||||
* filled when the QLyXKeySym is used to pass a key press
|
||||
* event, not when stored in a kbsequence etc.
|
||||
*/
|
||||
QString text_;
|
||||
/// shift held or not
|
||||
bool shift_;
|
||||
};
|
||||
|
||||
#endif // QLYXKEYSYM_H
|
||||
|
@ -12,7 +12,8 @@ then remember to call form_->changed() at the end (if it has changed !)
|
||||
Every non-trivial widget should have a tooltip. If you don't know
|
||||
what to write, write "FIXME", and it can fixed later. Don't be afraid
|
||||
to use QWhatsThis too, but this must be done in the derived class's
|
||||
constructor, and use _("...").
|
||||
constructor, and use _("..."). Non-trivial means that things like "OK"
|
||||
/must not/ have a tooltip.
|
||||
|
||||
If necessary, you should override Qt2Base::isValid() for determining the validity
|
||||
of the current dialog's contents.
|
||||
|
@ -16,9 +16,18 @@
|
||||
|
||||
#include <qsocketnotifier.h>
|
||||
|
||||
/**
|
||||
* io_callback - a simple wrapper for asynchronous pipe notification
|
||||
*
|
||||
* This is used by the lyxserver to notice the pipe is ready to be
|
||||
* read.
|
||||
*
|
||||
* FIXME: this code apparently will not work on Windows.
|
||||
*/
|
||||
class io_callback : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/// connect a read ready notification for fd to the LyXComm
|
||||
io_callback(int fd, LyXComm * comm)
|
||||
: comm_(comm) {
|
||||
QSocketNotifier * sn = new QSocketNotifier(fd,
|
||||
|
@ -274,12 +274,12 @@ int string_to_qkey(string const & str)
|
||||
|
||||
|
||||
/**
|
||||
* q_to_lkey - convert Qt keypress into LyX
|
||||
* qkey_t_string - convert Qt keypress into LyX
|
||||
*
|
||||
* Convert the Qt keypress into a string understandable
|
||||
* by the LyX core (same as XKeysymToString)
|
||||
*/
|
||||
string const qkey_to_string(int lkey)
|
||||
string const qkey_to_string(int lkey, bool shift)
|
||||
{
|
||||
switch (lkey) {
|
||||
case Qt::Key_Escape: return "Escape";
|
||||
@ -359,32 +359,32 @@ string const qkey_to_string(int lkey)
|
||||
case Qt::Key_Greater: return "greater";
|
||||
case Qt::Key_Question: return "question";
|
||||
case Qt::Key_At: return "at";
|
||||
case Qt::Key_A: return "a";
|
||||
case Qt::Key_B: return "b";
|
||||
case Qt::Key_C: return "c";
|
||||
case Qt::Key_D: return "d";
|
||||
case Qt::Key_E: return "e";
|
||||
case Qt::Key_F: return "f";
|
||||
case Qt::Key_G: return "g";
|
||||
case Qt::Key_H: return "h";
|
||||
case Qt::Key_I: return "i";
|
||||
case Qt::Key_J: return "j";
|
||||
case Qt::Key_K: return "k";
|
||||
case Qt::Key_L: return "l";
|
||||
case Qt::Key_M: return "m";
|
||||
case Qt::Key_N: return "n";
|
||||
case Qt::Key_O: return "o";
|
||||
case Qt::Key_P: return "p";
|
||||
case Qt::Key_Q: return "q";
|
||||
case Qt::Key_R: return "r";
|
||||
case Qt::Key_S: return "s";
|
||||
case Qt::Key_T: return "t";
|
||||
case Qt::Key_U: return "u";
|
||||
case Qt::Key_V: return "v";
|
||||
case Qt::Key_W: return "w";
|
||||
case Qt::Key_X: return "x";
|
||||
case Qt::Key_Y: return "y";
|
||||
case Qt::Key_Z: return "z";
|
||||
case Qt::Key_A: return shift ? "A" : "a";
|
||||
case Qt::Key_B: return shift ? "B" : "b";
|
||||
case Qt::Key_C: return shift ? "C" : "c";
|
||||
case Qt::Key_D: return shift ? "D" : "d";
|
||||
case Qt::Key_E: return shift ? "E" : "e";
|
||||
case Qt::Key_F: return shift ? "F" : "f";
|
||||
case Qt::Key_G: return shift ? "G" : "g";
|
||||
case Qt::Key_H: return shift ? "H" : "h";
|
||||
case Qt::Key_I: return shift ? "I" : "i";
|
||||
case Qt::Key_J: return shift ? "J" : "j";
|
||||
case Qt::Key_K: return shift ? "K" : "k";
|
||||
case Qt::Key_L: return shift ? "L" : "l";
|
||||
case Qt::Key_M: return shift ? "M" : "m";
|
||||
case Qt::Key_N: return shift ? "N" : "n";
|
||||
case Qt::Key_O: return shift ? "O" : "o";
|
||||
case Qt::Key_P: return shift ? "P" : "p";
|
||||
case Qt::Key_Q: return shift ? "Q" : "q";
|
||||
case Qt::Key_R: return shift ? "R" : "r";
|
||||
case Qt::Key_S: return shift ? "S" : "s";
|
||||
case Qt::Key_T: return shift ? "T" : "t";
|
||||
case Qt::Key_U: return shift ? "U" : "u";
|
||||
case Qt::Key_V: return shift ? "V" : "v";
|
||||
case Qt::Key_W: return shift ? "W" : "w";
|
||||
case Qt::Key_X: return shift ? "X" : "x";
|
||||
case Qt::Key_Y: return shift ? "Y" : "y";
|
||||
case Qt::Key_Z: return shift ? "Z" : "z";
|
||||
case Qt::Key_BracketLeft: return "bracketleft";
|
||||
case Qt::Key_Backslash: return "backslash";
|
||||
case Qt::Key_BracketRight: return "bracketright";
|
||||
@ -523,4 +523,56 @@ string const qkey_to_string(int lkey)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* qkey_to_char - convert keypress into char
|
||||
*
|
||||
* Convert the Qt keypress into a iso8859-1 char that
|
||||
* represents it.
|
||||
*
|
||||
* FIXME: this is where all the encoding stuff
|
||||
* sits, I suppose. I have shit all idea what
|
||||
* to do. Help !
|
||||
*/
|
||||
char const qkey_to_char(int lkey, bool shift)
|
||||
{
|
||||
// We are relying on Qt internals here, but it's
|
||||
// not likely to change anyway.
|
||||
if (lkey >= 0x1000)
|
||||
return 0;
|
||||
|
||||
switch (lkey) {
|
||||
case Qt::Key_A: return shift ? 'A' : 'a';
|
||||
case Qt::Key_B: return shift ? 'B' : 'b';
|
||||
case Qt::Key_C: return shift ? 'C' : 'c';
|
||||
case Qt::Key_D: return shift ? 'D' : 'd';
|
||||
case Qt::Key_E: return shift ? 'E' : 'e';
|
||||
case Qt::Key_F: return shift ? 'F' : 'f';
|
||||
case Qt::Key_G: return shift ? 'G' : 'g';
|
||||
case Qt::Key_H: return shift ? 'H' : 'h';
|
||||
case Qt::Key_I: return shift ? 'I' : 'i';
|
||||
case Qt::Key_J: return shift ? 'J' : 'j';
|
||||
case Qt::Key_K: return shift ? 'K' : 'k';
|
||||
case Qt::Key_L: return shift ? 'L' : 'l';
|
||||
case Qt::Key_M: return shift ? 'M' : 'm';
|
||||
case Qt::Key_N: return shift ? 'N' : 'n';
|
||||
case Qt::Key_O: return shift ? 'O' : 'o';
|
||||
case Qt::Key_P: return shift ? 'P' : 'p';
|
||||
case Qt::Key_Q: return shift ? 'Q' : 'q';
|
||||
case Qt::Key_R: return shift ? 'R' : 'r';
|
||||
case Qt::Key_S: return shift ? 'S' : 's';
|
||||
case Qt::Key_T: return shift ? 'T' : 't';
|
||||
case Qt::Key_U: return shift ? 'U' : 'u';
|
||||
case Qt::Key_V: return shift ? 'V' : 'v';
|
||||
case Qt::Key_W: return shift ? 'W' : 'w';
|
||||
case Qt::Key_X: return shift ? 'X' : 'x';
|
||||
case Qt::Key_Y: return shift ? 'Y' : 'y';
|
||||
case Qt::Key_Z: return shift ? 'Z' : 'z';
|
||||
default:
|
||||
return lkey;
|
||||
}
|
||||
|
||||
// FIXME: CapsLock ignored.
|
||||
// FIXME: all things like é are screwed too. I LOVE Qt. I REALLY DO.
|
||||
}
|
||||
|
||||
#endif // QLKEY_H
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
/// our owning widget
|
||||
QWorkArea & owner_;
|
||||
|
||||
/// the mini-pixmap used for backing store for the blinking caret
|
||||
/// the mini-pixmap used for backing store for the blinking cursor
|
||||
boost::scoped_ptr<QPixmap> nocursor_pixmap_;
|
||||
|
||||
//{@ the cursor pixmap position/size
|
||||
@ -73,7 +73,7 @@ private:
|
||||
int cursor_y_;
|
||||
int cursor_w_;
|
||||
int cursor_h_;
|
||||
//@}
|
||||
//@}
|
||||
};
|
||||
|
||||
#endif // QSCREEN_H
|
||||
|
Loading…
Reference in New Issue
Block a user