Difference (from prior major revision)
(no other diffs)
Changed: 7c7
-- by 2011.04.17 lee.sheen@gmail.com
|
-- by 2011.04.22 lee.sheen@gmail.com
|
Added: 18a19
removeCtagsFile(ctagsFilename)
|
Added: 110a112,115
function removeCtagsFile(ctagsFilename) os.remove(ctagsFilename) end
|
This is a simple Lua script to show the function list of the current editing source file in the output pane. If you'd like to move to the function that you are looking for, you just need to click the function name in the output pane.
SciteFuncList depends on the [ctags] and SciteTags, so you need to prepare these before using SciteFuncList.
scite_Command {
'Function List|functionList|Ctrl+/',
}
function functionList()
local sourceFilename = props["FilePath"]
local ctagsFilename = sourceFilename .. ".ctags"
makeCtagsFile(sourceFilename, ctagsFilename)
readCtagsFile(ctagsFilename)
removeCtagsFile(ctagsFilename)
end
function makeCtagsFile(sourceFilename, ctagsFilename)
local makeCtagsCommand = "ctags -u -f " .. ctagsFilename .. " " .. sourceFilename
os.execute(makeCtagsCommand)
end
function readCtagsFile(ctagsFilename)
print()
io.input(ctagsFilename)
while true do
local line = io.read("*line")
if line == nil then break end
if not isCommentLine(line) then
print(getFunctionName(line))
end
end
end
function isCommentLine(line)
return '!' == string.sub(line, 0, 1)
end
function getFunctionName(line)
local ctagsTable = {}
ctagsTable = splitCtagsLine(line)
local functionName = makeFunctionName(ctagsTable)
local searchString = makeSearchString(ctagsTable)
return functionName, searchString
end
function splitCtagsLine(line)
local t = {}
local l = 0
local r = 0
while true do
r = string.find(line, "\t", l)
if r == nil then
r = #line + 1
end
local name = string.sub(line, l, r - 1)
t[#t + 1] = name
l = r + 1
if #line <= l then break end
end
return t
end
function makeFunctionName(ctagsTable)
local functionName = ctagsTable[1]
return functionName
end
function makeSearchString(ctagsTable)
local searchString = nil
local s = string.sub(ctagsTable[3], 0, #ctagsTable[3] - 2)
local l = 0
local r = 0
while true do
r = string.find(s, "\\", l)
if r == nil then
r = #s + 1
elseif string.sub(s, r + 1, r + 1) == "\\" then
r = r + 1
end
local name = string.sub(s, l, r - 1)
if searchString == nil then
searchString = name
else
searchString = searchString..name
end
l = r + 1
if #s <= l then break end
end
return searchString
end
function removeCtagsFile(ctagsFilename)
os.remove(ctagsFilename)
end
RecentChanges · preferences
edit · history
Last edited April 22, 2011 3:58 pm GMT (diff)