Page MenuHomePhabricator

Elm Key Bindings
Updated 1,188 Days AgoPublic

Key Bindings

Discussion about this document can be done in {T2891}

The feature of key bindings is implemented in 2 different places. In Elm.Widget and Elm.Key_Binding.Storage.

Elm.Widget part

Every widget can resolve key bindings. You can add key bindings by calling

key_binding_add

  • key : const(char)*
  • mods : TODO Type
  • action : const(char)*
  • cb : TODO type

Every time the event function of a widget is called it tryes checks if one keybinding is registered to the key and mods of the current event.

There is also

key_binding_storage_add

  • storage : Elm.Key_Binding.Storage
  • actions : Elm.Key_Binding.Action[]

Storage is introduced later. Actions specifies an array which maps actions to callbacks. Each action which can be found will be transformed into a keybinding with the key and mods out of the storage, the action, and the callback of the action array.

Elm.Key_Bindings.Storage

key_binding_add

  • key : const(char)*;
  • mods : TODO type
  • action : const(char);
  • description : const(char);

This will add a key binding to the internal list of the storage. If the given action is already in the internal list , key and mods will not change, and the internal values will be kept.

key_binding_del

  • key : const(char)*;
  • mods : TODO type
  • action : const(char);

will delete the entry with the given key and mods

There are 3 way of initalizising a strorage. One way is doing nothing, this will leave the internal list of actions empty. Or calling file_init or elm_init.

file_init

  • file : const(char)*;
  • scheme : const(char)*;
  • appname : const(char)* // ?? can be replaced with elementary app name ??

This will load the key bindings saved in the given file under the given scheme into the internal list. If a action is added with the api and the file is not aware of this action the action will be added to the file, with the key and mod passed to the api.

elm_init

  • widget_name : const(char)*;

This will load the widget scheme from elementary interal config, key_bindings cannot be added to this storage.

Elementary Config part

Each Key_Binding Storage which are loaded from a file will be cached and written into elementarys cache.

This cache is queryed when elementary_config is used to configure the key and mods for a given action.

Things to think about

  • Translation of the description
  • Link a scheme of a app to another scheme of another file,
Last Author
bu5hm4n
Last Edited
Dec 22 2015, 12:49 AM
Projects
None
Subscribers
seoz