]> git.lyx.org Git - lyx.git/blobdiff - src/KeySequence.cpp
Hack to display section symbol
[lyx.git] / src / KeySequence.cpp
index a2aac20519a5f1efccf62dbb5c946ec03e9bfd54..c0985b78b9b75d8f252437812a307798ad89cbc9 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Jean-Marc Lasgouttes
  * \author John Levon
  *
 #include <config.h>
 
 #include "KeySequence.h"
-
-#include "gettext.h"
 #include "KeyMap.h"
-#include "lfuns.h"
-
-#include "frontends/KeySymbol.h"
 
-using std::make_pair;
-using std::string;
+#include "support/gettext.h"
 
+using namespace std;
 
 namespace lyx {
 
@@ -40,12 +35,10 @@ FuncRequest const & KeySequence::addkey(KeySymbol const & key,
        modifiers.push_back(make_pair(mod, nmod));
        sequence.push_back(key);
 
-       if (curmap) {
+       if (curmap)
                return curmap->lookup(key, mod, this);
-       }
 
-       static FuncRequest unknown(LFUN_UNKNOWN_ACTION);
-       return unknown;
+       return FuncRequest::unknown;
 }
 
 
@@ -75,6 +68,12 @@ size_t KeySequence::parse(string const & s)
                                i += 2;
                                continue;
                        case 'm': case 'M':
+#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
+                               mod |= MetaModifier;
+                               i += 2;
+                               continue;
+#endif
+                       case 'a': case 'A':
                                mod |= AltModifier;
                                i += 2;
                                continue;
@@ -93,6 +92,12 @@ size_t KeySequence::parse(string const & s)
                                i += 3;
                                continue;
                        case 'm': case 'M':
+#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
+                               nmod |= MetaModifier;
+                               i += 3;
+                               continue;
+#endif
+                       case 'a': case 'A':
                                nmod |= AltModifier;
                                i += 3;
                                continue;
@@ -118,8 +123,7 @@ size_t KeySequence::parse(string const & s)
                }
        }
 
-       // empty sequence?
-       if (sequence.size() == 0)
+       if (sequence.empty())
                return 0;
 
        // everything is fine
@@ -127,7 +131,7 @@ size_t KeySequence::parse(string const & s)
 }
 
 
-docstring const KeySequence::print(outputFormat format) const
+docstring const KeySequence::print(outputFormat format, bool const untranslated) const
 {
        docstring buf;
 
@@ -136,20 +140,24 @@ docstring const KeySequence::print(outputFormat format) const
        for (size_t i = 0; i != length; ++i) {
                switch (format) {
                case Portable:
-                       buf += sequence[i].print(modifiers[i].first, false);
+                       buf += sequence[i].print(modifiers[i].first, false, untranslated);
                        break;
                case ForGui:
-                       buf += sequence[i].print(modifiers[i].first, true);
+                       buf += sequence[i].print(modifiers[i].first, true, untranslated);
                        break;
                case BindFile:
                        KeyModifier mod = modifiers[i].first;
                        if (mod & ControlModifier)
                                buf += "C-";
                        if (mod & AltModifier)
+#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
+                               buf += "A-";
+                       if (mod & MetaModifier)
+#endif
                                buf += "M-";
                        if (mod & ShiftModifier)
                                buf += "S-";
-               
+
                        buf += from_utf8(sequence[i].getSymbolName());
                        break;
                }
@@ -174,15 +182,9 @@ docstring const KeySequence::printOptions(bool forgui) const
 }
 
 
-void KeySequence::mark_deleted()
-{
-       deleted_ = true;
-}
-
-
 void KeySequence::reset()
 {
-       mark_deleted();
+       deleted_ = true;
        curmap = stdmap;
 }
 
@@ -194,4 +196,15 @@ void KeySequence::clear()
 }
 
 
+void KeySequence::removeKey()
+{
+       if (deleted_)
+               return;
+       sequence.pop_back();
+       modifiers.pop_back();
+       if (sequence.empty())
+               deleted_ = true;
+}
+
+
 } // namespace lyx