On 07/07/2007 18:27, Jonathan Wilson wrote:
I know C++ and don't mind getting my hands dirty with the SciTE codebase
:) But if I can do what I need with the LUA interface, thats fine too.
I did something similar for another language (AutoHotkey aka. AHK).
The exact code parsing the script isn't relevant here, but I will give
you the code to display and use the resulting list of tags/lines.
It might not be perfect, but it can be a starting point.
-- User Defined Lists
local udl_Separator = "~"
local udl_SuperAbbr = 10
local udl_ListTools = 15
local udl_ListAHKFunctions = 20
function UserListShow(udl, list)
editorACS = editor.AutoCSeparator
editor.AutoCSeparator = string.byte(udl_Separator)
editor:UserListShow(udl, list)
editor.AutoCSeparator = editorACS
end
local ahkFunctions = {}
if string.lower(props["FileExt"]) == "ahk" then
dofile(props["SciteDefaultHome"] .. [[\ListAHKFunctions4SciTE.lua]])
else
ListAutoHotkeyFunctions = function () return nil end
end
function CreateAHKFunctionList()
local functionNb, functionList, labelNb, labelList,
hotkeyNb, hotkeyList, hotstringNb, hotstringList =
ListAutoHotkeyFunctions()
if functionNb == nil then return "" end
local menuItem
local rf, rl, rhk, rhs = '', '', '', ''
for i = 1, functionNb do
pl = string.gsub(functionList[i].parameters, "%s%s*", " ")
menuItem = "F [" .. functionList[i].line .. "] " ..
functionList[i].name .. "(" .. pl .. ")"
rf = rf .. menuItem .. udl_Separator
ahkFunctions[menuItem] = functionList[i].line
end
for i = 1, labelNb do
menuItem = "L [" .. labelList[i].line .. "] " .. labelList[i].name
rl = rl .. menuItem .. udl_Separator
ahkFunctions[menuItem] = labelList[i].line
end
for i = 1, hotkeyNb do
menuItem = "K [" .. hotkeyList[i].line .. "] " .. hotkeyList[i].name
rhk = rhk .. menuItem .. udl_Separator
ahkFunctions[menuItem] = hotkeyList[i].line
end
for i = 1, hotstringNb do
menuItem = "S [" .. hotstringList[i].line .. "] " ..
hotstringList[i].name
rhs = rhs .. menuItem .. udl_Separator
ahkFunctions[menuItem] = hotstringList[i].line
end
return string.gsub(rf .. rl .. rhk .. rhs, udl_Separator .. '$', '')
end
function ShowAHKFunctions()
UserListShow(udl_ListAHKFunctions, CreateAHKFunctionList())
end
function OnUserListSelection(lt, choice)
-- print("OnUserListSelection: " .. lt .. ", " .. choice)
-- Ignore the first two, it just shows how to manage several lists
if lt == udl_ListTools then
local tool = tools[choice]
tool[2]()
return true
elseif lt == udl_SuperAbbr then
editor:InsertText(-1, abbrList[choice]["template"])
-- Should locate posChar, remove it and put the caret there
return true
elseif lt == udl_ListAHKFunctions then
CreateAHKFunctionList() -- Re-create the list
editor:GotoLine(ahkFunctions[choice] - 1)
return true
else
return false
end
end
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
_______________________________________________
Scite-interest mailing list
Scite-interest@lyra.org
http://mailman.lyra.org/mailman/listinfo/scite-interest