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

Keymap configuration (or at least extraction) #8

Closed
neiljp opened this issue Feb 7, 2019 · 8 comments
Closed

Keymap configuration (or at least extraction) #8

neiljp opened this issue Feb 7, 2019 · 8 comments

Comments

@neiljp
Copy link
Collaborator

neiljp commented Feb 7, 2019

It would be really useful to be able to know which keys are used by the library, to avoid conflict with other keys, or to show a list of shortcut keys. Currently the keymap is in the keypress command; does it seem reasonable to extract this, and potentially include metadata regarding each one, if there is not already?

I could investigate another PR, if this would be a reasonable idea.

@rr-
Copy link
Owner

rr- commented Feb 7, 2019

You mean being able to know in the programmatical sense?

Do you want to go a step further and be able to manipulate this keymap?

@neiljp
Copy link
Collaborator Author

neiljp commented Feb 8, 2019

In increasing degrees of convenience, it would be useful to:
a) know which keys are handled by this library (to sense key conflicts)
b) know what each key "does" (symbolic strings, actual text, ...) (eg. to show 'help')
c) potentially (?) remove keys from the map (to manually resolve conflicts if desired)
d) in some future version, hypothetically have a map which translates keys to 'commands'? (full customization)

(a) or (b) are the short-term options I was considering for this issue.

(c) or (d) could allow much more customization and eg. sets of keymaps, extending beyond just readline, perhaps.

@rr-
Copy link
Owner

rr- commented Feb 16, 2019

Sorry for the late reply. Pushed 8f13b26 which moves the keymap to the constructor. That way, you should be able to subclass ReadlineEdit and manipulate its keymap however you need. Let me know if this change is sufficient for your needs, and if it is, I'll publish a new version on PyPI. Thanks :)

@neiljp
Copy link
Collaborator Author

neiljp commented Feb 16, 2019

@rr- No problem - this is great as a first iteration for (a), and it would be useful to have the other commit from #7 in a release too.

I am investigating another issue with zulip-terminal that may or may not be a urwid_readline bug, for multiline boxes with previous_line/next_line - I was checking the tests and didn't see any for the multiline case? If this is an urwid_readline bug, it might be good to get this in & fixed too, if it's not too difficult.

@rr-
Copy link
Owner

rr- commented Feb 16, 2019

c) and d) should be completely doable, though (that's what I meant by subclassing ReadlineEdit):

class MyReadlineEdit(ReadlineEdit):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        del self.keymap['ctrl a']
        self.keymap['ctrl a'] =

As for b), all you have to do is to compare the keymap values with the member functions. They're public for a reason.

As for the bug, it should go into a separate ticket.

@neiljp
Copy link
Collaborator Author

neiljp commented Feb 16, 2019

Oh, yes, sorry, I meant to agree on the subclassing point, and was thinking about (b) to myself, still.

I referenced the other issue since I had only just remembered it and thought it pertinent in the context of releasing now or later.

@neiljp
Copy link
Collaborator Author

neiljp commented Feb 26, 2019

@rr- To be clear, if you're fine with making a new release, that would be fine with me :)

@rr-
Copy link
Owner

rr- commented Feb 26, 2019

Release 0.9 available on PyPI.

@rr- rr- closed this as completed Mar 9, 2019
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

No branches or pull requests

2 participants