]> git.lyx.org Git - features.git/commitdiff
key4.diff
authorJohn Levon <levon@movementarian.org>
Thu, 12 Dec 2002 13:46:06 +0000 (13:46 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 12 Dec 2002 13:46:06 +0000 (13:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5808 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/ChangeLog
src/frontends/LyXKeySym.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QLyXKeySym.C
src/frontends/qt2/QLyXKeySym.h
src/frontends/qt2/qlkey.h
src/lyxfunc.C

index 40a7dd1c449059d0ead98988047dcd7e0bbe43e1..e1bbdc43b8c435e97e77013df2af49d37d051f21 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-12  John Levon  <levon@movementarian.org>
+
+       * lyxfunc.C: use LyXKeySym->isText() as last-ditch
+         insert. Only remove shift modifier under strict
+         circumstances.
 2002-12-09  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * MenuBackend.C (expandToc): fix crash.
index 6f7b75f4453cbad72232b9a557162f9695b54b76..425adc7e7d5d7adc1e54a6f7fe97d3082ff167c4 100644 (file)
@@ -1,3 +1,7 @@
+2002-12-12  John Levon  <levon@movementarian.org>
+
+       * LyXKeySym.h: add isText()
 2002-12-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * screen.C (fitCursor): remove usleep thingie
index 84b9a869f97a1af8947237df6f0b695613fc38a1..8765b685a06aa88bb374368bca4f94e9db93034e 100644 (file)
@@ -36,6 +36,9 @@ public:
        /// Is this a modifier key only?
        virtual bool isModifier() const = 0;
 
+       /// Is this normal insertable text ? (last ditch attempt only)
+       virtual bool isText() const { return false; }
        /// What is the symbolic name of this key? F.ex. "Return" or "c"
        virtual string getSymbolName() const = 0;
 
index d6dc81d23f311e87ef785b040037e172b4c134c6..fa60d963599c486a4653998d1edca467315ca42f 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-12  John Levon  <levon@movementarian.org>
+
+       * QLyxKeySym.h:
+       * QLyXKeySym.C:
+       * qlkey.h: implement isText() to allow us to insert
+         unrecognised text
 2002-12-11  John Levon  <levon@movementarian.org>
 
        * qfont_loader.h:
index 6d787d5044d29c15e9532dc5aaaf8d7f9d559b18..7e7b160ba952d1a0bf5f4c318049381552e528d4 100644 (file)
@@ -34,6 +34,7 @@ void QLyXKeySym::set(QKeyEvent * ev)
 {
        key_ = ev->key();
        text_ = ev->text();
+       lyxerr[Debug::KEY] << "Setting key to " << key_ << ", " <<  text_.latin1() << endl;
 }
 
 
@@ -41,19 +42,23 @@ void QLyXKeySym::init(string const & symbolname)
 {
        key_ = string_to_qkey(symbolname);
        text_ = symbolname.c_str();
-       lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
+       lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_.latin1() << endl;
 }
 
 
 bool QLyXKeySym::isOK() const
 {
-       return ! key_ == 0;
+       bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
+       lyxerr[Debug::KEY] << "isOK is " << ok << endl;
+       return ok;
 }
 
-
 bool QLyXKeySym::isModifier() const
 {
-       return q_is_modifier(key_);
+       bool const mod(q_is_modifier(key_));
+       lyxerr[Debug::KEY] << "isMod is " << mod << endl;
+       return mod;
 }
 
 
@@ -78,6 +83,20 @@ char QLyXKeySym::getISOEncoded() const
 }
 
 
+bool QLyXKeySym::isText() const
+{
+       if (text_.isEmpty()) {
+               lyxerr[Debug::KEY] << "text_ empty, isText() == false" << endl;
+               return false;
+       }
+
+       QChar const c(text_[0]);
+       lyxerr[Debug::KEY] << "isText for key " << key_ 
+               << " isPrint is " << c.isPrint() << endl;
+       return c.isPrint();
+}
+
 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
 {
        // note we ignore text_ here (non-strict ==), because
index e104b262f9720206966a1c92d0b05645c2cfbcc7..5ee71c405dc7d5a68141ba754e32a0fd5802bc33 100644 (file)
@@ -50,6 +50,9 @@ public:
        /// return the LyX symbolic name
        virtual string getSymbolName() const;
 
+       /// Is this normal insertable text ? (last ditch attempt only)
+       virtual bool isText() const;
        /**
         * Return the value of the keysym into the local ISO encoding.
         * This converts the LyXKeySym to a 8-bit encoded character.
index ba62ad954274b7184a94f4ee217cd1e2ec5b7970..c56909338aca13b5dee5d2fd2334744d707d60c1 100644 (file)
@@ -34,10 +34,6 @@ bool q_is_modifier(int qkey)
                case Qt::Key_Meta:
                case Qt::Key_Alt:
                        return true;
-
-               // AltGr becomes Key_unknown on at least one keyboard
-               case Qt::Key_unknown:
-                       return true;
        }
        return false;
 }
index 179156e15761c28ba5735176425277b9ef40f521..6491f8649ed98b8888d93e3ad29b28986e5489a2 100644 (file)
@@ -171,6 +171,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
        }
 
        if (keysym->isModifier()) {
+               lyxerr[Debug::KEY] << "isModifier true" << endl;
                return;
        }
 
@@ -214,16 +215,24 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                owner->message(keyseq.print());
        }
 
-       if (action == LFUN_UNKNOWN_ACTION) {
-               // It is unknown, but what if we remove all
-               // the modifiers? (Lgb)
+       // Maybe user can only reach the key via holding down shift.
+       // Let's see. But only if shift is the only modifier
+       if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
+               lyxerr[Debug::KEY] << "Trying without shift" << endl;
                action = keyseq.addkey(keysym, key_modifier::none);
-
-               lyxerr[Debug::KEY] << "Removing modifiers...\n"
-                       << "Action now set to ["
-                       << action << ']' << endl;
-
-               if (action == LFUN_UNKNOWN_ACTION) {
+               lyxerr[Debug::KEY] << "Action now " << action << endl;
+       }
+       if (action == LFUN_UNKNOWN_ACTION) {
+               // 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) {
+                       lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
+                       action = LFUN_SELFINSERT;
+               } else {
+                       lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
                        owner->message(_("Unknown function."));
                        return;
                }
@@ -233,6 +242,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                char c = keysym->getISOEncoded();
                string argument;
 
+               // FIXME: why ...
                if (c != 0)
                        argument = c;