Hie all!
I’ve written a pretty long script with a loooooot of brackets.
I would love to find a way to close every brackets of my script with a hotkey but I didn’t find how!
Do you know if it’s possible ?
Thanks!
Hie all!
I’ve written a pretty long script with a loooooot of brackets.
I would love to find a way to close every brackets of my script with a hotkey but I didn’t find how!
Do you know if it’s possible ?
Thanks!
If you want to fold every bracket of a certain level then you’ll have to do it manually.
Here’s the example to play with. It needs some fix for un-folding, btw
( -- level 0
local hwnd = (dotNetClass "Autodesk.Max.GlobalInterface").Instance.TheMxsEditorInterface.EditorGetEditHWND
SCI_GETFOLDLEVEL = 2223
SCI_GETLINECOUNT = 2154
SCI_TOGGLEFOLD = 2231
SCI_GETLINEVISIBLE = 2228
SCI_GETLASTCHILD = 2224
folds = #()
for i = 0 to (windows.sendMessage hwnd SCI_GETLINECOUNT 0 0) - 1 do
( -- level 2
linefoldlevel = (bit.shift (windows.sendMessage hwnd SCI_GETFOLDLEVEL i 0) -16) - 1024
foldisexpanded = 1 == windows.sendMessage hwnd SCI_GETLINEVISIBLE i 0
foldendline = windows.sendMessage hwnd SCI_GETLASTCHILD i -1
format "line#% - expaned:% foldlevel:% foldend:%\n" (1+i) foldisexpanded linefoldlevel foldendline
-- should fold level 2 & 3 only
if linefoldlevel >= 2 and linefoldlevel <= 3 and foldisexpanded do
( -- level 3
-- windows.sendMessage hwnd SCI_TOGGLEFOLD i 0
-- fold testing
(
(
(
-- these won't be folded
)
)
)
append folds #( i, foldendline, linefoldlevel ) -- fold start line, fold last line, fold level
)
)
fn sortByFoldDepth a b = if a[3] > b[3] then -1 else if a[3] < b[3] then 1 else 0
qsort folds sortByFoldDepth
folded = #{}
for f in folds where not (folded[f[1]] and folded[f[2]]) and f[1] != f[2] do
(
windows.sendMessage hwnd SCI_TOGGLEFOLD f[1] 0
folded[f[1]] = true
folded[f[2]] = true
)
)
Not sure if it will work for you but, in the 3DsMax script editor if you close the brackets holding CTRL key all the contained nested brackets will close. If you open the bracket again (without holding CTRL key) the nested brackets will remain closed.