2009-04-24 23:35:41 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file KeyMap.h
|
|
|
|
** Defines a mapping between keystrokes and commands.
|
|
|
|
**/
|
|
|
|
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
|
|
|
// The License.txt file describes the conditions under which this software may be distributed.
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
#ifndef KEYMAP_H
|
|
|
|
#define KEYMAP_H
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
namespace Scintilla {
|
|
|
|
|
|
|
|
#define SCI_NORM 0
|
|
|
|
#define SCI_SHIFT SCMOD_SHIFT
|
|
|
|
#define SCI_CTRL SCMOD_CTRL
|
|
|
|
#define SCI_ALT SCMOD_ALT
|
2013-08-28 00:44:27 +00:00
|
|
|
#define SCI_META SCMOD_META
|
2019-05-04 18:14:48 +00:00
|
|
|
#define SCI_SUPER SCMOD_SUPER
|
2009-04-24 23:35:41 +00:00
|
|
|
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
|
|
|
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class KeyModifiers {
|
|
|
|
public:
|
|
|
|
int key;
|
|
|
|
int modifiers;
|
|
|
|
KeyModifiers(int key_, int modifiers_) : key(key_), modifiers(modifiers_) {
|
|
|
|
}
|
|
|
|
bool operator<(const KeyModifiers &other) const {
|
|
|
|
if (key == other.key)
|
|
|
|
return modifiers < other.modifiers;
|
|
|
|
else
|
|
|
|
return key < other.key;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class KeyToCommand {
|
|
|
|
public:
|
|
|
|
int key;
|
|
|
|
int modifiers;
|
|
|
|
unsigned int msg;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class KeyMap {
|
2015-06-07 21:19:26 +00:00
|
|
|
std::map<KeyModifiers, unsigned int> kmap;
|
2009-04-24 23:35:41 +00:00
|
|
|
static const KeyToCommand MapDefault[];
|
|
|
|
|
|
|
|
public:
|
|
|
|
KeyMap();
|
|
|
|
~KeyMap();
|
|
|
|
void Clear();
|
|
|
|
void AssignCmdKey(int key, int modifiers, unsigned int msg);
|
2013-08-28 00:44:27 +00:00
|
|
|
unsigned int Find(int key, int modifiers) const; // 0 returned on failure
|
2019-05-04 18:14:48 +00:00
|
|
|
const std::map<KeyModifiers, unsigned int> &GetKeyMap() const;
|
2009-04-24 23:35:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|