diff libgui/src/m-editor/octave-qscintilla.cc @ 18976:dcb260e7a648

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Fri, 01 Aug 2014 12:10:05 -0400
parents 888f8ce79bbe c6b89c4a9e63
children
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Thu Jul 31 15:49:21 2014 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Fri Aug 01 12:10:05 2014 -0400
@@ -98,6 +98,36 @@
         }
     }
 #endif
+
+#if defined (Q_OS_MAC)
+  // Octave interprets Cmd key as Meta whereas Qscintilla interprets it
+  // as Ctrl. We thus invert Meta/Ctrl in Qscintilla's shortcuts list.
+  QList< QsciCommand * > cmd_list_mac = cmd_set->commands ();
+  for (int i = 0; i < cmd_list_mac.length (); i++)
+    {
+      // Primary key 
+      int key = cmd_list_mac.at (i)->key ();
+
+      if (static_cast<int> (key | Qt::META) == key &&
+          static_cast<int> (key | Qt::CTRL) != key)
+        key = (key ^ Qt::META) | Qt::CTRL;
+      else if (static_cast<int> (key | Qt::CTRL) == key)
+        key = (key ^ Qt::CTRL) | Qt::META;
+
+      cmd_list_mac.at (i)->setKey (key);
+
+      // Alternate key
+      key = cmd_list_mac.at (i)->alternateKey ();
+
+      if (static_cast<int> (key | Qt::META) == key &&
+          static_cast<int> (key | Qt::CTRL) != key)
+        key = (key ^ Qt::META) | Qt::CTRL;
+      else if (static_cast<int> (key | Qt::CTRL) == key)
+        key = (key ^ Qt::CTRL) | Qt::META;
+
+      cmd_list_mac.at (i)->setAlternateKey (key);
+    }
+#endif
 }
 
 octave_qscintilla::~octave_qscintilla ()