Discussion:
Custom folding outside of the lexer
Paul K
2014-07-10 05:28:59 UTC
Permalink
Neil:

I'm trying to add custom folding after lexing is already done and can't
figure out the sequence of steps to achieve that. It seems to be possible
(at least according to the documentation), but I can't figure out why the
following is not working:

e:SetFoldLevel(3, e:GetFoldLevel(3) + 1 + wxstc.wxSTC_FOLDLEVELHEADERFLAG)
e:SetFoldLevel(4, e:GetFoldLevel(4) + 1)
e:SetFoldLevel(5, e:GetFoldLevel(5) + 1)
e:SetFoldLevel(6, e:GetFoldLevel(6) + 1)

I'd like to start my fold on line 3 and end on line 6. Just in case, the
text I'm applying it to looks like this:

if true then
if false then
end
--#start
print '1'
print '2'
--#end
end

The folding is shown for the "if" statements (Lua lexer), but I also want
to add another fold level for the lines marked by --#start and --#end. Is
it possible and if so, what am I doing wrong?

Paul.
--
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/d/optout.
Neil Hodgson
2014-07-10 22:55:59 UTC
Permalink
Implementing folding completely in your own code should work but I don't expect trying to modify the results of a built in folder will work since your changes will be overwritten when the folder is next called. Its not something I have ever tried.

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/d/optout.
Paul K
2014-07-11 00:14:42 UTC
Permalink
Implementing folding completely in your own code should work but I don’t
expect trying to modify the results of a built in folder will work since
your changes will be overwritten when the folder is next called. Its not
something I have ever tried.

I realize that and expect that code to be executed in something like
UPDATEUI handler, but I couldn't get folding markers to show up, so I
wasn't sure if the logic is correct. I tried it in UPDATEUI handler and it
does execute (at least once), but I don't see any folding indicators
updated:

e:Connect(wxstc.wxEVT_STC_UPDATEUI, function ()
if e:GetFoldLevel(3) < wxstc.wxSTC_FOLDLEVELHEADERFLAG then -- will use
check for bit mask
e:SetFoldLevel(3, e:GetFoldLevel(3) + 1 +
wxstc.wxSTC_FOLDLEVELHEADERFLAG)
e:SetFoldLevel(4, e:GetFoldLevel(4) + 1)
e:SetFoldLevel(5, e:GetFoldLevel(5) + 1)
e:SetFoldLevel(6, e:GetFoldLevel(6) + 1)
end
end)

Is there something I'm doing incorrectly?

Paul.
--
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/d/optout.
Neil Hodgson
2014-07-11 01:43:34 UTC
Permalink
Post by Paul K
...
Is there something I'm doing incorrectly?
I can't see anything but its not something I have looked into so the sequencing may be wrong. At this point I'd run it in a debugger or add some traces to see what the sequence of fold setting calls is.

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/d/optout.
Loading...