Mit den folgenden beiden Funktionen, schon verpackt als Eintrag für SciTEUser.properties, könnt ihr Bereiche anhand eines Lua-String-Patterns festlegen, die alle gemeinsam ein- oder ausgeklappt werden sollen.
Ich habe hier im Bsp. die Funktionsdeklaration gewählt. Das Pattern gilt für die erste Zeile des Faltbereiches.
pattern = '^[Ff][Uu][Nn][Cc]%s'
Bedeutet:
- Zeilenanfang
- "Func" (egal ob Groß- oder Kleinschreibung)
- Leerzeichen
EDIT:
Hatte mich leider in der Zeilenumbrucherkennung vertan, hatte nur LF erkannt. Jetzt gültig für CRLF.
EDIT 2:
Ich sammle hier mal Pattern, wenn mir was einfällt.
- Funktionsdeklaration: pattern = '^[Ff][Uu][Nn][Cc]%s'
- UDF-konforme Funktionsheader: pattern = '^; #FUNCTION# '
# 31 FOLD ALL FUNC
command.name.31.*.au3=Fold all Function definitions
command.31.*.au3=dostring \
pattern = '^[Ff][Uu][Nn][Cc]%s' \
nLine = 0 \
text = editor:GetText() \
for line in (text..'\r\n'):gmatch("(.-)"..'\r\n') do \
if line:find(pattern) then \
if editor.FoldExpanded[nLine] == true then \
editor:GotoLine(nLine) \
scite.MenuCommand(IDM_EXPAND) \
end end nLine = nLine +1 \
end
command.mode.31.*.au3=subsystem:lua
command.shortcut.31.*.au3=Alt+Shift+F8
# 32 UN-FOLD ALL FUNC
command.name.32.*.au3=Un-Fold all Function definitions
command.32.*.au3=dostring \
pattern = '^[Ff][Uu][Nn][Cc]%s' \
nLine = 0 \
text = editor:GetText() \
for line in (text..'\r\n'):gmatch("(.-)"..'\r\n') do \
if line:find(pattern) then \
if editor.FoldExpanded[nLine] == false then \
editor:GotoLine(nLine) \
scite.MenuCommand(IDM_EXPAND) \
end end nLine = nLine +1 \
end
command.mode.32.*.au3=subsystem:lua
command.shortcut.32.*.au3=Alt+Shift+F9
Alles anzeigen
Passt die command-Nr. und den shortcut an euer System an (Wie es geht habe ich schon in mehreren Posts hier beschrieben).
Das könnt ihr dann auch für andere Bereiche nutzen, die ihr in einem Rutsch aus- oder einklappen möchtet. Die Zeile mit der Pattern-Definition dazu entsprechend anpassen.
Viel Spaß.