Forums

Code Folding Strategy

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Code Folding Strategy

Postby RIGHT_THEN » Sun Feb 27, 2011 7:09 am

Sorry i dont know how to delete it so i just edited it to
nothing. i might invoke this topic some time later thou.

ThankingYou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Code Folding Strategy

Postby Charles » Sun Feb 27, 2011 9:58 am

That's okay. We can just leave it to stimulate conversation or as a placeholder for the future. :-)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Code Folding Strategy

Postby torial » Mon Feb 28, 2011 9:05 am

WRT code folding, the Alsing SyntaxBox that I've been using in my slowly progressing editor/IDE project doesn't seem to easily support python-like syntax for code folding. So I'm going to have to explore this concept as well. Add at least one more interested party to this discussion!
torial
 
Posts: 229
Location: IA

Re: Code Folding Strategy

Postby Charles » Mon Feb 28, 2011 9:23 am

I have a theory that when one finds code folding necessary then there is something wrong with the code: the methods and/or classes are too long.

I don't even use code folding in Visual Studio with C#, or anywhere else. Do you?

I navigate with page up, page down, go to definition and find (file or project based).
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Code Folding Strategy

Postby torial » Mon Feb 28, 2011 9:29 am

I typically will use code folding w/ C# especially with regions. Where I would separate event handlers into their own region, public functions, or related sets of functions (whether overloads or similar functions). In C#, I've also made extensive use of folding while maintaining legacy systems. I've seen large functions that were 1000+ lines in production, and didn't want to navigate through that.

ALSO, I should be upfront, I suck at learning keyboard shortcuts for navigation (I have a co-worker who laughs at that), so probably use code folding as a crutch.
torial
 
Posts: 229
Location: IA

Re: Code Folding Strategy

Postby RIGHT_THEN » Tue Mar 01, 2011 1:19 am

Mr.Torial

editor you are working on is your personal or available for download
what code folding strategy did you apply.
to keep things simple i thought of INDENT and DEDENT as que points
for Folding that would make if`s and other things foldable also.

python has : as a que for initiating folding
cobra does not. so if one goes by keywords then 'def' 'class'
in case of 'def' one may try to match return but def even works without
explicit 'return' and there could be many 'returns' in 'def'. one would have to apply logic to get hold of the right one.

matching column number of INDENT and DEDENT where OCCURENCE of INDENT is
smaller than DEDENT and also the diffrence between INDENT charnum and DEDENT charnum if is smallest amongst all INDENTS and DEDENTS captured
should fold. this seems to be the only viable option as yet to me.
What do you Think??

as for regions they can be implemented very easily because '#' is allready a comment in Cobra so #region = start folding and #endregion = endfolding.

#if false can also be implemented similarly to aviod certain code compilation. #if false is actually better to keep code but avoid compiling than /**/ of c#.

Alsing SyntaxBox is there a reason for using this have you tried AvlonEdit or its predecessor

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Code Folding Strategy

Postby torial » Tue Mar 01, 2011 8:18 am

Well, I had actually written a "real" reply, but when I went to preview it, it all got lost. Sorry, don't have the heart to write it again right now.

Short version:
* I think the indent/dedent strategy is correct. I wasn't able to get the other strategy to work w/ the Alsing SyntaxBox. So the indent/dedent strategy is also what I've been considering.
* I'm not using AvalonEdit because of WPF, and the learning curve thereof. But last night I did explore the earlier versions of the editor, as I'd prefer to be in sync w/ any work you are doing.
* The CodeProject TextEditor sample (ie prior to AvalonEdit sample) has a simple folding strategy for just regions, which I was able to get running w/ the Cobra syntax file you defined, and the test regions I had put there worked.
* I'm not yet ready to release it, probably in a few weeks I will. Currently it only supports single files, and doesn't have folding support... and is limited in the options. I'm working on project support and then will likely release it under MIT.
* My next goal is to have test runner integration, so it can be run from a GUI.
torial
 
Posts: 229
Location: IA

Re: Code Folding Strategy

Postby torial » Tue Mar 01, 2011 8:19 am

<snip>
Last edited by torial on Tue Mar 01, 2011 9:38 pm, edited 1 time in total.
torial
 
Posts: 229
Location: IA

Re: Code Folding Strategy

Postby RIGHT_THEN » Tue Mar 01, 2011 8:46 am

Mr. torial

ScreenShot is appeasing and clean
at any time you charge for intellisense do inform
why are the lines in continuation and not breaking at dedents are
you not breaking out of the loop at the first match.

but i am not yet able to take the line correctly to the dedent because
i am using cobra tokeizer to detect INDENTS and DEDENTS and it does not seem to
correspond to avlonedits colum number or i have to correct my logic.i might be asking
you more on getting this right soon.

good to see your product thou.

THANKING_YOU
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Code Folding Strategy

Postby Charles » Tue Mar 01, 2011 5:20 pm

Torial, those are good points regarding cold folding.

Regarding your screenshot, that looks like a nice start.

Maybe it would be possible to separate out non-UI parts (often called the domain model) as much as possible and then have multiple UI subdirs such as WinForms, WPF and Monobjc (I'm on Mac most of the time).

Candidates for the domain model, which could be shared by all UI implementations, include at least:
-- File
-- Project
-- Project search
-- Configuration
-- MRU list
-- File system watching setup

There's probably more.

I'm not suggesting that you implement more than one UI. Just that you structure the code for it.

Assuming this would be an open source project that people could share. Maybe it's not.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Next

Return to Discussion

Who is online

Users browsing this forum: No registered users and 45 guests