openMSX
HotKey.cc
Go to the documentation of this file.
1 #include "HotKey.hh"
2 #include "InputEventFactory.hh"
4 #include "CommandException.hh"
5 #include "EventDistributor.hh"
6 #include "CliComm.hh"
7 #include "Event.hh"
8 #include "TclArgParser.hh"
9 #include "TclObject.hh"
10 #include "SettingsConfig.hh"
11 #include "one_of.hh"
12 #include "outer.hh"
13 #include "ranges.hh"
14 #include "view.hh"
15 #include "build-info.hh"
16 #include <cassert>
17 #include <memory>
18 
19 using std::string;
20 
21 // This file implements all Tcl key bindings. These are the 'classical' hotkeys
22 // (e.g. F12 to (un)mute sound) and the more recent input layers. The idea
23 // behind an input layer is something like an OSD widget that (temporarily)
24 // takes semi-exclusive access to the input. So while the widget is active
25 // keyboard (and joystick) input is no longer passed to the emulated MSX.
26 // However the classical hotkeys or the openMSX console still receive input.
27 
28 namespace openmsx {
29 
30 constexpr bool META_HOT_KEYS =
31 #ifdef __APPLE__
32  true;
33 #else
34  false;
35 #endif
36 
38  GlobalCommandController& commandController_,
39  EventDistributor& eventDistributor_)
40  : RTSchedulable(rtScheduler)
41  , bindCmd (commandController_, *this, false)
42  , bindDefaultCmd (commandController_, *this, true)
43  , unbindCmd (commandController_, *this, false)
44  , unbindDefaultCmd(commandController_, *this, true)
45  , activateCmd (commandController_)
46  , deactivateCmd (commandController_)
47  , commandController(commandController_)
48  , eventDistributor(eventDistributor_)
49 {
50  initDefaultBindings();
51 
52  eventDistributor.registerEventListener(
54  eventDistributor.registerEventListener(
56  eventDistributor.registerEventListener(
58  eventDistributor.registerEventListener(
60  eventDistributor.registerEventListener(
62  eventDistributor.registerEventListener(
64  eventDistributor.registerEventListener(
66  eventDistributor.registerEventListener(
68  eventDistributor.registerEventListener(
70  eventDistributor.registerEventListener(
72  eventDistributor.registerEventListener(
74  eventDistributor.registerEventListener(
76  eventDistributor.registerEventListener(
78  eventDistributor.registerEventListener(
80 }
81 
83 {
86  eventDistributor.unregisterEventListener(EventType::FILEDROP, *this);
87  eventDistributor.unregisterEventListener(EventType::FOCUS, *this);
88  eventDistributor.unregisterEventListener(EventType::JOY_BUTTON_UP, *this);
89  eventDistributor.unregisterEventListener(EventType::JOY_BUTTON_DOWN, *this);
90  eventDistributor.unregisterEventListener(EventType::JOY_AXIS_MOTION, *this);
91  eventDistributor.unregisterEventListener(EventType::JOY_HAT, *this);
92  eventDistributor.unregisterEventListener(EventType::MOUSE_WHEEL, *this);
93  eventDistributor.unregisterEventListener(EventType::MOUSE_BUTTON_UP, *this);
95  eventDistributor.unregisterEventListener(EventType::MOUSE_MOTION, *this);
96  eventDistributor.unregisterEventListener(EventType::KEY_UP, *this);
97  eventDistributor.unregisterEventListener(EventType::KEY_DOWN, *this);
98 }
99 
100 void HotKey::initDefaultBindings()
101 {
102  // TODO move to Tcl script?
103 
104  if constexpr (META_HOT_KEYS) {
105  // Hot key combos using Mac's Command key.
106  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
108  "screenshot -guess-name"));
109  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
111  "toggle pause"));
112  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
114  "toggle fastforward"));
115  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
117  "toggle console"));
118  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
120  "toggle mute"));
121  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
123  "toggle fullscreen"));
124  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
126  "exit"));
127  } else {
128  // Hot key combos for typical PC keyboards.
129  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_PRINT),
130  "screenshot -guess-name"));
131  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_PAUSE),
132  "toggle pause"));
133  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_F9),
134  "toggle fastforward"));
135  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_F10),
136  "toggle console"));
137  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_F11),
138  "toggle fullscreen"));
139  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_F12),
140  "toggle mute"));
141  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
143  "exit"));
144  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
146  "exit"));
147  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(
149  "toggle fullscreen"));
150  // and for Android
151  bindDefault(HotKeyInfo(Event::create<KeyDownEvent>(Keys::K_BACK),
152  "quitmenu::quit_menu"));
153  }
154 }
155 
156 static Event createEvent(const TclObject& obj, Interpreter& interp)
157 {
158  auto event = InputEventFactory::createInputEvent(obj, interp);
165  EventType::FOCUS)) {
166  throw CommandException("Unsupported event type");
167  }
168  return event;
169 }
170 static Event createEvent(std::string_view str, Interpreter& interp)
171 {
172  return createEvent(TclObject(str), interp);
173 }
174 
176 {
177  // restore default bindings
178  unboundKeys.clear();
179  boundKeys.clear();
180  cmdMap = defaultMap;
181 }
182 
183 void HotKey::loadBind(std::string_view key, std::string_view cmd, bool repeat, bool event)
184 {
185  bind(HotKeyInfo(createEvent(key, commandController.getInterpreter()),
186  std::string(cmd), repeat, event));
187 }
188 
189 void HotKey::loadUnbind(std::string_view key)
190 {
191  unbind(createEvent(key, commandController.getInterpreter()));
192 }
193 
194 struct EqualEvent {
195  EqualEvent(const Event& event_) : event(event_) {}
196  bool operator()(const Event& e) const {
197  return event == e;
198  }
199  bool operator()(const HotKey::HotKeyInfo& info) const {
200  return event == info.event;
201  }
202  const Event& event;
203 };
204 
205 static bool contains(auto&& range, const Event& event)
206 {
207  return ranges::any_of(range, EqualEvent(event));
208 }
209 
210 template<typename T>
211 static void erase(std::vector<T>& v, const Event& event)
212 {
213  if (auto it = ranges::find_if(v, EqualEvent(event)); it != end(v)) {
214  move_pop_back(v, it);
215  }
216 }
217 
218 static void insert(HotKey::KeySet& set, const Event& event)
219 {
220  if (auto it = ranges::find_if(set, EqualEvent(event)); it != end(set)) {
221  *it = event;
222  } else {
223  set.push_back(event);
224  }
225 }
226 
227 template<typename HotKeyInfo>
228 static void insert(HotKey::BindMap& map, HotKeyInfo&& info)
229 {
230  if (auto it = ranges::find_if(map, EqualEvent(info.event)); it != end(map)) {
231  *it = std::forward<HotKeyInfo>(info);
232  } else {
233  map.push_back(std::forward<HotKeyInfo>(info));
234  }
235 }
236 
237 void HotKey::bind(HotKeyInfo&& info)
238 {
239  erase(unboundKeys, info.event);
240  erase(defaultMap, info.event);
241  insert(boundKeys, info.event);
242  insert(cmdMap, std::move(info));
243 }
244 
245 void HotKey::unbind(const Event& event)
246 {
247  if (auto it1 = ranges::find_if(boundKeys, EqualEvent(event));
248  it1 == end(boundKeys)) {
249  // only when not a regular bound event
250  insert(unboundKeys, event);
251  } else {
252  //erase(boundKeys, *event);
253  move_pop_back(boundKeys, it1);
254  }
255 
256  erase(defaultMap, event);
257  erase(cmdMap, event);
258 }
259 
260 void HotKey::bindDefault(HotKeyInfo&& info)
261 {
262  if (!contains( boundKeys, info.event) &&
263  !contains(unboundKeys, info.event)) {
264  // not explicitly bound or unbound
265  insert(cmdMap, info);
266  }
267  insert(defaultMap, std::move(info));
268 }
269 
270 void HotKey::unbindDefault(const Event& event)
271 {
272  if (!contains( boundKeys, event) &&
273  !contains(unboundKeys, event)) {
274  // not explicitly bound or unbound
275  erase(cmdMap, event);
276  }
277  erase(defaultMap, event);
278 }
279 
280 void HotKey::bindLayer(HotKeyInfo&& info, const string& layer)
281 {
282  insert(layerMap[layer], std::move(info));
283 }
284 
285 void HotKey::unbindLayer(const Event& event, const string& layer)
286 {
287  erase(layerMap[layer], event);
288 }
289 
290 void HotKey::unbindFullLayer(const string& layer)
291 {
292  layerMap.erase(layer);
293 }
294 
295 void HotKey::activateLayer(std::string layer, bool blocking)
296 {
297  // Insert new activation record at the end of the list.
298  // (it's not an error if the same layer was already active, in such
299  // as case it will now appear twice in the list of active layer,
300  // and it must also be deactivated twice).
301  activeLayers.push_back({std::move(layer), blocking});
302 }
303 
304 void HotKey::deactivateLayer(std::string_view layer)
305 {
306  // remove the first matching activation record from the end
307  // (it's not an error if there is no match at all)
308  if (auto it = ranges::find(view::reverse(activeLayers), layer, &LayerInfo::layer);
309  it != activeLayers.rend()) {
310  // 'reverse_iterator' -> 'iterator' conversion is a bit tricky
311  activeLayers.erase((it + 1).base());
312  }
313 }
314 
315 static HotKey::BindMap::const_iterator findMatch(
316  const HotKey::BindMap& map, const Event& event)
317 {
318  return ranges::find_if(map, [&](auto& p) {
319  return matches(p.event, event);
320  });
321 }
322 
323 void HotKey::executeRT()
324 {
325  if (lastEvent) executeEvent(lastEvent);
326 }
327 
328 int HotKey::signalEvent(const Event& event) noexcept
329 {
330  if (lastEvent.getPtr() != event.getPtr()) {
331  // If the newly received event is different from the repeating
332  // event, we stop the repeat process.
333  // Except when we're repeating a OsdControlEvent and the
334  // received event was actually the 'generating' event for the
335  // Osd event. E.g. a cursor-keyboard-down event will generate
336  // a corresponding osd event (the osd event is send before the
337  // original event). Without this hack, key-repeat will not work
338  // for osd key bindings.
339  if (lastEvent && isRepeatStopper(lastEvent, event)) {
340  stopRepeat();
341  }
342  }
343  return executeEvent(event);
344 }
345 
346 int HotKey::executeEvent(const Event& event)
347 {
348  // First search in active layers (from back to front)
349  bool blocking = false;
350  for (auto& info : view::reverse(activeLayers)) {
351  auto& cmap = layerMap[info.layer]; // ok, if this entry doesn't exist yet
352  if (auto it = findMatch(cmap, event); it != end(cmap)) {
353  executeBinding(event, *it);
354  // Deny event to MSX listeners, also don't pass event
355  // to other layers (including the default layer).
356  return EventDistributor::MSX;
357  }
358  blocking = info.blocking;
359  if (blocking) break; // don't try lower layers
360  }
361 
362  // If the event was not yet handled, try the default layer.
363  if (auto it = findMatch(cmdMap, event); it != end(cmdMap)) {
364  executeBinding(event, *it);
365  return EventDistributor::MSX; // deny event to MSX listeners
366  }
367 
368  // Event is not handled, only let it pass to the MSX if there was no
369  // blocking layer active.
370  return blocking ? EventDistributor::MSX : 0;
371 }
372 
373 void HotKey::executeBinding(const Event& event, const HotKeyInfo& info)
374 {
375  if (info.repeat) {
376  startRepeat(event);
377  }
378  try {
379  // Make a copy of the command string because executing the
380  // command could potentially execute (un)bind commands so
381  // that the original string becomes invalid.
382  // Valgrind complained about this in the following scenario:
383  // - open the OSD menu
384  // - activate the 'Exit openMSX' item
385  // The latter is triggered from e.g. a 'OSDControl A PRESS'
386  // event. The Tcl script bound to that event closes the main
387  // menu and reopens a new quit_menu. This will re-bind the
388  // action for the 'OSDControl A PRESS' event.
389  TclObject command(info.command);
390  if (info.passEvent) {
391  // Add event as the last argument to the command.
392  // (If needed) the current command string is first
393  // converted to a list (thus split in a command name
394  // and arguments).
395  command.addListElement(toTclList(event));
396  }
397 
398  // ignore return value
399  command.executeCommand(commandController.getInterpreter());
400  } catch (CommandException& e) {
401  commandController.getCliComm().printWarning(
402  "Error executing hot key command: ", e.getMessage());
403  }
404 }
405 
406 void HotKey::startRepeat(const Event& event)
407 {
408  // I initially thought about using the builtin SDL key-repeat feature,
409  // but that won't work for example on joystick buttons. So we have to
410  // code it ourselves.
411 
412  // On android, because of the sensitivity of the touch screen it's
413  // very hard to have touches of short durations. So half a second is
414  // too short for the key-repeat-delay. A full second should be fine.
415  static constexpr unsigned DELAY = PLATFORM_ANDROID ? 1000 : 500;
416  // Repeat period.
417  static constexpr unsigned PERIOD = 30;
418 
419  unsigned delay = (lastEvent ? PERIOD : DELAY) * 1000;
420  lastEvent = event;
421  scheduleRT(delay);
422 }
423 
424 void HotKey::stopRepeat()
425 {
426  lastEvent = Event{};
427  cancelRT();
428 }
429 
430 
431 // class BindCmd
432 
433 static constexpr std::string_view getBindCmdName(bool defaultCmd)
434 {
435  return defaultCmd ? "bind_default" : "bind";
436 }
437 
438 HotKey::BindCmd::BindCmd(CommandController& commandController_, HotKey& hotKey_,
439  bool defaultCmd_)
440  : Command(commandController_, getBindCmdName(defaultCmd_))
441  , hotKey(hotKey_)
442  , defaultCmd(defaultCmd_)
443 {
444 }
445 
446 static string formatBinding(const HotKey::HotKeyInfo& info)
447 {
448  return strCat(toString(info.event), (info.repeat ? " [repeat]" : ""),
449  (info.passEvent ? " [event]" : ""), ": ", info.command, '\n');
450 }
451 
452 void HotKey::BindCmd::execute(std::span<const TclObject> tokens, TclObject& result)
453 {
454  string layer;
455  bool layers = false;
456  bool repeat = false;
457  bool passEvent = false;
458  ArgsInfo parserInfo[] = {
459  valueArg("-layer", layer),
460  flagArg("-layers", layers),
461  flagArg("-repeat", repeat),
462  flagArg("-event", passEvent),
463  };
464  auto arguments = parseTclArgs(getInterpreter(), tokens.subspan<1>(), parserInfo);
465  if (defaultCmd && !layer.empty()) {
466  throw CommandException("Layers are not supported for default bindings");
467  }
468 
469  auto& cMap = defaultCmd
470  ? hotKey.defaultMap
471  : layer.empty() ? hotKey.cmdMap
472  : hotKey.layerMap[layer];
473 
474  if (layers) {
475  for (const auto& [layerName, bindings] : hotKey.layerMap) {
476  // An alternative for this test is to always properly
477  // prune layerMap. ATM this approach seems simpler.
478  if (!bindings.empty()) {
479  result.addListElement(layerName);
480  }
481  }
482  return;
483  }
484 
485  switch (arguments.size()) {
486  case 0: {
487  // show all bounded keys (for this layer)
488  string r;
489  for (auto& p : cMap) {
490  r += formatBinding(p);
491  }
492  result = r;
493  break;
494  }
495  case 1: {
496  // show bindings for this key (in this layer)
497  auto it = ranges::find_if(cMap,
498  EqualEvent(createEvent(arguments[0], getInterpreter())));
499  if (it == end(cMap)) {
500  throw CommandException("Key not bound");
501  }
502  result = formatBinding(*it);
503  break;
504  }
505  default: {
506  // make a new binding
507  string command(arguments[1].getString());
508  for (const auto& arg : view::drop(arguments, 2)) {
509  strAppend(command, ' ', arg.getString());
510  }
511  HotKey::HotKeyInfo info(
512  createEvent(arguments[0], getInterpreter()),
513  command, repeat, passEvent);
514  if (defaultCmd) {
515  hotKey.bindDefault(std::move(info));
516  } else if (layer.empty()) {
517  hotKey.bind(std::move(info));
518  } else {
519  hotKey.bindLayer(std::move(info), layer);
520  }
521  break;
522  }
523  }
524 }
525 string HotKey::BindCmd::help(std::span<const TclObject> /*tokens*/) const
526 {
527  auto cmd = getBindCmdName(defaultCmd);
528  return strCat(
529  cmd, " : show all bounded keys\n",
530  cmd, " <key> : show binding for this key\n",
531  cmd, " <key> [-repeat] [-event] <cmd> : bind key to command, optionally "
532  "repeat command while key remains pressed and also optionally "
533  "give back the event as argument (a list) to <cmd>\n"
534  "These 3 take an optional '-layer <layername>' option, "
535  "see activate_input_layer.\n",
536  cmd, " -layers : show a list of layers with bound keys\n");
537 }
538 
539 
540 // class UnbindCmd
541 
542 static constexpr std::string_view getUnbindCmdName(bool defaultCmd)
543 {
544  return defaultCmd ? "unbind_default" : "unbind";
545 }
546 
547 HotKey::UnbindCmd::UnbindCmd(CommandController& commandController_,
548  HotKey& hotKey_, bool defaultCmd_)
549  : Command(commandController_, getUnbindCmdName(defaultCmd_))
550  , hotKey(hotKey_)
551  , defaultCmd(defaultCmd_)
552 {
553 }
554 
555 void HotKey::UnbindCmd::execute(std::span<const TclObject> tokens, TclObject& /*result*/)
556 {
557  string layer;
558  ArgsInfo info[] = { valueArg("-layer", layer) };
559  auto arguments = parseTclArgs(getInterpreter(), tokens.subspan<1>(), info);
560  if (defaultCmd && !layer.empty()) {
561  throw CommandException("Layers are not supported for default bindings");
562  }
563 
564  if ((arguments.size() > 1) || (layer.empty() && (arguments.size() != 1))) {
565  throw SyntaxError();
566  }
567 
568  Event event;
569  if (arguments.size() == 1) {
570  event = createEvent(arguments[0], getInterpreter());
571  }
572 
573  if (defaultCmd) {
574  assert(event);
575  hotKey.unbindDefault(event);
576  } else if (layer.empty()) {
577  assert(event);
578  hotKey.unbind(event);
579  } else {
580  if (event) {
581  hotKey.unbindLayer(event, layer);
582  } else {
583  hotKey.unbindFullLayer(layer);
584  }
585  }
586 }
587 string HotKey::UnbindCmd::help(std::span<const TclObject> /*tokens*/) const
588 {
589  auto cmd = getUnbindCmdName(defaultCmd);
590  return strCat(
591  cmd, " <key> : unbind this key\n",
592  cmd, " -layer <layername> <key> : unbind key in a specific layer\n",
593  cmd, " -layer <layername> : unbind all keys in this layer\n");
594 }
595 
596 
597 // class ActivateCmd
598 
599 HotKey::ActivateCmd::ActivateCmd(CommandController& commandController_)
600  : Command(commandController_, "activate_input_layer")
601 {
602 }
603 
604 void HotKey::ActivateCmd::execute(std::span<const TclObject> tokens, TclObject& result)
605 {
606  bool blocking = false;
607  ArgsInfo info[] = { flagArg("-blocking", blocking) };
608  auto args = parseTclArgs(getInterpreter(), tokens.subspan(1), info);
609 
610  auto& hotKey = OUTER(HotKey, activateCmd);
611  switch (args.size()) {
612  case 0: {
613  string r;
614  for (auto& layerInfo : view::reverse(hotKey.activeLayers)) {
615  r += layerInfo.layer;
616  if (layerInfo.blocking) {
617  r += " -blocking";
618  }
619  r += '\n';
620  }
621  result = r;
622  break;
623  }
624  case 1: {
625  std::string_view layer = args[0].getString();
626  hotKey.activateLayer(string(layer), blocking);
627  break;
628  }
629  default:
630  throw SyntaxError();
631  }
632 }
633 
634 string HotKey::ActivateCmd::help(std::span<const TclObject> /*tokens*/) const
635 {
636  return "activate_input_layer "
637  ": show list of active layers (most recent on top)\n"
638  "activate_input_layer [-blocking] <layername> "
639  ": activate new layer, optionally in blocking mode\n";
640 }
641 
642 
643 // class DeactivateCmd
644 
645 HotKey::DeactivateCmd::DeactivateCmd(CommandController& commandController_)
646  : Command(commandController_, "deactivate_input_layer")
647 {
648 }
649 
650 void HotKey::DeactivateCmd::execute(std::span<const TclObject> tokens, TclObject& /*result*/)
651 {
652  checkNumArgs(tokens, 2, "layer");
653  auto& hotKey = OUTER(HotKey, deactivateCmd);
654  hotKey.deactivateLayer(tokens[1].getString());
655 }
656 
657 string HotKey::DeactivateCmd::help(std::span<const TclObject> /*tokens*/) const
658 {
659  return "deactivate_input_layer <layername> : deactivate the given input layer";
660 }
661 
662 
663 } // namespace openmsx
#define PLATFORM_ANDROID
Definition: build-info.hh:17
Definition: one_of.hh:7
void printWarning(std::string_view message)
Definition: CliComm.cc:10
void unregisterEventListener(EventType type, EventListener &listener)
Unregisters a previously registered event listener.
void registerEventListener(EventType type, EventListener &listener, Priority priority=OTHER)
Registers a given object to receive certain events.
HotKey(RTScheduler &rtScheduler, GlobalCommandController &commandController, EventDistributor &eventDistributor)
Definition: HotKey.cc:37
void loadUnbind(std::string_view key)
Definition: HotKey.cc:189
std::vector< HotKeyInfo > BindMap
Definition: HotKey.hh:34
void loadBind(std::string_view key, std::string_view cmd, bool repeat, bool event)
Definition: HotKey.cc:183
void loadInit()
Definition: HotKey.cc:175
std::vector< Event > KeySet
Definition: HotKey.hh:35
void scheduleRT(uint64_t delta)
constexpr double e
Definition: Math.hh:18
Event createInputEvent(const TclObject &str, Interpreter &interp)
KeyCode combine(KeyCode key, KeyCode modifier)
Convenience method to create key combinations (hides ugly casts).
Definition: Keys.hh:234
@ K_RETURN
Definition: Keys.hh:34
This file implemented 3 utility functions:
Definition: Autofire.cc:9
bool isRepeatStopper(const Event &self, const Event &other)
Should 'bind -repeat' be stopped by 'other' event.
Definition: Event.cc:185
bool matches(const Event &self, const Event &other)
Does this event 'match' the given event.
Definition: Event.cc:216
ArgsInfo valueArg(std::string_view name, T &value)
Definition: TclArgParser.hh:85
std::vector< TclObject > parseTclArgs(Interpreter &interp, std::span< const TclObject > inArgs, std::span< const ArgsInfo > table)
constexpr bool META_HOT_KEYS
Definition: HotKey.cc:30
TclObject toTclList(const Event &event)
Similar to toString(), but retains the structure of the event.
Definition: Event.cc:85
EventType getType(const Event &event)
Definition: Event.hh:644
ArgsInfo flagArg(std::string_view name, bool &flag)
Definition: TclArgParser.hh:72
std::string toString(const Event &event)
Get a string representation of this event.
Definition: Event.cc:180
bool any_of(InputRange &&range, UnaryPredicate pred)
Definition: ranges.hh:169
auto find_if(InputRange &&range, UnaryPredicate pred)
Definition: ranges.hh:157
auto find(InputRange &&range, const T &value)
Definition: ranges.hh:144
constexpr auto reverse(Range &&range)
Definition: view.hh:372
constexpr auto drop(Range &&range, size_t n)
Definition: view.hh:360
#define OUTER(type, member)
Definition: outer.hh:41
void move_pop_back(VECTOR &v, typename VECTOR::iterator it)
Erase the pointed to element from the given vector.
Definition: stl.hh:125
std::string strCat(Ts &&...ts)
Definition: strCat.hh:549
void strAppend(std::string &result, Ts &&...ts)
Definition: strCat.hh:627
const Event & event
Definition: HotKey.cc:202
EqualEvent(const Event &event_)
Definition: HotKey.cc:195
bool operator()(const HotKey::HotKeyInfo &info) const
Definition: HotKey.cc:199
bool operator()(const Event &e) const
Definition: HotKey.cc:196
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
Definition: xrange.hh:148
constexpr auto end(const zstring_view &x)