Problem with .syntaxColorize method

Hi, I’m having trouble with the TextView method .syntaxColorize.

According to the help file, it “applies colors to text throughout the entire contents of the view, according to the SuperCollider language syntax highlighting scheme.” But when I evaluate the example code (below) nothing happens. Am I not configuring something right in the class or the IDE or is this just a general issue with QT and this method?

(
t = TextView(bounds: Rect(300, 400));
t.string = this.cmdLine;
t.syntaxColorize;
t.front;
)

	syntaxColorize {
		this.nonimpl( "syntaxColorize" );
	}

I think that method was for Cocoa only, and was never ported to Qt.

hjh

Got it! Thanks for the info!

For what it’s worth: hooking up the existing syntax highlighter to the TextEdit component in sclang is a pretty simple task on the C++ side. If anyone is interested in taking this on, it might only be an afternoon or two at work, I’d be happy to relay where to start.

Yeah, I’d be interested in seeing if I can implement this! Where should I look?

i think Luke Nihlen may already be working on fixing this!

I was working on fixing it, but the direction I had in mind is probably a longer path. I’ve been working on a parser for SCLang, which is basically exposing the parse tree that the SCLang compiler builds for itself back to the language. Work on that is ongoing, but it’s a big project.

Once the parser is working writing a syntax highlighter in sclang itself could be pretty trivial, and could get a lot fancier than the current regex-based (IIUC) one we have in Qt.

If scztt@ has an idea about how to do it in an afternoon, and Ian@ is interested in pursuing, I think that’d be great, and probably a faster path to usable results.

1 Like

This is orthogonal, but one thing I would really like is the ability to define alternate syntax colorizing rules.

We can implement new dialects using the interpreter preprocessor. But the IDE enforces one and only one syntax style. A document is either “SC code” (you can execute statements in it, and it’s colorized by The One True Way and no other way is supported), or it is “not SC code” and you’re not allowed to submit anything in it to the interpreter.

That’s really annoying for my live coding dialect.

Now, if there is an object structure for a parse tree and we can use that for colorizing, then my dialect could construct its own parse tree and colorize according to the dialect’s syntax. That would be nice for TextView – would be nicer to extend that possibility to the IDE as well.

hjh

Hi there,
the SC’s syntax (“only”) could be a big plus for one of my projects…
Is there anything new about this method ?