www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [feedback] folding in scintilla

reply maXmo <nospam nospam.org> writes:
cpp lexer folding in scintilla always seemed bizarre to me and I tried to
implement folding algorithm similar to that of akelpad or editplus.

https://sourceforge.net/tracker/?func=detail&aid=2986054&group_id=2439&atid=352439

What do you think?
Apr 12 2010
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
maXmo Wrote:

 cpp lexer folding in scintilla always seemed bizarre to me and I tried to
implement folding algorithm similar to that of akelpad or editplus.
 
 https://sourceforge.net/tracker/?func=detail&aid=2986054&group_id=2439&atid=352439
 
 What do you think?
Personally, I would prefer the left and right brace to stay on the same line as the function definition, and maybe add an elipsis between them so I can tell that function is folded just by looking at the code.
Apr 12 2010
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"maXmo" <nospam nospam.org> wrote in message 
news:hq083d$2qpo$1 digitalmars.com...
 cpp lexer folding in scintilla always seemed bizarre to me and I tried to 
 implement folding algorithm similar to that of akelpad or editplus.

 https://sourceforge.net/tracker/?func=detail&aid=2986054&group_id=2439&atid=352439

 What do you think?
I don't know if this is applicable or not, but one thing that drives me absolutely crazy is in Programmer's Notepad 2 is how collapsing this: foo { bar } Will collapse on the "{" line instead of the "foo" line. I hate that sooo much. Not sure if that's relevent to your patch, and not sure if PN2 uses scintilla or what, so take it for whatever it's worth.
Apr 12 2010
next sibling parent reply maXmo <nospam nospam.org> writes:
Nick Sabalausky Wrote:

 "maXmo" <nospam nospam.org> wrote in message 
 news:hq083d$2qpo$1 digitalmars.com...
 cpp lexer folding in scintilla always seemed bizarre to me and I tried to 
 implement folding algorithm similar to that of akelpad or editplus.

 https://sourceforge.net/tracker/?func=detail&aid=2986054&group_id=2439&atid=352439

 What do you think?
I don't know if this is applicable or not, but one thing that drives me absolutely crazy is in Programmer's Notepad 2 is how collapsing this: foo { bar } Will collapse on the "{" line instead of the "foo" line. I hate that sooo much. Not sure if that's relevent to your patch, and not sure if PN2 uses scintilla or what, so take it for whatever it's worth.
I had exactly same reason: old folding works only for sun style, my folding treats sun and ms style equally. See: http://i42.tinypic.com/2qjx1mf.png
Apr 12 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"maXmo" <nospam nospam.org> wrote in message 
news:hq0qrq$13pb$1 digitalmars.com...
 Nick Sabalausky Wrote:

 "maXmo" <nospam nospam.org> wrote in message
 news:hq083d$2qpo$1 digitalmars.com...
 cpp lexer folding in scintilla always seemed bizarre to me and I tried 
 to
 implement folding algorithm similar to that of akelpad or editplus.

 https://sourceforge.net/tracker/?func=detail&aid=2986054&group_id=2439&atid=352439

 What do you think?
I don't know if this is applicable or not, but one thing that drives me absolutely crazy is in Programmer's Notepad 2 is how collapsing this: foo { bar } Will collapse on the "{" line instead of the "foo" line. I hate that sooo much. Not sure if that's relevent to your patch, and not sure if PN2 uses scintilla or what, so take it for whatever it's worth.
I had exactly same reason: old folding works only for sun style, my folding treats sun and ms style equally. See: http://i42.tinypic.com/2qjx1mf.png
Ahh, I see. No, that's not what I was talking about. This is a mockup of the way I've been wanting it: http://www.semitwist.com/download/goodFolding.png Putting it on the line with the "{" seem ridiculous, ugly and just plain sloppy to me. (IMO).
Apr 12 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:hq142v$1hh9$1 digitalmars.com...
 "maXmo" <nospam nospam.org> wrote in message 
 news:hq0qrq$13pb$1 digitalmars.com...
 I had exactly same reason: old folding works only for sun style, my 
 folding treats sun and ms style equally.
 See: http://i42.tinypic.com/2qjx1mf.png
Ahh, I see. No, that's not what I was talking about. This is a mockup of the way I've been wanting it: http://www.semitwist.com/download/goodFolding.png Putting it on the line with the "{" seem ridiculous, ugly and just plain sloppy to me. (IMO).
Although, I do think your approach is still an improvement over the way it currently is.
Apr 13 2010
prev sibling parent reply maXmo <nospam nospam.org> writes:
Nick Sabalausky Wrote:

 Ahh, I see. No, that's not what I was talking about. This is a mockup of the 
 way I've been wanting it:
 
 http://www.semitwist.com/download/goodFolding.png
 
 Putting it on the line with the "{" seem ridiculous, ugly and just plain 
 sloppy to me. (IMO).
 
1. How should it work for sun style? 2. How should it work for multiline function signature?
Apr 13 2010
next sibling parent =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
maXmo wrote:
 Nick Sabalausky Wrote:
=20
 Ahh, I see. No, that's not what I was talking about. This is a mockup =
of the=20
 way I've been wanting it:

 http://www.semitwist.com/download/goodFolding.png

 Putting it on the line with the "{" seem ridiculous, ugly and just pla=
in=20
 sloppy to me. (IMO).
1. How should it work for sun style? 2. How should it work for multiline function signature?
I believe that XEmacs does the right thing here: fold on the line that contains the closing parenthesis of the function signature (or the if/switch/for/while condition), except for isolated blocks where they fold on the the line of the opening brace. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Apr 13 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"maXmo" <nospam nospam.org> wrote in message 
news:hq1k6n$2omq$1 digitalmars.com...
 Nick Sabalausky Wrote:

 Ahh, I see. No, that's not what I was talking about. This is a mockup of 
 the
 way I've been wanting it:

 http://www.semitwist.com/download/goodFolding.png

 Putting it on the line with the "{" seem ridiculous, ugly and just plain
 sloppy to me. (IMO).
1. How should it work for sun style? 2. How should it work for multiline function signature?
By "sun-style", I assume you mean like this: foo { } right? Well, the current folding rule scintilla uses is something like this: - Folding starts at (but does not include) any "{" in the source. What I have in mind is more like: - Folding starts at (but does not include) the last non-whitespace character just before any "{" in the source. (This would also make it work for a language like Go^H^H Issue 9) So, it would be like this mockup (top is sun-style, bottom is multi-line): http://www.semitwist.com/download/goodFoldingMore.png In any case, even if neither the opening nor closing curly brace is visible, I think the horizontal rule is sufficient in indicating that a block of code is hidden. But, if some people think that's too subtle (or to allow a VS.NET-style "hover to show the folded code in a popup tooltip"), then it could also do what Andrej suggested and place a specially-highlighted "{...}" (actually including the three dots) at the end of the line just before the horizontal rule. To properly handle something like this: void foo() { int x; { auto f = openFile(); scope(exit) closeFile(f); bar(f); } baz(); } I suppose you could modify the rule to something more like: - Folding starts at (but does not include) the last non-whitespace character just before any "{" in the source, as long as that character is a ")", otherwise just fold at (but not including) the whitespace character immediately before the "{" in question. or - Folding starts at (but does not include) the last non-whitespace character just before any "{" in the source, unless that character is a semicolon or another "{", in which case just fold at (but not including) the whitespace character immediately before the "{" in question.
Apr 13 2010
parent maXmo <nospam nospam.org> writes:
Nick Sabalausky Wrote:

 So, it would be like this mockup (top is sun-style, bottom is multi-line):
 
 http://www.semitwist.com/download/goodFoldingMore.png
 
Scintilla's folding is line-based: each line is assigned a fold level and folder hides lines according to these levels (kinda simple python-friendly algorithm), visible lines are displayed in their entirety.
Apr 13 2010
prev sibling parent maXmo <nospam nospam.org> writes:
Nick Sabalausky Wrote:

 I don't know if this is applicable or not, but one thing that drives me 
 absolutely crazy is in Programmer's Notepad 2 is how collapsing this:
 
 foo
 {
   bar
 }
 
 Will collapse on the "{" line instead of the "foo" line. I hate that sooo 
 much.
 
 Not sure if that's relevent to your patch, and not sure if PN2 uses 
 scintilla  or what, so take it for whatever it's worth. 
PN2 uses scintilla and by getting my patch into scintilla I hoped for this to be adopted in PN2 for I use it myself. I also planned to modify cpp lexer to fold code according to this algorithm, so that all C languages benefit from it.
Apr 12 2010
prev sibling parent Jussi Jumppanen <jussij zeusedit.com> writes:
Andrej Mitrovic Wrote:

 Personally, I would prefer the left and right brace to stay on the same 
 line as the function definition, and maybe add an elipsis between them 
 so I can tell that function is folded just by looking at the code.
That's a bit like how Zeus does it's folding: http://www.zeusedit.com/images/lookfold.png
Apr 13 2010