Skip to content

Instantly share code, notes, and snippets.

@marcelhollerbach
Created December 21, 2015 15:47
Show Gist options
  • Save marcelhollerbach/f72ed2ab76d3ce0bbb3b to your computer and use it in GitHub Desktop.
Save marcelhollerbach/f72ed2ab76d3ce0bbb3b to your computer and use it in GitHub Desktop.
struct Efm.Key_Binding{
action : const(char)*;
description : const(char)*;
key : const(char)*;
mods : FancyType;
}
struct Efm.Key_Binding.Action{
action : const(char)*;
cb : CallbackType;
}
class Efm.Key_Binding.Storage(Eo.Base) {
methods {
file_connect {
[[synchronise this file storage with a file]]
params {
file : const(char)*;
}
}
elm_connect {
[[load the schema from elm config]]
params {
name : const(char)*;
}
}
add_key_binding {
params {
key : const(char)*;
mods : SomeFancyType;
action : const(char)*;
description : const(char)*;
}
}
del_key_binding {
params {
key : const(char)*;
mods : SomeFancyType;
action : const(char)*;
}
}
get_key_bindings {
return : list<Efm.Key_Binding>;
}
}
constructors {
.file_connect
.elm_connect;
}
}
class Elm.Widget(Eo.Base) {
methods {
...
key_binding_add {
[[tell elm to listen to this key with the mods, and call the callback once the key is pressed]]
params {
key : const(char)*; [[the key to listen to]]
mods : SomeFancyType; [[with given mods]]
action : const(char)*; [[action to pass to the callback]]
ev : CallbackType; [[the callback]]
}
}
key_binding_storage_add {
[[load the actions given with mappings out of the storage]]
params {
storage : Efm.Key_Binding.Storage*; [[storage to take]]
mappings : Efm.Key_Binding.Action[]; [[mappings to load]]
}
}
}
}
class Elm.Config.Key_Bindings(Elm.Widget) {
[[Widget which allows to configure the keybindings in the given storage]]
methods {
add {
params {
storage : Efm.Key_Binding.Storage*;
parent
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment