Hi all,
Manta (SciTE) wrote:
might still be nice to have a function that collapses only 'n' fold
It would be nice - if you figure it out, please share it with the list,
I would like to add that functionality to the default config of SciTE
for my team
Here is a folding/unfolding Lua function with a customizable depth
setting.
-- toggle folds, with customizable fold range
function FoldSome()
local FOLDSTART = 1024 -- level to start folding (from 1024)
local FOLDDEPTH = 3 -- fold depth; comment out if no
limit
--------------------------------------------------------------------
local FOLDEND = FOLDSTART + (FOLDDEPTH or 9999)
if FOLDEND <= FOLDSTART or FOLDEND > 4096 then FOLDEND = 4096 end
local start, ending, hide
editor:Colourise(0, -1) -- update doc's folding info
for ln = 0, editor.LineCount - 1 do
local foldRaw = editor.FoldLevel[ln]
local foldLvl = math.mod(foldRaw, 4096)
local foldHdr = math.mod(math.floor(foldRaw / 8192), 2) == 1
-- fold if within limits and is a fold header
if foldHdr and foldLvl >= FOLDSTART and foldLvl < FOLDEND then
local expanded = editor.FoldExpanded[ln]
if foldLvl == FOLDSTART and not start then -- start fold block
-- fix a hide/show setting for whole doc, for consistency
if hide == nil then hide = expanded end
start = ln + 1 -- remember range
ending = editor:GetLastChild(ln, foldLvl)
end
editor.FoldExpanded[ln] = not hide
end
-- if end of block, perform hide or show operation
if start and ln == ending then
if hide then
editor:HideLines(start, ending)
else
editor:ShowLines(start, ending)
end
start, ending = nil, nil
end
end--for
end
HTH,
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest