1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Code coloring

Posted by Pachicito on Dec 31, 2009

Hello,

I'm running NodeBox on Snow Leopard and every once in a while I seem to run into this problem. After a long line of code, the subsequent lines no longer format the code with colors. All the code is just regular black text. The code still runs fine, but it makes coding and debugging more difficult. Any help is greatly appreciated.

example of long line: boxes.append(Box(random(WIDTH), random(HEIGHT), random(1.0), 1.0, 1.0, 40))

Everything after this line is plain text.

Thanks


 
Posted by Josh Caswell on Jan 06, 2010

I've noticed the same thing in the past. After a little experimentation, I believe that it has nothing to do with the line length, but happens when there are more than four keywords in the line. Try this, for example:

oval rect line from paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul paul line

If you type lines following this, they won't be syntax colored, but if you take away one of the keywords from that long line, the following lines will become colorized. Then you can put back the removed word, and the colorization will stay, but new lines typed will again be uncolorized.

I had a look at the source, and I'm not positive, but I think there is a bug.

PyDETextView.PyDETextStorageDelegate._colorize punts after colorizing more than 4 tokens, and I think it doesn't properly schedule a new pass for colorization after that.



Posted by Josh Caswell on Jan 06, 2010

Boy, even more weirdness:

If you have a line with four keywords, the next line will only colorize one keyword, then all colorization stops.

oval line from rect
oval line
oval line from rect
oval
oval
However, if you type the keyword on the next line, then add something at the beginning of the line that also needs to be colorized, colorization will resume normally. The best way to see this may be using a comment:

If the next line is a comment, it will get colorized, but stop colorization after that.
oval line from rect
#nothing
oval
However, if you type the comment first, then add a keyword at the beginning of that line, colorization resumes normally.
oval line from rect
rect #this comment has to be typed before rect
oval



Posted by fdb on Jan 08, 2010

We're aware of problems with PyDETextView but haven't got the time and resources to look into it as we're working hard on NodeBox 2 at the moment.

I love the fact that you're putting effort in this issue. If you have a concrete workaround I'll be glad to include it in the source.

All the best,

Frederik



Posted by Hndrsn on Jan 08, 2010

I've encountered similar problems, but by cutting and repasting the code it sorts itself out.



Posted by Josh Caswell on Jan 08, 2010

Thanks, Frederik. I know you're focussed on NB2; I didn't really figure this was on your radar. I'll put looking into it on my own to-do list, and let you know if I figure anything out!