-- TIME_STAMP 2013-05-04 14:32:52 v 0.1 ---------------------------------------------------------------------------------------------------------------------------------- -- Beschreibung..: Ermittlung der im Skript deklarierten Funktionen -- ..............: In der EndFunc-Zeile wird " ;==>FUNKTIONSNAME" angehängt -- ..............: Nicht wirksam in auskommentierten Zeilen ---------------------------------------------------------------------------------------------------------------------------------- local IsComment = function(_pos) local tComment = {1,2} if tComment[editor.StyleAt[_pos]] == nil then return false else return true end end local InSense = function(_s) _s = _s:gsub("%a", function(_c) return string.format("[%s%s]", _c:upper(),_c:lower()) end) return _s end local pattFunc = '()('..InSense('func')..'%s+([%w_]+)%s-%b().-'..InSense('endfunc')..')' local t, s, firstVisible, a, f, fname, iLines, pos, e = {}, editor:GetText(), editor.FirstVisibleLine for a, f, fname in s:gmatch(pattFunc) do _, iLines = f:gsub('\n', '\n') table.insert(t, {editor:LineFromPosition(a) + iLines, fname}) end editor:BeginUndoAction() for i = 1, #t, 1 do editor:GotoLine(t[i][1]) pos = editor:PositionFromLine(t[i][1]) if not IsComment(pos) then _, e = editor:GetCurLine():find(InSense('endfunc')) editor:SetSel(pos + e, pos + e) editor:DelLineRight() editor:InsertText(pos + e, ' ;==>'..t[i][2]) end end editor:EndUndoAction() editor.FirstVisibleLine = firstVisible scite.MenuCommand(IDM_SAVE)