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

Allow custom accept-then keybindings from edit mode #2193

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ajkerrigan
Copy link
Collaborator

@ajkerrigan ajkerrigan commented Dec 27, 2023

Allow a mapping in the form "keystroke -> iterable-of-vd-functions" to define custom keybindings that accept input and then queue one or more vd functions. With these changes, an option like the following can define custom "accept/move/re-edit" flows:

vd.options.edit_accept_keybindings = {
    "Ctrl+N": ("go-down", "edit-cell"),
    "Ctrl+P": ("go-up", "edit-cell"),
}

Allow a mapping in the form "keystroke -> iterable-of-vd-functions" to
define custom keybindings that accept input and then queue one or more
vd functions. With these changes, an option like the following can
define custom "accept/move/re-edit" flows:

vd.options.edit_accept_keybindings = {
    "Ctrl+N": ("go-down", "edit-cell"),
    "Ctrl+P": ("go-up", "edit-cell"),
}
@@ -623,6 +625,7 @@ def editCell(self, vcolidx=None, rowidx=None, value=None, **kwargs):

# update local bindings with kwargs.bindings instead of the inverse, to preserve kwargs.bindings for caller
bindings.update(kwargs.get('bindings', {}))
bindings.update({k: acceptThenFunc(*v) for k, v in options.edit_accept_keybindings.items()})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of allowing people to customize their keybindings for edit/input, but the 'always accept' gives me pause every time I come back to it. I think it'd be better if we had user-set bindings apart from options, and required them to manually specify something like acceptThenFunc. Like:

vd.edit_bindings = {
    'Ctrl+X': acceptThenFunc('syscopy-cell', 'delete-cell')
}

but that API is pretty terrible too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants