I'm using the python readline module (and using the input() function, which readline modifies). Everything is working, but I would like to add a feature to call a custom python function when a certain key is pressed during input (the function would record that the key was pressed, change the prompt on the current line, and call redisplay to display the new prompt).
Essentially, I want to call rl_bind_key in the underling readline library, but give it a python function as a callback instead of a C function.
Is there a way of doing this short of writing my own extension for the readline library? Does such a thing already exist?
Other than that I don't want to write a new extension if I can avoid it, I would also like this to work when the readline module is compiled with editline, and it seems that would be tricky (mostly to know how to build my extension based on how the readline module was compiled).