Discussion:
Add fold header to the very last line?
Charly Dante
2014-02-16 16:04:31 UTC
Permalink
Hi,

I implemented a custom lexer with folding and everything works perfectly
fine. However, if I add a keyword which is asociated with folding to the
very last line,
it isn't recognized as long as I add a newline. For example:


void foo () { // Second last line, fold flag is added correctly here
if () // Very last line, no fold header is added until one
enters a newline


I would like to have a consistent behavior here and add a fold header when
the user is typing in the last line of the document (even if it could not
fold anything).


I already found something in PerLine.cxx, but I'm not sure what I have to
change exactly to get this to work. I tried changing the if in the function
LineLevels::SetLevel
from *if ((line >= 0) && (line < lines))* to *if ((line >= 0) && (line <=
lines))* but that seems to cause bugs as when adding newlines then, the
folder isn't closed anymore
at the end of the last line but remains open (vertical line instead of
T-line).

How can I achieve the desired behavior?

Best Regards,
CD
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-16 20:57:34 UTC
Permalink
I implemented a custom lexer with folding and everything works perfectly fine. However, if I add a keyword which is asociated with folding to the very last line,
it isn't recognized as long as I add a newline.
There are no subordinate lines to fold, so there is no visible indication of something to fold.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Charly Dante
2014-02-16 22:59:21 UTC
Permalink
Hi,

yes thats true. However, I'm currently rewriting an old lexer that provided
that feature back then (with some custom SciLexer.dll), so it is somehow
possible.

Could you please just give me some small hints where to modify what to
achieve this? That would be really nice :)

Best Regards,
CD
Post by Charly Dante
Post by Charly Dante
I implemented a custom lexer with folding and everything works perfectly
fine. However, if I add a keyword which is asociated with folding to the
very last line,
Post by Charly Dante
it isn't recognized as long as I add a newline.
There are no subordinate lines to fold, so there is no visible
indication of something to fold.
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-17 23:50:56 UTC
Permalink
yes thats true. However, I'm currently rewriting an old lexer that provided that feature back then (with some custom SciLexer.dll), so it is somehow possible.
Could you please just give me some small hints where to modify what to achieve this? That would be really nice :)
Diff the source for the old SciLexer.DLL with the desired behaviour against the distributed source for that version.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Charly Dante
2014-02-21 16:23:34 UTC
Permalink
Hi,

making a diff with the source of the old SciLexer.dll is unfortunatly not
possible, because it doesn't exist any more. I only have the compiled
binary, the source code was lost by the author.

Appart from that, there should be an option to allow zero-folders in my
opinion. The basic problem (and your argument) is, that on the end of the
document there are no subordinate lines to fold. This is correct, but that
situation occures not only at the end of the document, but in more cases.

Consider an indentation based language like for example MATLAB, were one
would like to add folding on if but also on elseif and else. One example
code could look like this:

if mycondition
% Do something
else
% Do something else
end

So, I would like to have a folding header on the if but as well on the
else. The folding header on the else should however not be nested, but have
the same folding level as the one on the if.

As long as there are statements writen in both the if block as well in the
else block, the folders are displayed as usually. But if a user writes
something like:

if mycondition
else
% Do something else
end

The fold header on the if disapears, because it has no subordinate lines.
This might make sense here, however for the user this behavior seems like
he has a syntax error in this line, because thats usually the case when
folding headers disapear. It would be much less confusing if the fold
header would just stay there and nothing happens when clicking on it (as
there is nothing to fold).

This is especially confusing as under different circumstances, namely when
the fold headers are nested and not at the same level, it is allowed to
have multiple fold headers above each others.

I guess one has just to change a few if-conditions in the Scintilla source
to achieve this so... can you add support for this or tell me which
functions have to be modified?


Best Regards,
CD
Post by Charly Dante
yes thats true. However, I'm currently rewriting an old lexer that
provided that feature back then (with some custom SciLexer.dll), so it is
somehow possible.
Post by Charly Dante
Could you please just give me some small hints where to modify what to
achieve this? That would be really nice :)
Diff the source for the old SciLexer.DLL with the desired behaviour
against the distributed source for that version.
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-21 22:13:28 UTC
Permalink
Post by Charly Dante
if mycondition
else
% Do something else
end
The fold header on the if disapears, because it has no subordinate lines. This might make sense here,
Yes.
Post by Charly Dante
however for the user this behavior seems like he has a syntax error in this line, because thats usually the case when folding headers disappear.
That appears unlikely to me. If its a problem for your users then it should be explained in the documentation.
Post by Charly Dante
This is especially confusing as under different circumstances, namely when the fold headers are nested and not at the same level, it is allowed to have multiple fold headers above each others.
I do not see this as at all confusing. Visible fold headers are there to allow the user to fold text. If folding is not possible then showing a fold header which has no effect would be confusing.
Post by Charly Dante
I guess one has just to change a few if-conditions in the Scintilla source to achieve this
This is just wishful thinking on your part. Examine the source code.
Post by Charly Dante
so... can you add support for this or tell me which functions have to be modified?
This is not a feature I am interested in so I will not work on it.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Charly Dante
2014-02-21 23:11:36 UTC
Permalink
Ok, I thought it would be quite simple to do this but it seems to be more
work than changing a few if conditions.

Thank you nevertheless for your fast answer, I will overthink this feature.
Post by Charly Dante
As long as there are statements writen in both the if block as well in
the else block, the folders are displayed as usually. But if a user writes
Post by Charly Dante
if mycondition
else
% Do something else
end
The fold header on the if disapears, because it has no subordinate
lines. This might make sense here,
Yes.
Post by Charly Dante
however for the user this behavior seems like he has a syntax error in
this line, because thats usually the case when folding headers disappear.
That appears unlikely to me. If its a problem for your users then it
should be explained in the documentation.
Post by Charly Dante
This is especially confusing as under different circumstances, namely
when the fold headers are nested and not at the same level, it is allowed
to have multiple fold headers above each others.
I do not see this as at all confusing. Visible fold headers are there to
allow the user to fold text. If folding is not possible then showing a fold
header which has no effect would be confusing.
Post by Charly Dante
I guess one has just to change a few if-conditions in the Scintilla
source to achieve this
This is just wishful thinking on your part. Examine the source code.
Post by Charly Dante
so... can you add support for this or tell me which functions have to be
modified?
This is not a feature I am interested in so I will not work on it.
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Charly Dante
2014-02-16 22:58:42 UTC
Permalink
Post by Charly Dante
Hi,
I implemented a custom lexer with folding and everything works perfectly
fine. However, if I add a keyword which is asociated with folding to the
very last line,
void foo () { // Second last line, fold flag is added correctly here
if () // Very last line, no fold header is added until one
enters a newline
I would like to have a consistent behavior here and add a fold header when
the user is typing in the last line of the document (even if it could not
fold anything).
I already found something in PerLine.cxx, but I'm not sure what I have to
change exactly to get this to work. I tried changing the if in the function
LineLevels::SetLevel
from *if ((line >= 0) && (line < lines))* to *if ((line >= 0) && (line <=
lines))* but that seems to cause bugs as when adding newlines then, the
folder isn't closed anymore
at the end of the last line but remains open (vertical line instead of
T-line).
How can I achieve the desired behavior?
Best Regards,
CD
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Continue reading on narkive:
Loading...