Skip to content

Instantly share code, notes, and snippets.

@SpotlightKid
Last active July 15, 2018 08:51
Show Gist options
  • Save SpotlightKid/9964085 to your computer and use it in GitHub Desktop.
Save SpotlightKid/9964085 to your computer and use it in GitHub Desktop.
Lua script to select folding block in Geany editor
--[[
Select block corresponding to current folding level
--]]
line, col = geany.rowcol()
-- Scintilla uses 0-based line numbering internally
line = line - 1
--~print("L: " .. line .. " C: " .. col)
fstart = geany.scintilla("SCI_GETFOLDPARENT", line)
--~print("S: " .. fstart+1)
fend = geany.scintilla("SCI_GETLASTCHILD", line, -1)
--~print("E: " .. fend+1)
if fend == line then
fend = geany.scintilla("SCI_GETLASTCHILD", fstart, -1)
sstart = geany.rowcol(fstart + 1, 0)
send = geany.rowcol(fend + 2, 0)
else
sstart = geany.rowcol(line + 1, 0)
send = geany.rowcol(fend + 2, 0)
end
geany.select(send, sstart)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment