{"action":"opened","issue":{"url":"https://api.github.com/repos/jonathanslenders/python-prompt-toolkit/issues/335","repository_url":"https://api.github.com/repos/jonathanslenders/python-prompt-toolkit","labels_url":"https://api.github.com/repos/jonathanslenders/python-prompt-toolkit/issues/335/labels{/name}","comments_url":"https://api.github.com/repos/jonathanslenders/python-prompt-toolkit/issues/335/comments","events_url":"https://api.github.com/repos/jonathanslenders/python-prompt-toolkit/issues/335/events","html_url":"https://github.com/jonathanslenders/python-prompt-toolkit/issues/335","id":164585567,"number":335,"title":"Add example for converting from readline-based key bindings to Prompt Toolkit","user":{"login":"evandrone","id":19310202,"avatar_url":"https://avatars.githubusercontent.com/u/19310202?v=3","gravatar_id":"","url":"https://api.github.com/users/evandrone","html_url":"https://github.com/evandrone","followers_url":"https://api.github.com/users/evandrone/followers","following_url":"https://api.github.com/users/evandrone/following{/other_user}","gists_url":"https://api.github.com/users/evandrone/gists{/gist_id}","starred_url":"https://api.github.com/users/evandrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evandrone/subscriptions","organizations_url":"https://api.github.com/users/evandrone/orgs","repos_url":"https://api.github.com/users/evandrone/repos","events_url":"https://api.github.com/users/evandrone/events{/privacy}","received_events_url":"https://api.github.com/users/evandrone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-08T18:09:57Z","updated_at":"2016-07-08T18:09:57Z","closed_at":null,"body":"The [keybinding example](https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/examples/custom-key-binding.py) shows how to do some fancy things with key bindings (CtrlT to print \"hello world\"), so it's clear how to execute an arbitrary callable for a given key combination (or at least, for key combinations defined in from `prompt_toolkit.keys.Keys`), but if I just want to customize key combinations for existing cursor functions, where would I go?  For instance, my `.inputrc` contains:\r\n\r\n```\r\nC-f: backward-word\r\nC-g: backward-kill-word\r\n```\r\n\r\nThe prompt-toolkit alternative should be something like: \r\n\r\n```python\r\nfrom prompt_toolkit import prompt\r\nfrom prompt_toolkit.key_binding.manager import KeyBindingManager\r\nfrom prompt_toolkit.keys import Keys\r\nmanager = KeyBindingManager.for_prompt()\r\n\r\n@manager.registry.add_binding(Keys.ControlF)\r\ndef _(event):\r\n    # < Function call to move cursor backward one word>\r\n\r\n@manager.registry.add_binding(Keys.ControlG)\r\ndef _(event):\r\n    # < Function call to kill backward one word>\r\n\r\n```\r\n\r\nI'd be happy to add something like this to the keybinding example, if someone can tell me what functions to call.  Cheers!"}}
{"actor":{"display_login":"evandrone"}}