--------------------------------------------------------- -- List: Functions/Procedures ---------------------------------------------------------- list_func:on_double_click(function(idx) local pos = list_func:get_item_data(idx) if pos then editor:GotoLine(pos) editor.Focus = true end end) local FIND_FUNC_REG_EXP = { ['cpp']="([^.,<>=\n]-[ :][^.,<>=\n%s]+[(][^.<>=)]-[)])[%s\/}]-%b{}", ['js']="(\n[^,<>\n]-function[^(]-%b())[^{]-%b{}", ['vbs']="(\n[SsFf][Uu][BbNn][^\r]-)\r", ['css']="([%w.#-_]+)[%s}]-%b{}", ['pas']="\n[pPfF][rRuU][oOnN][cC][eEtT][dDiI][uUoO][rRnN].(.-%b().-)\n", ['py']="\n%s-([dc][el][fa]%s-.-):", ['*']="\n[local ]*[SsFf][Uu][BbNn][^ .]* ([^(]*%b())", } local FIND_FUNC_REG_EXP_LEX_IDX = { ['cpp']='cpp', ['js']='js', ['vb']='vbs', ['vbscript']='vbs', ['css']='css', ['pascal']='pas', ['python']='py', } local FIND_FUNC_REG_EXP_EXT_IDX = {} local function fill_func_reg_exp_idx() local patterns = { [props['file.patterns.cpp']]='cpp', [props['file.patterns.wsh']]='js', [props['file.patterns.vb']]='vbs', [props['file.patterns.wscript']]='vbs', ['*.css']='css', [props['file.patterns.pascal']]='pas', [props['file.patterns.py']]='py', } for i,v in pairs(patterns) do for ext in (i..';'):gfind("%*%.([^;]+);") do FIND_FUNC_REG_EXP_EXT_IDX[ext] = v end end end fill_func_reg_exp_idx() function fill_list_func() list_func:clear() local findPattern = FIND_FUNC_REG_EXP [FIND_FUNC_REG_EXP_EXT_IDX [props["FileExt"]]] if not findPattern then findPattern = FIND_FUNC_REG_EXP [FIND_FUNC_REG_EXP_LEX_IDX [editor.LexerLanguage]] if not findPattern then findPattern = FIND_FUNC_REG_EXP ['*'] end end local textAll = editor:GetText() local startPos, endPos, findString startPos = 1 while true do startPos, endPos, findString = string.find(textAll, findPattern, startPos) if startPos == nil then break end findString = findString:gsub("[\r\n]", ""):gsub("%s+", " ") local line_number = editor:LineFromPosition(startPos) list_func:add_item(findString, line_number) startPos = endPos + 1 end end |