2 days of near-non-stop coding....

General discussion about the development of the open source Blender

Moderators: jesterKing, stiv

Post Reply
Goofster
Posts: 108
Joined: Mon Oct 14, 2002 12:26 pm

2 days of near-non-stop coding....

Post by Goofster »

It's safe to say this have been two of more rewarding days in my coding "career" (if you can call it that :) )

Syntax Highlighting

some notes to go with this pictures:

- some stuff is a bit screwed up, mainly because some tabs get last in the parsing (easy to fix)
- not all commands are highlighted yet. not sure how to keep the commands updated, probably it checks if you have an external file, or else it uses an internal commandlist.
- colours, if you don't like them, I WILL make them customizable.
- some explanation on how I did it:

blender draws lines of text line-by-line. So there wasn't such a thing as a "Word" just a "line".
I split the line word by word, check it, and then draw the word in the apropriate color. then I move on to the next word on the line....untill the line is complete.

amazingly enough, so far I don't see any lag with the highlighting turned on. but I havn't checked on older pc's yet (I have a 1Ghz Athlon)


- and finally: IT IS NOT DONE YET!

So here it is, I hope you like it :D :

http://www.roelspruit.com/var/syntax6.jpg

Roel
[/url][/u]

thorax
Posts: 320
Joined: Sun Oct 27, 2002 6:45 am
Contact:

Well

Post by thorax »

I commend your effort, but you might look into using CTags library
to colorize the syntax..

Do a search on google for the CTags.. It takes
a script in a certain language and processes it so it can
easily be processed by a text editor, and according to my copy
of GVIM it already recognizes about 100 languages, I saw Radiance and
Perl and Java in the list, it seems to interpret anything now..

Another feature that would be useful in blender's text editor is a
save button.. Its at least not obvious how one saves text files
out..

wavk
Posts: 126
Joined: Wed Oct 16, 2002 9:58 am
Location: The Netherlands
Contact:

Post by wavk »

Hi Goofster! Very cool addition. It will make coding a lot nicer. And thorax, I disagree. Please don't add yet another external library. We don't need syntax hilighting for tens of languages, we just need python. Adding an external library for that will only complicate matters.

The Alt+Shift+F menu is a bit hard to find, I agree. And there's a lot of space free in the text window header button bar. Maybe put these options in the pop menu left of the text file name.

Coz
Posts: 39
Joined: Wed Oct 16, 2002 5:15 pm
Location: Santo Domingo, Dominican Republic

Post by Coz »

hey Goofster in your screenshot i see a text window that puts the text from the console? if so, how did you do that?

Goofster
Posts: 108
Joined: Mon Oct 14, 2002 12:26 pm

Post by Goofster »

To Coz: yeah, the Tuhopuu tree has that now. it's VERy handy. instead of directing output to a console blender has a kind of internal console. very handy for debugging and such.

UPDATE

Some new stuff:

- all tab problems have been fixed. the text is now drawn exactly the same as when you don't use the syntax colouring (which is pretty friggen amazing since I now don't write an entire line at once but word-for-word)

- added a switching button (look at the neat button I made! :))

- added a colorpicker! I know, I know, not exactly "OOOOH! I wanna have it" but it's neat anyway. Mainly because now you don't have to b*tch about the colourscheme :)

- not new, but cool: it STILL doesn't lag :)

Still To Do:

- Add a check for block comments. This is perticulary hard because blender only "sees" text that is on the screen. so if the start of a commentblock is above the screen, you don't know you're in a commentblock.

- make some kind of organized way to save the words to check. hopefully I can make some kind of config file so you can use different words too (other languages anyone?)
screenshot with the latest updates:

http://www.roelspruit.com/var/syntax9.jpg

Devas73
Posts: 26
Joined: Wed Oct 16, 2002 12:21 am

Wow cool!

Post by Devas73 »

Great job, my compliments!
With Italian keyboard, on win32 I can't insert [] or {} which is annoying as hell since I have to copy/paste from an external script (it seems the alt key is not recognized) but I haven't checked if in newer versions (2.26 and tohuppu) this has been fixed... if not, this would be another key addition to the editor.
:wink:

wavk
Posts: 126
Joined: Wed Oct 16, 2002 9:58 am
Location: The Netherlands
Contact:

Post by wavk »

So how's this going?

IoN_PuLse
Posts: 212
Joined: Wed Oct 16, 2002 6:05 am
Location: Canada, BC
Contact:

Post by IoN_PuLse »

I just searched for CTags, thank goodness it's a standalone class, I was afraid because of the C in front of it that it was some MFC nonsense....such an evil thing...

thorax
Posts: 320
Joined: Sun Oct 27, 2002 6:45 am
Contact:

Post by thorax »

IoN_PuLse wrote:I just searched for CTags, thank goodness it's a standalone class, I was afraid because of the C in front of it that it was some MFC nonsense....such an evil thing...
Yep, it should make life easier..

It makes editing source in GVIM a breeze..
Eventually it would be nice if blender's text editor had VI
capabilities as blender's own hotkey interface borrowed from
VI. "x" key in blender is delete, same key in VI.
However in VI, the TAB key has no special meaning, but
ESC-key gets you out of edit mode.. That's why some have called Blender the VI of 3D modelling packages, its small efficient
and the interfaces are somewhat similar.

Post Reply