[IPython-dev] pyreadline: getting callbacks for keypresses from pyreadline
Thu Jun 14 16:39:05 CDT 2007
On 6/14/07, Ville M. Vainio <email@example.com> wrote:
> Is it possible to register certain keys to certain functions that are
> called when that key is pressed? I'm thinking of something like:
> def my_translator(line, curpos):
> return (line +"appended", curpos)
> readline.bind_translator("Alt-e", my_translator)
> where my_translator returns the new content for corrent line, along
> with cursor position.
> This could be used e.g. to launch external editor for current command
> line, something that seems to exist in Vi mode. We should rig the
> IPython default editor for something like this.
I think that GNU readline does allow this, but I'm not 100% sure.
Then, there's the question of whether it will be available to ipython
itself. You can check the GNU readline docs and see if it's possible
via a call to
readline.parse_and_bind(" some syntax here to bind key->cmd ")
but I honestly don't really know (and can't check right now) if it works.
More information about the IPython-dev