Akira-Hayasaka / ofxGLEditor

Script editor for oF Live Coding
GNU General Public License v2.0
100 stars 16 forks source link

Any way of detecting words within a string for syntax highlighting? #11

Closed JoshuaBatty closed 9 years ago

JoshuaBatty commented 9 years ago

Hi Akira,

Firstly thanks a bunch for the amazing editor, really is coming along nicely. I have just forked the library as i'm creating a syntax highlighting example for GLSL. You can see it here https://github.com/JoshuaBatty/ofxGLEditor/tree/master/GLSLeditorSyntaxExample

What would be great is for GLSL keywords to be detected for highlighting without needing to provide a " " (space) for them to be detected. This way you could write the following for example and sytax highlighting would still occur on abs and sin...

float t = abs(sin(u_time)); instead of: float t = abs ( sin ( u_time));

Obviously the first example is a lot nicer to write and read so would be great for the glsl functions to still highlight using this method.... any ideas?

Cheers.

danomatika commented 9 years ago

Yeah, I have that in mind. I just need to break apart the brackets & parens as text blocks.

danomatika commented 9 years ago

Also, the syntax parser considers non-string, non whitespace text blocks entries as "words". I added support for breaking up these "words" with a new MATCHING_CHAR type so highlighting your example will now work:

screen shot 2015-03-26 at 1 17 10 pm

danomatika commented 9 years ago

If you're going to do a PR with the new example, can you name it editorGLSLSyntaxExample?

JoshuaBatty commented 9 years ago

Awesome thanks! I have submitted a pull request with a basic live coding GLSL example with syntax highlighting turned on for you to review. I added in + - / * into ofxEditorSettings so that syntax highlighting would still occur in the event of ( float t = 10.0+sin(u_time); ) for example.