April White wrote:
This version requires that the tool name match the function name, which
limits the name. The version I have at work builds a table of display
names/function names which gives a better display (tbl["Check out"] =
"co.bat") but the display order is not in the order added - does anyone
have any suggestions on how to keep a table in the order the items were
added?
Very nice, useful as I have a number of small routines which I don't
want to put in the tool menu.
Here is my take on ordering the list:
local udl_Separator = "~"
local udl_SuperAbbr = 10
local udl_ListTools = 15
local tools =
{
[1] = { "Normalize line", "Normalize" },
[2] = { "Sort all lines", "SortLines" },
[3] = { "Add XML Tag", "AddXMLTag" },
[4] = { "Super Abbreviations", "SuperAbbr" },
--~ [] = { "", "" }
}
local functionList = {}
local function udl_Initialize()
local tl = {}
for i, l in ipairs(tools) do
tl[i] = l[1]
functionList[l[1]] = l[2]
end
toolList = table.concat(tl, udl_Separator)
editor.AutoCMaxHeight = 10
end
function OtherTools()
editor:GrabFocus()
editorAutoCSeparator = editor.AutoCSeparator
editor.AutoCSeparator = string.byte(udl_Separator)
editor:UserListShow(udl_ListTools, toolList)
editor.AutoCSeparator = editorAutoCSeparator
end
function OnClear()
udl_Initialize()
return false
end
function OnUserListSelection(lt, choice)
if lt == udl_ListTools then
assert(loadstring(functionList[choice] .. "()"))();
return true
elseif lt == udl_SuperAbbr then
editor:InsertText(-1, abbrList[txt]["template"])
-- Should locate posChar, remove it and put the caret there
return true
else
return false
end
end
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest