must be optional !
Posted: Mon Jan 07, 2008 7:28 pm
If this were a feature, I would likely have it OFF (!) almost all of the time.
I am one of those people who barely ever uses it in C#, and I've used that for quite a few midsize projects. I just find it isn't terribly practical addition to the way I [personally] write code. The first thing I generally do is turn folding off when I open a VS solution with various regions collapsed. I just don't like not being able to see everything.
Don't get me wrong, though, I actually would like to *have* the option. The only time I see using it that much is when reviewing a project, either when starting it, or when reviewing a big round of my recent work. Personally, I like seeing ALL of the code I write with nothing hidden that could be biting me at compile time. Of course, I don't generally do things like put more than one class definition per file, so that's why it doesn't sound very appealing to me. I keep my code as modularized as I possibly can.
We've beat this dead horse a thousand times already, but there is one way I can think of to make it work in as simplistic a fashion as possible - with a Namespace2 that has an alternate bracketing mechanism. Even if a "bracket is designated as "#region" and "#endregion", the folding needs to ignore things inside of a comment, syntax block, string, etc.
Then there's also the problem I should mention of being sure the folding-start and folding-end brackets don't have characters that are also regular brackets or operators, because the existing TextPad applies a pretty simple approach to determining what type of code gets what type of color treatment. I've run into these limitations before. Like if I assign a SingleComment to a # for a Perl-esque language, there is no way for me to also have the # character be colored correctly when in another context.. such as when existing in a bare-looking string like s/#search/replace/gi, and even though perl definitely supports using that character for things like an alternate matching operand like m#regex-match-test#. To help combat occurrences of these oddities from screwing up my syntax highlighting for cgi scripts, I use a triple ### for a SingleCommentAlt. Not great, but it does basically work. Anyways, the short version of my comment here should just be that this is a very difficult problem, only complicated by things like how to even approach what code instrumentation should be matched against the fold start/end indicators.
The other final sticky point I'll mention is where to keep the data for what is and is not "folded". This data can't be in the file being edited itself, so it has to be in the workspace file. That's fine by me, but it isn't all that portable. There isn't a way around this issue unless TextPad starts spanning extra files like file.ext.folds all over the place - which sucks if you ask me, and I trust that Helios would only go with the workspace thing, just like it does for the existing bookmarks.
Personally, since I wouldn't use the feature, and since there are so many difficulties in applying a good, generic approach that will be as cross-platform [target] and multifunctional as TextPad's target end-use paradigm... I can see why it isn't in there yet.
- - -
On a more positive note:
To the person talking about bookmarking functions - use a macro. I have long used a macro that I run when I first open a file. It clears all bookmarks and then does a RegEx search and marks all lines matching something like:
^[[:space:]]*\(class\|function\|sub\|def\|type\)[[:space:]]\{1\}
I code in many languages, and this macro I use works very well for me when using any/all of my languages, including including PHP, Perl, ASP-VB, ASP-JScript, WSH, Python, and BlitzMax. There are probably specialized cases such as PHP/ASP with embedded Javascript in the HTML blocks due to the namespacing where this wouldn't necessarily work right off, but if you instrument your code properly, I think you will find it a quite successful approach... I've been doing it for many years :)
·· Z ··
I am one of those people who barely ever uses it in C#, and I've used that for quite a few midsize projects. I just find it isn't terribly practical addition to the way I [personally] write code. The first thing I generally do is turn folding off when I open a VS solution with various regions collapsed. I just don't like not being able to see everything.
Don't get me wrong, though, I actually would like to *have* the option. The only time I see using it that much is when reviewing a project, either when starting it, or when reviewing a big round of my recent work. Personally, I like seeing ALL of the code I write with nothing hidden that could be biting me at compile time. Of course, I don't generally do things like put more than one class definition per file, so that's why it doesn't sound very appealing to me. I keep my code as modularized as I possibly can.
We've beat this dead horse a thousand times already, but there is one way I can think of to make it work in as simplistic a fashion as possible - with a Namespace2 that has an alternate bracketing mechanism. Even if a "bracket is designated as "#region" and "#endregion", the folding needs to ignore things inside of a comment, syntax block, string, etc.
Then there's also the problem I should mention of being sure the folding-start and folding-end brackets don't have characters that are also regular brackets or operators, because the existing TextPad applies a pretty simple approach to determining what type of code gets what type of color treatment. I've run into these limitations before. Like if I assign a SingleComment to a # for a Perl-esque language, there is no way for me to also have the # character be colored correctly when in another context.. such as when existing in a bare-looking string like s/#search/replace/gi, and even though perl definitely supports using that character for things like an alternate matching operand like m#regex-match-test#. To help combat occurrences of these oddities from screwing up my syntax highlighting for cgi scripts, I use a triple ### for a SingleCommentAlt. Not great, but it does basically work. Anyways, the short version of my comment here should just be that this is a very difficult problem, only complicated by things like how to even approach what code instrumentation should be matched against the fold start/end indicators.
The other final sticky point I'll mention is where to keep the data for what is and is not "folded". This data can't be in the file being edited itself, so it has to be in the workspace file. That's fine by me, but it isn't all that portable. There isn't a way around this issue unless TextPad starts spanning extra files like file.ext.folds all over the place - which sucks if you ask me, and I trust that Helios would only go with the workspace thing, just like it does for the existing bookmarks.
Personally, since I wouldn't use the feature, and since there are so many difficulties in applying a good, generic approach that will be as cross-platform [target] and multifunctional as TextPad's target end-use paradigm... I can see why it isn't in there yet.
- - -
On a more positive note:
To the person talking about bookmarking functions - use a macro. I have long used a macro that I run when I first open a file. It clears all bookmarks and then does a RegEx search and marks all lines matching something like:
^[[:space:]]*\(class\|function\|sub\|def\|type\)[[:space:]]\{1\}
I code in many languages, and this macro I use works very well for me when using any/all of my languages, including including PHP, Perl, ASP-VB, ASP-JScript, WSH, Python, and BlitzMax. There are probably specialized cases such as PHP/ASP with embedded Javascript in the HTML blocks due to the namespacing where this wouldn't necessarily work right off, but if you instrument your code properly, I think you will find it a quite successful approach... I've been doing it for many years :)
·· Z ··