About Scite specifying the folding level

The popular SciTE-based AutoHotkey Script Editor
cgx5871
Posts: 315
Joined: 26 Jul 2018, 14:02

About Scite specifying the folding level

20 Jan 2024, 00:15

The following is the lua code

Code: Select all

function ToggleFoldLv(x)
--~     if editor.Lexer == SCLEX_AU3 then
        -- clear output pane when debugging
        output:ClearAll()
        fldonlev=tonumber(x)
--~         print("### Fold toggle fold level ", fldonlev)
        local savlinlev1=-1
        local fldinlev1=0
        for a = 0, editor.LineCount-1, 1
        do
            if editor.FoldParent[a+1] < savlinlev1 then
--~            print("End of fold block",a+1)
                savlinlev1=editor.FoldParent[a+1]
                fldinlev1=fldinlev1-1
            elseif editor.FoldParent[a+1] > savlinlev1 then
--~            print("Start of fold block")
                savlinlev1=editor.FoldParent[a+1]
                if fldonlev == fldinlev1 then
--~                print("! Toggle fold for line ", a+1)
                    editor:ToggleFold(a)
                    prefold=fldonlev
                end
                fldinlev1=fldinlev1+1
            end

        end
end
ToggleFoldLv(3)
I found a piece of Lua code in the AU3 forum that can specify the level of folding.
There is a problem with this code
If the level is smaller than the specified level, all will be expanded.
What I hope is that if it is smaller than the specified level, it will also be folded.
Can anyone help modify this code?

Return to “SciTE4AutoHotkey”

Who is online

Users browsing this forum: No registered users and 95 guests