Skif-off left a comment (geany/geany-plugins#1527) A little better: ```lua -- Select-folding-block.lua (cross-platform) --2025.12.14 --[[ Details: https://github.com/geany/geany-plugins/issues/1527
Selects the text inside the current folding block. odd(), bit_and(): http://mydc.ru/topic334.html ]] local function odd(x) return math.floor(x / 2) * 2 ~= x end local function bit_and(x, y) local c, s = 0, 1 while x > 0 or y > 0 do if odd(x) and odd(y) then c = c + s end s = s * 2 x = math.floor(x / 2) y = math.floor(y / 2) end return c end local function GetFoldLevel(iN) -- SCI_GETFOLDLEVEL(line) & SC_FOLDLEVELNUMBERMASK local n = geany.scintilla("SCI_GETFOLDLEVEL", iN) return bit_and(n, 0x0fff) end -- Current line local iT = geany.scintilla("SCI_GETCURRENTPOS") local iL = geany.scintilla("SCI_LINEFROMPOSITION", iT) -- Line number of the start of the folding block local iFB = geany.scintilla("SCI_GETFOLDPARENT", iL) if iFB == -1 then geany.message("Select folding block", "Not found or other problem. Exit.") return end -- Position at the start of the line local iSB = geany.scintilla("SCI_POSITIONFROMLINE", iFB) -- Line number of the end of the folding block -- local iFE = geany.scintilla("SCI_GETLASTCHILD", iL, -1) -- I didn't understand or failed, so we will forget about SCI_GETLASTCHILD -- and will stupidly search for the same fold level as the current line local iFE local iFL = GetFoldLevel(iL) local iN = geany.height() for i = iL + 1, iN do iT = GetFoldLevel(i) if iT < iFL then iFE = i - 1 break end end -- Position at the end of the line, before any line end characters local iSE = geany.scintilla("SCI_GETLINEENDPOSITION", iFE) -- Select block geany.select(iSB, iSE) ``` -- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/issues/1527#issuecomment-3649874871 You are receiving this because you are subscribed to this thread. Message ID: <geany/geany-plugins/issues/1527/[email protected]>
