Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to save and load custom keymap to/from file. #66

Open
MartinHowarth opened this issue Dec 30, 2019 · 0 comments
Open

Add ability to save and load custom keymap to/from file. #66

MartinHowarth opened this issue Dec 30, 2019 · 0 comments
Labels
large Large amount of work estimated

Comments

@MartinHowarth
Copy link
Owner

Challenge here is that current key maps are defined with references to actual code objects.
Need to be able to refer to objects by strings instead.
I think this should JustWork™️ by adding the restriction that KeyboardActionDefinition can only have callbacks to a single object - and use getattr to find methods on that object.

i.e. interface would be:
KeyboardActionDefinition.from_yaml(target_object, yaml_defn=None)
and the equivalent to_yaml would just get the string name of the functions it points at.

And the calculator example would approximately change from def create_keymap(self) -> KeyMap: to static method: create_keymap(calculator, yaml_defn=None) -> KeyMap:

Unresolved challenge:

  • need a way to make it easy to state which object to re-load the map for.
    • For global singletons this seems pretty straightforward.
    • Alternatively, encourage / mandate that keyboardhandlers (not just KeyboardActionDefinition) must act on a single object - then the definition of a keymap is pure and contained.
    • Alternatively, because keymaps are probably identical for all things of the same type (assuming only one focused at once) then a global map of unique string: keymap save name as part of a class definition means we can re-load it for any of a given class easily. e.g. class Calculator: _keymap_name = Calculator (default to class.name? - should be unique for most situations)

Second challenge:
Actually make keymaps editable. Shouldn't be too hard to just define a collection of buttons + key captures in a menu/form layout (once those are implemented!)

@MartinHowarth MartinHowarth added the large Large amount of work estimated label Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
large Large amount of work estimated
Projects
None yet
Development

No branches or pull requests

1 participant