Merge pull request #3991 from techee/hacking_patch
[geany-mirror.git] / scintilla / src / KeyMap.h
blob673f381f4484526c5e001d8852c610114ec822bd
1 // Scintilla source code edit control
2 /** @file KeyMap.h
3 ** Defines a mapping between keystrokes and commands.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef KEYMAP_H
9 #define KEYMAP_H
11 namespace Scintilla::Internal {
13 #define SCI_NORM KeyMod::Norm
14 #define SCI_SHIFT KeyMod::Shift
15 #define SCI_CTRL KeyMod::Ctrl
16 #define SCI_ALT KeyMod::Alt
17 #define SCI_META KeyMod::Meta
18 #define SCI_SUPER KeyMod::Super
19 #define SCI_CSHIFT (KeyMod::Ctrl | KeyMod::Shift)
20 #define SCI_ASHIFT (KeyMod::Alt | KeyMod::Shift)
22 /**
24 class KeyModifiers {
25 public:
26 Scintilla::Keys key;
27 Scintilla::KeyMod modifiers;
28 KeyModifiers() noexcept : key{}, modifiers(KeyMod::Norm) {
30 KeyModifiers(Scintilla::Keys key_, Scintilla::KeyMod modifiers_) noexcept : key(key_), modifiers(modifiers_) {
32 bool operator<(const KeyModifiers &other) const noexcept {
33 if (key == other.key)
34 return modifiers < other.modifiers;
35 else
36 return key < other.key;
40 /**
42 class KeyToCommand {
43 public:
44 Scintilla::Keys key;
45 Scintilla::KeyMod modifiers;
46 Scintilla::Message msg;
49 /**
51 class KeyMap {
52 std::map<KeyModifiers, Scintilla::Message> kmap;
53 static const KeyToCommand MapDefault[];
55 public:
56 KeyMap();
57 void Clear() noexcept;
58 void AssignCmdKey(Scintilla::Keys key, Scintilla::KeyMod modifiers, Scintilla::Message msg);
59 Scintilla::Message Find(Scintilla::Keys key, Scintilla::KeyMod modifiers) const; // 0 returned on failure
60 const std::map<KeyModifiers, Scintilla::Message> &GetKeyMap() const noexcept;
65 #endif