-- TIME_STAMP 2014-01-29 22:07:32 v 0.1 --[[ Installation: SciTE4AutoIt - "SelectStatement.lua" in den Lua-Skriptordner kopieren - In "SciTEStartup.lua" anfugen LoadLuaFile("PATH\\SelectStatement.lua") - Shortcut erstellen, command.NR.*.au3=Statement.ShowStatementList() SciTE-RU - "SelectStatementRU.lua" in den Lua-Skriptordner kopieren - In "COMMON.lua" einfugen dofile("PATH\\SelectStatement.lua") Statement.Handler() - Shortcut erstellen, command.NR.*.au3=Statement.ShowStatementList() Anwendung: - Code markieren - Shortcut aufrufen - der Code wird in das Statement eingebettet ]] Statement = {} Statement.GetReplacement = function(_sel) local selStart = editor.SelectionStart local sSelection = editor:GetSelText():gsub('(\r\n)$', ''):gsub('(\r\n)', '\n\t') local tStatements = { ["If-Then"] = {"If Then\n\t"..sSelection.."\nEndIf\n", 3}, ["If-Then-Else"] = {"If Then\n\t"..sSelection.."\nElse\n\t\nEndIf\n", 3}, ["If-Then-ElseIf"] = {"If Then\n\t"..sSelection.."\nElseIf Then\n\t\nEndIf\n", 3}, ["If-Then-ElseIf-Else"] = {"If Then\n\t"..sSelection.."\nElseIf Then\n\t\nElse\n\t\nEndIf\n", 3}, ["For-Loop"] = {"For \n\t"..sSelection.."\nNext\n", 4}, ["While-Loop"] = {"While 1\n\t"..sSelection.."\nWEnd\n", 6}, ["Do-Until"] = {"Do\n\t"..sSelection.."\nUntil \n", nil}, ["With-EndWith"] = {"With \n\t"..sSelection.."\nEndWith\n", 5}, ["Func-EndFunc"] = {"Func \n\t"..sSelection.."\nEndFunc\n", 5}} local iCol = nil if tStatements[_sel][2] then iCol = selStart + tStatements[_sel][2] else iCol = selStart + string.len(tStatements[_sel][1]) end return tStatements[_sel][1], iCol end Statement.ShowStatementList = function() local tList = {"If-Then", "If-Then-Else", "If-Then-ElseIf", "If-Then-ElseIf-Else", "For-Loop", "While-Loop", "Do-Until", "With-EndWith", "Func-EndFunc"} local sep = '•' local list = table.concat(tList, sep) local sep_tmp = editor.AutoCSeparator editor.AutoCSeparator = string.byte(sep) editor:UserListShow(15, list) editor.AutoCSeparator = sep_tmp end Statement.Handler = function() AddEventHandler("OnUserListSelection", function(tp, sel_value) if tp == 15 then local sReplacement, iCol = Statement.GetReplacement(sel_value) if iCol then editor:ReplaceSel(sReplacement) editor.CurrentPos = iCol editor:SetSel(iCol, iCol) end end end) end