该脚本收集函数并在用户表中显示。它与 php 文件一起使用。没有 oop 设计。我希望有时间开发这个脚本。
function UserListShow(list)
local s = ''
local sep = ';'
local n = table.getn(list)
for i = 1,n-1 do
s = s..list[i]..sep
end
s = s..list[n]
editor.AutoCSeparator = string.byte(sep)
editor:UserListShow(12,s)
editor.AutoCSeparator = string.byte(' ')
end
function AllLinesWithText(txt,flags)
if not flags then flags = 0 end
local s,e = editor:findtext(txt,flags,0)
local result = {}
while s do
local l = editor:LineFromPosition(s)
func = strip(editor:GetLine(l))
table.insert(result,func)
s,e = editor:findtext(txt,flags,e+1)
end
return result
end
function strip(str)
str=string.gsub(str, "^%s+","")
if string.find(str, "\r\n") then
return string.gsub(str, "\r\n", "")
else
return string.gsub(str, "\n", "")
end
end
function charAt(n)
return string.char(editor.CharAt[n])
end
function getCurrentWord()
_curpos = editor.CurrentPos
regexp = "[a-zA-Z_]"
curpos = _curpos
char=charAt(curpos)
right=''
while string.find(char,regexp) do
right=right..char
curpos = curpos + 1
char=charAt(curpos)
end
regexp = "[a-zA-Z_]"
curpos = _curpos-1
char=charAt(curpos)
left=''
while string.find(char,regexp) do
left=char..left
curpos = curpos - 1
char=charAt(curpos)
end
result = left..right
if result == '' then
return false
else
return result
end
end
function isInFunctionTable(table,value)
indicator = false
for k,v in pairs(table) do
if string.find(v,("^function "..value)) then indicator = true end
end
return indicator
end
function DisplayFunctions()
function_catch = '^[ |\t]*function [a-zA-Z0-9_:&]*([a-zA-Z0-9,_ \$\=\&]*)'
ki = AllLinesWithText(function_catch,SCFIND_REGEXP)
current_word = getCurrentWord()
if (current_word) and (isInFunctionTable(ki,current_word)) then
local s,e = editor:findtext("^[ |\t]*function "..current_word,SCFIND_REGEXP,0)
editor:GotoPos(s)
else
if ( table.getn(ki) > 0 ) then
UserListShow(ki)
end
end
return 0
end
function OnUserListSelection(listID, s)
local s,e = editor:findtext(s,SCFIND_REGEXP,0)
editor:GotoPos(s)
return 0
end
最近更改 · 偏好设置
编辑 · 历史记录
最后编辑于 2017 年 2 月 27 日下午 12:52 GMT (差异)