[IPython-dev] Highlighting code as program runs?

Doug Blank doug.blank at gmail.com
Sat Sep 27 19:05:08 EDT 2014


Ok, so a few afternoon hacks later, and I have a prototype of a graphical
stepper/debugger with code highlighting, graphical breakpoints, and slider
control for speed. What do I mean? See example tracing Scheme factorial:

https://www.youtube.com/watch?v=f8PvbMt6i1o

I based my experiment on an animation example by Jake Vanderplas:

http://jakevdp.github.io/blog/2013/05/19/a-javascript-viewer-for-matplotlib-animations/

I did a few experiments to play with CodeMirror and running code (fail):

http://jupyter.cs.brynmawr.edu/hub/dblank/public/Experiments/Breakpoint%20Tests.ipynb

Initially, I thought I'd use Widgets and real code execution. But ended up
using raw Javascript and kernel.execute commands. There probably is a
better way. In any event, the version in the video is just a prototype, but
is designed to be code agnostic, working with any language through the
MagicKernel's debug magic  [1].  Not every language may be able to do this
as easily as Scheme [2], however.

-Doug

[1] - https://github.com/blink1073/jupyter_kernel
[2] - https://bitbucket.org/ipre/calico/src/master/src/calico_scheme_kernel/
and
https://bitbucket.org/ipre/calico/src/master/src/calico/scheme.py

On Tue, Sep 23, 2014 at 10:50 PM, Doug Blank <doug.blank at gmail.com> wrote:
>
> We are currently running an external kernel (Scheme) based on the
"wrapper kernel" [1]. We would like to have a mode such that we could
highlight the expression in the code cell as the program "runs".
>
> Is there an example of something like this? If not, what would be the
recommended method to do this? Perhaps a CodeWidget, with specialized comm
message handling to highlight the text, with stepper controls?
>
> I see that CodeMirror supports highlighting an area [2]. Now, just need
to be able to send the region bounds as the program runs, and receive them.
>
> Any pointers appreciated,
>
> -Doug
>
> [1] - http://ipython.org/ipython-doc/dev/development/wrapperkernels.html
>
> [2] - cell.code_mirror.markText({line: 6, ch: 2}, {line: 6, ch: 5},
{className: "styled-background"});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140927/ff26fa84/attachment.html>


More information about the IPython-dev mailing list