17class GlobalCommandController;
18class EventDistributor;
25 bool repeat_ =
false,
bool passEvent_ =
false)
43 void loadBind(std::string_view key, std::string_view cmd,
bool repeat,
bool event);
46 template<
typename XmlStream>
49 xml.begin(
"bindings");
51 for (
const auto& k : boundKeys) {
56 xml.attribute(
"repeat",
"true");
59 xml.attribute(
"event",
"true");
61 xml.data(info.command);
65 for (
const auto& k : unboundKeys) {
79 void initDefaultBindings();
80 void bind (HotKeyInfo&& info);
81 void unbind (
const Event& event);
82 void bindDefault (HotKeyInfo&& info);
83 void unbindDefault(
const Event& event);
84 void bindLayer (HotKeyInfo&& info,
const std::string& layer);
85 void unbindLayer (
const Event& event,
const std::string& layer);
86 void unbindFullLayer(
const std::string& layer);
87 void activateLayer (std::string layer,
bool blocking);
88 void deactivateLayer(std::string_view layer);
90 int executeEvent(
const Event& event);
91 void executeBinding(
const Event& event,
const HotKeyInfo& info);
92 void startRepeat (
const Event& event);
96 int signalEvent(
const Event& event)
override;
98 void executeRT()
override;
101 class BindCmd final :
public Command {
103 BindCmd(CommandController& commandController,
HotKey& hotKey,
105 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
106 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
109 const bool defaultCmd;
112 BindCmd bindDefaultCmd;
114 class UnbindCmd final :
public Command {
116 UnbindCmd(CommandController& commandController,
HotKey& hotKey,
118 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
119 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
122 const bool defaultCmd;
125 UnbindCmd unbindDefaultCmd;
127 struct ActivateCmd final : Command {
128 explicit ActivateCmd(CommandController& commandController);
129 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
130 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
133 struct DeactivateCmd final : Command {
134 explicit DeactivateCmd(CommandController& commandController);
135 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
136 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
141 std::map<std::string, BindMap> layerMap;
142 std::vector<LayerInfo> activeLayers;
145 GlobalCommandController& commandController;
146 EventDistributor& eventDistributor;
HotKey(RTScheduler &rtScheduler, GlobalCommandController &commandController, EventDistributor &eventDistributor)
void loadUnbind(std::string_view key)
void saveBindings(XmlStream &xml) const
std::vector< HotKeyInfo > BindMap
void loadBind(std::string_view key, std::string_view cmd, bool repeat, bool event)
std::vector< Event > KeySet
This file implemented 3 utility functions:
std::string toString(const Event &event)
Get a string representation of this event.
ITER find_unguarded(ITER first, ITER last, const VAL &val, Proj proj={})
Faster alternative to 'find' when it's guaranteed that the value will be found (if not the behavior i...
HotKeyInfo(Event event_, std::string command_, bool repeat_=false, bool passEvent_=false)
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.