CodeArea Module

Community Forums/Showcase/CodeArea Module

Ked(Posted 2008) [#1]
Hey. I am almost finished with my 3rd BlitzMax module which wraps up some textarea functions so that it is crazy easy to syntax highlight.

I will post a demo later. Let me know of your thoughts!

FEATURES:
*Set CodeArea font
*Set CodeArea background and foreground/text color
*Set CodeArea keyword color
*Set CodeArea comment color
*Set CodeArea digit color
*Set CodeArea string color
*Create a syntax list per CodeArea
*Retrieve textarea handle from the TCodeArea type
*Pretty much everything else that you can do with a textarea

POSSIBLE UPCOMING FEATURES:
*Set CodeArea operator colors
*Auto-Indenting
*Anything else I think of or anything that is suggested

FUNCTIONS:

...More being added...

SCREENSHOTS:



GaryV(Posted 2008) [#2]
Looks VERY useful!


Ked(Posted 2008) [#3]
Thanks.

I updated the top and the demo is coming.


fredborg(Posted 2008) [#4]
That looks brilliant!


Ked(Posted 2008) [#5]
The demo probably won't be coming out for a while because I found out the the highlighting is crazy slow when highlighting big files. Sorry for the delay.

btw: Thanks!


SebHoll(Posted 2008) [#6]
The demo probably won't be coming out for a while because I found out the the highlighting is crazy slow when highlighting big files. Sorry for the delay.


The exact same thing happened to me when I first started developing the built-in codearea to my GUI editor (Max'd GUI) - still, I did manage to fix it in the end.


Koriolis(Posted 2008) [#7]
Yes, it's insanely slow. I personnaly had to work around it by directly sending the RTF data to the underlying Windows control. But obviously, that's windows specific.


Ked(Posted 2008) [#8]
The exact same thing happened to me when I first started developing the built-in codearea to my GUI editor (Max'd GUI) - still, I did manage to fix it in the end.

I can't seem to figure out how to fix it. I've tried highlighting it by line but it seems slower than highlighting it by character.


SSS(Posted 2008) [#9]
Could you highlight it incrementally? Like 500 lines per increment or something?


klepto2(Posted 2008) [#10]
Looks very nice :)
I've started one by myself long time ago but give up as soon as it comes to get it work on Linux canvases (the whole keyevents were broken). It was able to load the whole MaxIDE Source within 70ms (including highlighting).

The trick for fast highlighting is just to calculate the visible lines instead of highlighting the total amount of lines.

Just as a proof ;)



and




xlsior(Posted 2008) [#11]
Ked: Function/comment folding would be nice.


plash(Posted 2008) [#12]
@Klepto: Why is that not in maxide yet!?? That's awesomeness.


Mark Tiffany(Posted 2008) [#13]
Good question. There's a codearea been donated to the CE IDE before, but has some bugs, and I've never got round to hooking it up. Would be fantastic to get a custom codearea into the CE IDE...and then we can add function folding, etc, etc...


plash(Posted 2008) [#14]
<3

EDIT: Klepto, I've noticed key problems in graphics windows aswell. Sounds like a bug that needs fixin.


Ked(Posted 2008) [#15]
Could you highlight it incrementally? Like 500 lines per increment or something?

I thought about highlighting 200 (200 is just an example number) lines under the current line position but I'm afraid of scrolling down and seeing messed up highlighting.

Could you explain what you mean by incrementally? I think I know what you're talking about.

The trick for fast highlighting is just to calculate the visible lines instead of highlighting the total amount of lines.

I thought about that also, but I don't know how to get the visible lines from a textarea.

ALSO: klepto: that looks very nice!


klepto2(Posted 2008) [#16]
Ked, I was thinking you're using a custom textarea (simulated on a canvas) as I do. On windows it is possible to determine the first and last visible line with some afford. (I have posted these functions somewhere in the module tweaks forum)

@All: Unfortunatly this codearea isn't continued due the incompatibility bewtween the different OS. My goal was a codearea which will work on all supported OS, but this is currently unreachable. Also the code is about 2 years old so I don't believe I will get into the code again.


Ked(Posted 2008) [#17]
On windows it is possible to determine the first and last visible line with some afford. (I have posted these functions somewhere in the module tweaks forum)

I looked at that but it doesn't update the first visible line when you scroll up or down.

I'm fine with making a canvas-based codearea if that's whats needed.


plash(Posted 2008) [#18]
the code is about 2 years old so I don't believe I will get into the code again.
Are you going to let it rot, or post the code?


Ked(Posted 2008) [#19]
Nevermind. I don't have the knowledge of making a canvas textarea. :P


dmaz(Posted 2008) [#20]
here's my codearea, the one Mark Tiffany referred to I believe ...
http://www.blitzbasic.com/Community/posts.php?topic=63829

I had lots of plans but other stuff got in the way. anyway, I donated the source to the CE ide and it should still be available there. it's a completely custom canvas one, which I think is the only way to go for the best compatibility and more importantly the best performance.


Chalky(Posted 2008) [#21]
@dmaz - can anyone access your donated code (or is it for CE IDE developers' eyes only) and if so where can we find it?

@klepto2 - what Plash said...


Mark Tiffany(Posted 2008) [#22]
dmaz's codearea code is in the CVS (link in sig) which anyone can download. It is rather good, although there were a few minor bugs in it. I certainly agree a custom canvas is the only way to get a decent codearea - there's only so much you can do with the textarea control.

It's not integrated into the IDE at all at the present time, so if anyone wants to contribute feel free to amend the standalone code in CVS. One burning question was around what should go in the codearea and what should go in a parser, and what overlap is there with the IDE code. This is by far the hardest part of integrating it - which I'd love to see, but don't the time do myself...


klepto2(Posted 2008) [#23]
Unfortunatly my old code is somehow broken, but I have started a new one today. Progress comes along nicely and the new Keymanager I have written seems to work on linux as well.

My 2 cents for the codearea parser stuff:
Like most codearea or syntaxcontrols I believe at least the highlighting should be completely managed by the codearea. Thats the reason why Scintilla or Snytaxbox are so fast.
I have a really powerfull (I believe) parser which is easily to integrate within my new codearea. It could already manage multiline comments, different keyword highlighting (each list could get their own colors and style) also folding is possible to integrate.
So in general you should leave highlighting to the codearea, but the other parser stuff like Codelists etc should have a seperate parser which is normally much easier to implement than the whole highlighter parser.

I will keep you up to date as soon as there is something to show.


plash(Posted 2008) [#24]
Hopefully Brucey will have a part working wx maxide (see the CE IDE thread, he mentioned something about it) by the time you release that.

Then it should be as simple as using a wx.glcanvas :P.

EDIT: I think we totally hijacked his thread :( sorry