codearea control

BlitzMax Forums/MaxGUI Module/codearea control

dmaz(Posted 2006) [#1]
I've been playing around with this for a while now but it's starting to get close to a production state. there still are some things I need to clean up and some more functions to add. it does cut and paste, those are f1 and f2 for now. performance is good... it will load, highlight and set up folding for a 7000 line file in under 1500 ms on my computer. oh yeah, I'm not working on an editor... just a replacement for the textarea control (I am tempted)

some features are:
pc / mac
folding
scope completion
limited syntax checking
simple doc type files for almost any language
tons of options accessible by the programmer
modifiable key shortcuts

planned…
linux
selections still need work
macros
other editing shortcuts
split view (almost done)
more syntax features (multiline blocks like rem not complete yet)
bookmarks

Is there anything else anybody would like to see? Also, if you can test the performace that would be great...



download PC demo


Mark Tiffany(Posted 2006) [#2]
I've only had a quick play, but it looks very nice. A few things that are missing or would be nice:

- Rem & EndRem support (should generate an auto-end rem like function & method do, and should be foldable too)
- If blocks should also be foldable.
- Case statements within a select should possibly be foldable
- double click a word selects all of that word
- shift+arrow should select blocks of code
- ctrl+arrow should select to end of current word, and if pressed again, to next word. (i think that's right, check textarea behaviour)
- Should the first line be 0 or 1? ;)
- templates would be nice
- right click menu to access common functions
- when selecting a block, allow tab and shift-tab to do block outdent / indent
- auto-indent (e.g. if x then should add a tab to next line)
- undo / redo (not just the last one either - multiple undos)
- I'd like to see a gutter available on the left to indicate stuff. e.g. break points, todos, etc.
- auto-complete
- help on commands (e.g. show a tooltip-a-like under the command once types with the mini-help, then F1 to jump to full help).
- multi-language support (C, C++, HTML, XML)

Oops, just saw a couple of these in your notes above!

As for your comment about writing an IDE, once it's linux friendly too, I'd love to look into plugging this into the CE IDE.


Mark Tiffany(Posted 2006) [#3]
Wow, just loaded the BRL maxide.bmx file. Instantly.

Now to be fair, you're not currently highlighting everything, but still...

Couple more:
- code navigation tree
- highlight block of code you're currently in, e.g. background normally white, current block in that nice orangey colour, or make the separator lines bold?
- auto-collapse / auto-expand all
- some way of grouping declarations into a foldable block would be nice, although this is a bit tricky as max doesn't enforce declarations at the top of a type / function, and could be scatterred.


Perturbatio(Posted 2006) [#4]
- ctrl+arrow should select to end of current word, and if pressed again, to next word. (i think that's right, check textarea behaviour)


Nope, should be CTRL+SHIFT+ARROWS

SHIFT+END to select to the end of the line
SHIFT+HOME to select to the beginning
CTRL+SHIFT+HOME to select to the beginning of the textarea
CTRL+SHIFT+END to select to the end

CTRL+ARROW to jump the cursor one word.
etc.


Looking good btw :)


dmaz(Posted 2006) [#5]
- Rem & EndRem support (should generate an auto-end rem like function & method do, and should be foldable too)
next on my list
- If blocks should also be foldable.
this one is hard... if and then or just if.... I already can fold if endif but a straight if will break
- Case statements within a select should possibly be foldable
dont' know about this one
- double click a word selects all of that word
planned
- shift+arrow should select blocks of code
planned
- ctrl+arrow should select to end of current word, and if pressed again, to next word. (i think that's right, check textarea behaviour)
planned
- Should the first line be 0 or 1? ;)
yeah it should be but it might be too late
- templates would be nice
ide?
- right click menu to access common functions
ide?
- when selecting a block, allow tab and shift-tab to do block outdent / indent
planned
- auto-indent (e.g. if x then should add a tab to next line)
wait.... it does...?
- undo / redo (not just the last one either - multiple undos)
planned
- I'd like to see a gutter available on the left to indicate stuff. e.g. break points, todos, etc.
planned... break points, ide I think
- auto-complete
planned
- help on commands (e.g. show a tooltip-a-like under the command once types with the mini-help, then F1 to jump to full help).
planned and ide
- multi-language support (C, C++, HTML, XML)
done, well mostly done.

As for your comment about writing an IDE, once it's linux friendly too, I'd love to look into plugging this into the CE IDE.

Yep! that's why I wrote it... but I did get a little carried away I think, since this will gut some of that. BTW, it should be linux friendly I just haven't compiled it there yet.

Wow, just loaded the BRL maxide.bmx file. Instantly.

Now to be fair, you're not currently highlighting everything, but still...

Couple more:
- code navigation tree
- highlight block of code you're currently in, e.g. background normally white, current block in that nice orangey colour, or make the separator lines bold?
- auto-collapse / auto-expand all
- some way of grouping declarations into a foldable block would be nice, although this is a bit tricky as max doesn't enforce declarations at the top of a type / function, and could be scatterred.

well I think the only thing I'm not highlighting that maxide does is the secondary keywords like CreateGadget. that is not expensive at all, finding the start and end of blocks for folding and rem type things is what slows it down.

-code navigations tree, well I was thinking about adding lists in the control which the programmer of the ide can access for those...
-hightlight block of code, really...? I can add that. all colors are changable btw. you can even assign different colors to the arrows.
-auto-collapse yeah, grouping declarations... once rem and end rem type statement working then it's just a matter of defineing it in the language definition. for blitz 'Region comment..... 'End Region


I did notice that there were a bunch of things I broke over the last couple of days... still have a ways to go.


Mark Tiffany(Posted 2006) [#6]
Re: CE & IDE, yeah, I had figured you were hoping to plug it in from comments you made a while back: I was just checking that you hadn't gone all capitalist, and wanted to write your own. ;)

In terms of when to try plugging it in, I think that comes when undo / redo and the other standard keyboard shortcuts are in (copy/paste/select words/etc) outlined above. All the rest can be added later...

Also, the comments about what's in the control and what's in the IDE, you're absolutley right that many of the things I mentioned need to be exposed to the programmer, not necessarily hard coded into the control itself.

For example, auto-collapse etc are logically icons in the IDE - we'd just need to make sure there's a method available to tell the textarea to do it. Things like the gutter, I think there needs to be a mechanism for the IDE to set an image in the gutter on any given line, but again probably isn't part of the control itself.

I did mean to ask about the linux piece - whether it's known not to work on linux or just not compiled there yet. I'll try to dust off my linux box over the weekend and give it a go, although I'm kind of hoping Brucey might pop his head in here...

On folding If's, it ought to be possible to determine whether it's single line - the compiler does. Which isn't to say it's easy! I do think there's a question about whether to fold to the next endif, or the else, or elseif though...and this kind of applies to the case statement folding thing.

On the auto-indent piece, I'm sure it didn't auto-indent after typing "If x then", although it did auto-indent on other things. I'm gussing this boils down to the same "I don't know if it's a single or multi line if" problem?

On the templates, there's two levels. One is a set of copy and paste templates, the other is that when you type Function xxx() and you currently add end function, that you could more than just end function. For example, a standard format rem block for commenting the code. The former is the IDE, the latter requires that the "standard auto-complete patterns" be exposed and configured by the IDE.


dmaz(Posted 2006) [#7]
I will concentrate on the basics and the bugs I know about. The api is pretty solid already, I expose most everything. I not going to get a chance to work on it though until the weekend…

thanks guys


Blueapples(Posted 2006) [#8]
Looks good, dmaz, looking forward to using this in the future possibly.


Mark Tiffany(Posted 2006) [#9]
I not going to get a chance to work on it though until the weekend…

No probs - I don't have much time either, as work is taking me to Glasgow (from Birmingham) for a couple of days a week at the moment.


Booticus(Posted 2006) [#10]
Oy! There a chance I could grab the demo again?? Just wanted to give it a run and seems the link is down. :)


dmaz(Posted 2006) [#11]
sure, here you go... remeber it's only a "control" and a work in progress so there is still much to do

PC DOWNLOAD


Booticus(Posted 2006) [#12]
Ahhhhhhhhhhhh that's NICE. Verrrryyyy nice. Would be killer to get THAT integrated with the IDE....ANY IDE.

FYI it loaded a 4300 line chunk of code and diddled its color coding in like a half second. Neat! Keep us posted!


dmaz(Posted 2006) [#13]
thanks... that's my plan, the CE ide for sure and others will be welcome.


skn3(Posted 2006) [#14]
Is this using a canvas so 3d acceleration for a textbox ? Or are you using native gdi (don't now what mac os uses) painting functions. Just curious.

It is looking good.

*edit*
I found a bug. When you stretch the window past a certain size, the redrawing seems to fail. I suspect it is using a canvas then.

also editing a function when there is alot of code after it, so changing "function lalal()" to "hellofunction la()" causes a massive 4-5 second pause!

Perhaps when you edit an existing block it needs to know where the block ends so it can know where to stop/pause the scan. it could then complete it once you change line ? That way you can make an alteration to the line and it will intelligently wait for you to finish typing before rescanning the entire doc.


dmaz(Posted 2006) [#15]
it is canvas, mac compatible. yeah, there are some bugs but the ones you mention I can't reproduce...

When you stretch the window past a certain size, the redrawing seems to fail.

how big? I have no problems stretching to 1600x1200

the block code doesn't scan on the edit you just described but normally it will only go to the end of the block or beginning of the block depending on which line you edited. I'm not going to worry about that one until I've stopped playing with different implementations of the blocking code.


dmaz(Posted 2006) [#16]
also editing a function when there is alot of code after it, so changing "function lalal()" to "hellofunction la()" causes a massive 4-5 second pause!

yeah, I can't reproduce that even with a 7000 line program. does this happen every time when you do the above? When exactly does the pause happen? do you type a space after hello? yeah, I know I said I wasn't going to worry about this one...


Booticus(Posted 2006) [#17]
Hey I duplicated skn3[ac]'s "stops updating" error as well, if I have the editor window solely on my secondary it works unless I expand it past a certain point. Primary monitor it works fine, expand to fullscreen too, the works.


skn3(Posted 2006) [#18]
dmaz, its when i type space before the action "function" part. So it changes to " function". Just causes an insane pause. I had loaded a 4000 line doc, then copied and pasted another 6000 lines at random. So some of the code blocks were probably broken.


dmaz(Posted 2006) [#19]
ok... thanks, I'll be able to test that tonight. I have an idea about what happened...


dmaz(Posted 2006) [#20]
skn3, I can't seem to get to do the pause.... I start with a 7300 line file then select 0-3300(w/blocks broken), copy find a random place and paste... when I paste there is about a 1 to 2 second delay there but after that all changes are immediate for me. did that a few times, by the end I was working with 17000 lines.

can you re-download (I'm pretty sure it's the same) and try it again.

can anybody else reproduce this?


Mark Tiffany(Posted 2006) [#21]
Can't reproduce the problem.

dmaz, not sure if you're aware, but in the CVS, I have a MAXIDE2 branch of code which is intended to be a substantial overhaul of code. Please feel free to upload your code area and start integrating with that branch of code as soon as you like. Not sure what your intention is code-wise (i.e. did you want to release the module, not the code?), but if you're happy to, please feel free to drop your source in too. I may even be able to help out on some of it...


dmaz(Posted 2006) [#22]
well that's good but I really don't like not knowing what something like that was...

yeah I have that branch. I still have a little cleanup but hopefully I will start incorporating it this weekend, next for sure. once I have a compile I will upload the changes...

Mark, it will gut lots of code... is that going to be alright or should you create another branch?


Mark Tiffany(Posted 2006) [#23]
Hmm, I'min the middle of restructuring a whole bunch of stuff to:

a) Simply tidy up the type structure
b) Simplify the way GUI elements operate into a single unified base type
c) Amend all the GUI elements such that they can be attached to any "panel"
d) Allow full re-configuring of "panels" in the IDE.

I think I need to get a little further, but I'll have a look to see if it will be possible to do the bare minimum on the existing "codepanel" types, such that you can then hack that section of code. Ideally, you'll only need to hit one or two files if I get this right...

I think it would probably be a good idea to schedule a chat over the weekend? drop me an email.


dmaz(Posted 2006) [#24]
for anyone interested in an update on this....

I've been decided I needed to move from using TMap to a ternary search tree so I ported one one those and will be implementing it shortly. I've also implemented blocks but I'm not yet fully satisfied with it. Other than that I haven't really done much more as work has been heavy, new girlfriend and I bought a Wii. this next week I will be out on vacation but I expect to get back to this the following week.