# HG changeset patch # User pantxo # Date 1406098362 -7200 # Node ID c6b89c4a9e63d8c65e1a6a1703138b2a6bc9c5a9 # Parent 0be65bd7f369aed9e72f5e1a0e93439076df188e Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217) * octave-qscintilla.cc (octave_qscintilla::octave_qscintilla): under mac platform, manually swap Ctrl an Meta modifers in Qscintilla's shortcut list, in order to conform to octave settings. diff -r 0be65bd7f369 -r c6b89c4a9e63 libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Sun Jul 20 21:23:32 2014 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.cc Wed Jul 23 08:52:42 2014 +0200 @@ -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 (key | Qt::META) == key && + static_cast (key | Qt::CTRL) != key) + key = (key ^ Qt::META) | Qt::CTRL; + else if (static_cast (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 (key | Qt::META) == key && + static_cast (key | Qt::CTRL) != key) + key = (key ^ Qt::META) | Qt::CTRL; + else if (static_cast (key | Qt::CTRL) == key) + key = (key ^ Qt::CTRL) | Qt::META; + + cmd_list_mac.at (i)->setAlternateKey (key); + } +#endif } octave_qscintilla::~octave_qscintilla ()