[IPython-dev] pyreadline (Hey cocoa/QT/wx ipython GUI what do you think about this?)
laurent.dufrechou at gmail.com
Wed Mar 26 20:34:39 EDT 2008
>OK, but how to you choose how a key must behave? You need one single
>object that knows the configuration of keys (is pageup history, or
>nothing?), and what if I want to switch to VI mode, you don't want to
>implement this in all the frontends.
When you use a widget, like scintilla one that I used, all the classical key
where already handled by the text widget itself. I add to overload some to
better match ipython shell behavior. Like pushing 'up', does not go up but
call history back.
So if you want VI mode , just design your ipython widget around a VI aware
text widget, that's all...
>Sending a string defeats the goal of readline: readline is what
>translates keystrokes to a command string. Readline knows that if I use
>"ctr-left", it should jump the cursor one word to the left. Yes, it is
>not easy, but that's what readline is about, IMHO.
Ok I've deleted the beginning of my email:
In fact the problem can be solved 'easily'.
For WX the widget developer will ahev something like this:
Self.readline = Readline(ipython_instance)
self.readline.MoveCursorLeft = self.MoveCursorLeft
self.readline.GotoStartOfLine = self.MoveToPrompt
#------------------------ Key Handler ------------------------------------
def keyPress(self, event):
Key press callback with plenty of shell goodness, like history,
if event.GetKeyCode() == ord('C'):
if event.Modifiers == wx.MOD_CONTROL:
#we raise an exception inside the IPython thread container
#readline key handling
#post key processing
if (self.readline.has_processed_key == False):
Developer must have the possibility to let or not readline to handle the
If he don't want to use readline key handling, he must have access to
function that can make ipython execute a string, and that should be ok.
Am I clear in my explanation? Readline only process key but does not manage
widget directly. User will to hook it's widget function to readline one.
With this approach I'm OK. So we will be able to use a text area renderer, a
scintilla renderer or even an html renderer...
This will not be a problem for readline, has it will only redirect key event
to good widget functions via a unified interface.
More information about the IPython-dev