-
Notifications
You must be signed in to change notification settings - Fork 2
SciTE Code Assistance Helpers
Rickey Bowers Jr edited this page Feb 24, 2021
·
2 revisions
Putting this function within SciTEStartup.lua will monitor return keys to add terminating end lines for macro instructions.
local eol_tbl = {[0]="\r\n", [1]="\r", [2]="\n"}
local tag_tbl = {["calminstruction"]=1,["namespace"]=1,["macro"]=1,["iterate"]=0,["repeat"]=0,["match"]=0,["if"]=0}
function OnChar(char)
if char == "\n" then
line = editor:GetLine(editor:LineFromPosition(editor.CurrentPos - 1))
_,_,whitespace,keyword = string.find(line,"^(%s*)(%w+)")
if keyword ~= nil then
local foldit = tag_tbl[string.lower(keyword)]
if foldit ~= null then
if foldit==1 then
--TODO: update folding
end
local eol = eol_tbl[editor.EOLMode]
local pos = editor.CurrentPos
editor:AddText(eol .. whitespace .. "end " .. keyword)
editor:GotoPos(pos)
end
end
end
end