/trunk/PocketPlot/libs/AceConfig-3.0
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules. |
-- Options tables can be registered as raw tables, or as function refs that return a table.\\ |
-- These functions receive two arguments: "uiType" and "uiName". \\ |
-- Valid "uiTypes": "cmd", "dropdown", "dialog". This is verified by the library at call time. \\ |
-- The "uiName" field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\ |
-- :IterateOptionsTables() and :GetOptionsTable() always return a function reference that the requesting config handling addon must call with the above arguments. |
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\ |
-- Options tables can be registered as raw tables, OR as function refs that return a table.\\ |
-- Such functions receive three arguments: "uiType", "uiName", "appName". \\ |
-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\ |
-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\ |
-- * The **appName** field is the options table name as given at registration time \\ |
-- |
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". |
-- @class file |
-- @name AceConfigRegistry-3.0 |
-- @release $Id: AceConfigRegistry-3.0.lua 785 2009-04-05 14:57:29Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 9 |
-- @release $Id: AceConfigRegistry-3.0.lua 890 2009-12-06 12:50:05Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 11 |
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigRegistry then return end |
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry) |
end |
-- Lua APIs |
local tinsert, tconcat = table.insert, table.concat |
local strfind, strmatch = string.find, string.match |
local type, tostring, select, pairs = type, tostring, select, pairs |
local error, assert = error, assert |
----------------------------------------------------------------------- |
-- Validating options table consistency: |
for i=select("#",...),1,-1 do |
tinsert(t, (select(i, ...))) |
end |
error(MAJOR..":ValidateOptionsTable(): "..table.concat(t,".")..msg, errlvl+2) |
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2) |
end |
type=isstring, |
name=isstringfunc, |
desc=optstringfunc, |
descStyle=optstring, |
order=optmethodnumber, |
validate=optmethodfalse, |
confirm=optmethodbool, |
}, |
toggle={ |
tristate=optbool, |
image=optstringfunc, |
imageCoords=optmethodtable, |
}, |
tristate={ |
}, |
end |
end |
-- ------------------------------------------------------------------- |
-- :ValidateOptionsTable(options,name,errlvl) |
-- - options - the table |
-- - name - (string) name of table, used in error reports |
-- - errlvl - (optional number) error level offset, default 0 |
-- |
-- Validates basic structure and integrity of an options table |
--- Validates basic structure and integrity of an options table \\ |
-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth |
-- @param options The table to be validated |
-- @param name The name of the table to be validated (shown in any error message) |
-- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable) |
function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl) |
errlvl=(errlvl or 0)+1 |
name = name or "Optionstable" |
validate(options,errlvl,name) |
end |
--- Fires a ConfigTableChange callback for those listening in on it, allowing config GUIs to refresh. |
--- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh. |
-- You should call this function if your options table changed from any outside event, like a game event |
-- or a timer. |
-- @param appName The application name as given to `:RegisterOptionsTable()` |
--- Register an options table with the config registry. |
-- @param appName The application name as given to `:RegisterOptionsTable()` |
-- @param options The options table or a function reference that generates it on demand. |
-- @param options The options table, OR a function reference that generates it on demand. \\ |
-- See the top of the page for info on arguments passed to such functions. |
function AceConfigRegistry:RegisterOptionsTable(appName, options) |
if type(options)=="table" then |
if options.type~="group" then -- quick sanity checker |
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) |
errlvl=(errlvl or 0)+1 |
validateGetterArgs(uiType, uiName, errlvl) |
local tab = assert(options(uiType, uiName)) |
local tab = assert(options(uiType, uiName, appName)) |
if not AceConfigRegistry.validated[uiType][appName] then |
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable |
AceConfigRegistry.validated[uiType][appName] = true |
end |
--------------------------------------------------------------------- |
-- :GetOptionsTable(appName) |
-- - appName - which addon to retreive the options table of |
-- Optional: |
-- - uiType - "cmd", "dropdown", "dialog" |
-- - uiName - e.g. "MyLib-1.0" |
-- |
--- Query the registry for a specific options table. |
-- can call with (uiType,uiName) to get the table.\\ |
-- If uiType&uiName are given, the table is returned. |
-- @param appName The application name as given to `:RegisterOptionsTable()` |
-- @param uiType The type of UI to get the table for. |
-- @param uiName The name of the library/addon querying the table. |
-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog" |
-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0" |
function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName) |
local f = AceConfigRegistry.tables[appName] |
if not f then |
-- as well as associate it with a slash command. |
-- @class file |
-- @name AceConfig-3.0 |
-- @release $Id: AceConfig-3.0.lua 802 2009-04-11 12:12:37Z nevcairiel $ |
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
--[[ |
AceConfig-3.0 |
if not AceConfig then return end |
local cfgreg = LibStub("AceConfigRegistry-3.0") |
local cfgcmd = LibStub("AceConfigCmd-3.0") |
local cfgdlg = LibStub("AceConfigDialog-3.0") |
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0") |
-- Lua APIs |
local pcall, error, type, pairs = pcall, error, type, pairs |
-- ------------------------------------------------------------------- |
-- :RegisterOptionsTable(appName, options, slashcmd, persist) |
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. |
-- @class file |
-- @name AceConfigDialog-3.0 |
-- @release $Id: AceConfigDialog-3.0.lua 796 2009-04-07 15:48:54Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 34 |
local AceConfigDialog = LibStub:NewLibrary(MAJOR, MINOR) |
local MAJOR, MINOR = "AceConfigDialog-3.0", 41 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
local gui = LibStub("AceGUI-3.0") |
local reg = LibStub("AceConfigRegistry-3.0") |
local select = select |
local pairs = pairs |
local type = type |
local assert = assert |
local tinsert = tinsert |
local tremove = tremove |
local error = error |
local table = table |
local unpack = unpack |
local string = string |
local next = next |
local math = math |
local _ |
-- Lua APIs |
local tconcat, tinsert, tsort, tremove = table.concat, table.insert, table.sort, table.remove |
local strmatch, format = string.match, string.format |
local assert, loadstring, error = assert, loadstring, error |
local pairs, next, select, type, unpack = pairs, next, select, type, unpack |
local rawset, tostring = rawset, tostring |
local math_min, math_max, math_floor = math.min, math.max, math.floor |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show |
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge |
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler |
local emptyTbl = {} |
--[[ |
xpcall safecall implementation |
]] |
local ARGS = {} |
for i = 1, argCount do ARGS[i] = "arg"..i end |
code = code:gsub("ARGS", table.concat(ARGS, ", ")) |
code = code:gsub("ARGS", tconcat(ARGS, ", ")) |
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) |
end |
--Is Never a function or method |
local allIsLiteral = { |
type = true, |
descStyle = true, |
imageWidth = true, |
imageHeight = true, |
} |
if handler and handler[member] then |
a,b,c,d = handler[member](handler, info, ...) |
else |
error(string.format("Method %s doesn't exist in handler for type %s", member, membername)) |
error(format("Method %s doesn't exist in handler for type %s", member, membername)) |
end |
end |
del(info) |
end |
end |
table.sort(keySort, compareOptions) |
tsort(keySort, compareOptions) |
del(tempOrders) |
del(tempNames) |
local name = GetOptionsMemberValue("name", opt, options, path, appName) |
local desc = GetOptionsMemberValue("desc", opt, options, path, appName) |
local usage = GetOptionsMemberValue("usage", opt, options, path, appName) |
local descStyle = opt.descStyle |
if descStyle and descStyle ~= "tooltip" then return end |
GameTooltip:SetText(name, 1, .82, 0, 1) |
if opt.type == 'multiselect' then |
if dialog and oldstrata then |
dialog:SetFrameStrata(oldstrata) |
end |
AceConfigDialog:Open(appName, rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) |
del(info) |
end |
t.OnCancel = function() |
if dialog and oldstrata then |
dialog:SetFrameStrata(oldstrata) |
end |
AceConfigDialog:Open(appName, rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) |
del(info) |
end |
for i = 1, select('#', ...) do |
success, validated = safecall(handler[validate], handler, info, ...) |
if not success then validated = false end |
else |
error(string.format("Method %s doesn't exist in handler for type execute", validate)) |
error(format("Method %s doesn't exist in handler for type execute", validate)) |
end |
elseif type(validate) == "function" then |
success, validated = safecall(validate, info, ...) |
--validate function returned a message to display |
if rootframe.SetStatusText then |
rootframe:SetStatusText(validated) |
else |
-- TODO: do something else. |
end |
PlaySound("igPlayerInviteDecline") |
del(info) |
rootframe:SetStatusText(name..": Invalid Value") |
end |
end |
else |
-- TODO: do something else |
end |
PlaySound("igPlayerInviteDecline") |
del(info) |
confirm = false |
end |
else |
error(string.format("Method %s doesn't exist in handler for type confirm", confirm)) |
error(format("Method %s doesn't exist in handler for type confirm", confirm)) |
end |
elseif type(confirm) == "function" then |
success, confirm = safecall(confirm, info, ...) |
if handler and handler[func] then |
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...) |
else |
error(string.format("Method %s doesn't exist in handler for type func", func)) |
error(format("Method %s doesn't exist in handler for type func", func)) |
end |
elseif type(func) == "function" then |
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...) |
if handler and handler[func] then |
safecall(handler[func],handler, info, ...) |
else |
error(string.format("Method %s doesn't exist in handler for type func", func)) |
error(format("Method %s doesn't exist in handler for type func", func)) |
end |
elseif type(func) == "function" then |
safecall(func,info, ...) |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
--full refresh of the frame, some controls dont cause this on all events |
if option.type == "color" then |
if event == "OnValueConfirmed" then |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
elseif option.type == "range" then |
if event == "OnMouseUp" then |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
--multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed' |
user.valuechanged = true |
else |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
local option = widget:GetUserData('option') |
local min, max, step = option.min or 0, option.max or 100, option.step |
if step then |
value = math.floor((value - min) / step + 0.5) * step + min |
value = math_floor((value - min) / step + 0.5) * step + min |
else |
value = math.max(math.min(value,max),min) |
value = math_max(math_min(value,max),min) |
end |
ActivateControl(widget,event,value) |
end |
ActivateControl(widget, event, widget:GetUserData('value'), ...) |
local user = widget:GetUserDataTable() |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
local user = widget:GetUserDataTable() |
if user.valuechanged then |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
end |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
control:SetValue(value) |
control:SetCallback("OnValueChanged",ActivateControl) |
if v.descStyle == "inline" then |
local desc = GetOptionsMemberValue("desc", v, options, path, appName) |
control:SetDescription(desc) |
end |
local image = GetOptionsMemberValue("image", v, options, path, appName) |
local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName) |
if type(image) == 'string' then |
if type(imageCoords) == 'table' then |
control:SetImage(image, unpack(imageCoords)) |
else |
control:SetImage(image) |
end |
end |
elseif v.type == "range" then |
control = gui:Create("Slider") |
control:SetLabel(name) |
tinsert(valuesort, value) |
end |
end |
table.sort(valuesort) |
tsort(valuesort) |
if controlType then |
control = gui:Create(controlType) |
if not control then |
feedpath[i] = path[i] |
end |
BuildPath(feedpath, string.split("\001", uniquevalue)) |
BuildPath(feedpath, ("\001"):split(uniquevalue)) |
local group = options |
for i = 1, #feedpath do |
if not group then return end |
GameTooltip:SetOwner(button, "ANCHOR_NONE") |
if widget.type == "TabGroup" then |
GameTooltip:SetPoint("BOTTOM",button,"TOP") |
GameTooltip:SetPoint("BOTTOM",button,"TOP") |
else |
GameTooltip:SetPoint("LEFT",button,"RIGHT") |
GameTooltip:SetPoint("LEFT",button,"RIGHT") |
end |
GameTooltip:SetText(name, 1, .82, 0, 1) |
feedpath[i] = path[i] |
end |
BuildPath(feedpath, string.split("\001", uniquevalue)) |
BuildPath(feedpath, ("\001"):split(uniquevalue)) |
local group = options |
for i = 1, #feedpath do |
feedpath[i] = path[i] |
end |
BuildPath(feedpath, string.split("\001", uniquevalue)) |
BuildPath(feedpath, ("\001"):split(uniquevalue)) |
local group = options |
for i = 1, #feedpath do |
group = GetSubOption(group, feedpath[i]) |
--Add a scrollframe if we are not going to add a group control, this is the inverse of the conditions for that later on |
if (not (hasChildGroups and not inline)) or (grouptype ~= "tab" and grouptype ~= "select" and (parenttype == "tree" and not isRoot)) then |
if container.type ~= "InlineGroup" then |
if container.type ~= "InlineGroup" and container.type ~= "SimpleGroup" then |
scroll = gui:Create("ScrollFrame") |
scroll:SetLayout("flow") |
scroll.width = "fill" |
end |
if hasChildGroups and not inline then |
local name = GetOptionsMemberValue("name", group, options, path, appName) |
if grouptype == "tab" then |
local tab = gui:Create("TabGroup") |
elseif grouptype == "select" then |
local select = gui:Create("DropdownGroup") |
select:SetTitle(name) |
InjectInfo(select, options, group, path, rootframe, appName) |
select:SetCallback("OnGroupSelected", GroupSelected) |
local status = AceConfigDialog:GetStatusTable(appName, path) |
end |
if firstgroup then |
select:SetGroup( (GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) |
select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) |
end |
select.width = "fill" |
AceConfigDialog.OpenFrames[appName]:Hide() |
end |
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then |
local widget = AceConfigDialog.BlizOptions[appName] |
if not widget:IsVisible() then |
widget:ReleaseChildren() |
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do |
if not widget:IsVisible() then |
widget:ReleaseChildren() |
end |
end |
end |
this.closing[appName] = nil |
for appName in pairs(this.apps) do |
if AceConfigDialog.OpenFrames[appName] then |
local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable() |
AceConfigDialog:Open(appName, user.basepath and unpack(user.basepath)) |
AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl)) |
end |
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then |
local widget = AceConfigDialog.BlizOptions[appName] |
local user = widget:GetUserDataTable() |
if widget:IsVisible() then |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, user.basepath and unpack(user.basepath)) |
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do |
local user = widget:GetUserDataTable() |
if widget:IsVisible() then |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(user.basepath or emptyTbl)) |
end |
end |
end |
this.apps[appName] = nil |
if f.SetStatusTable then |
f:SetStatusTable(status) |
end |
if f.SetTitle then |
f:SetTitle(name or "") |
end |
else |
if not self.OpenFrames[appName] then |
f = gui:Create("Frame") |
del(path) |
end |
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {} |
-- convert pre-39 BlizOptions structure to the new format |
if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then |
local old = AceConfigDialog.BlizOptions |
local new = {} |
for key, widget in pairs(old) do |
local appName = widget:GetUserData('appName') |
if not new[appName] then new[appName] = {} end |
new[appName][key] = widget |
end |
AceConfigDialog.BlizOptions = new |
else |
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {} |
end |
local function FeedToBlizPanel(widget, event) |
local path = widget:GetUserData('path') |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, path and unpack(path)) |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(path or emptyTbl)) |
end |
local function ClearBlizPanel(widget, event) |
key = key..'\001'..select(n, ...) |
end |
if not BlizOptions[key] then |
if not BlizOptions[appName] then |
BlizOptions[appName] = {} |
end |
if not BlizOptions[appName][key] then |
local group = gui:Create("BlizOptionsGroup") |
BlizOptions[key] = group |
BlizOptions[appName][key] = group |
group:SetName(name or appName, parent) |
group:SetTitle(name or appName) |
--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames. |
-- @class file |
-- @name AceConfigCmd-3.0 |
-- @release $Id: AceConfigCmd-3.0.lua 801 2009-04-09 20:34:28Z nevcairiel $ |
-- @release $Id: AceConfigCmd-3.0.lua 897 2009-12-06 17:02:27Z mikk $ |
--[[ |
AceConfigCmd-3.0 |
]] |
-- TODO: handle disabled / hidden |
-- TODO: implement handlers for all types |
-- TODO: plugin args |
local MAJOR, MINOR = "AceConfigCmd-3.0", 9 |
local MAJOR, MINOR = "AceConfigCmd-3.0", 11 |
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigCmd then return end |
local AceConsole -- LoD |
local AceConsoleName = "AceConsole-3.0" |
-- Lua APIs |
local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim |
local format, tonumber, tostring = string.format, tonumber, tostring |
local tsort, tinsert = table.sort, table.insert |
local select, pairs, next, type = select, pairs, next, type |
local error, assert = error, assert |
-- WoW APIs |
local _G = _G |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME |
local L = setmetatable({}, { -- TODO: replace with proper locale |
__index = function(self,k) return k end |
}) |
end |
end |
local function checkhidden(info, inputpos, tab) |
if tab.cmdHidden~=nil then |
return tab.cmdHidden |
end |
local hidden = tab.hidden |
if type(hidden) == "function" or type(hidden) == "string" then |
info.hidden = hidden |
hidden = callmethod(info, inputpos, tab, 'hidden') |
info.hidden = nil |
end |
return hidden |
end |
local function showhelp(info, inputpos, tab, noHead) |
if not noHead then |
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":") |
for k,v in iterateargs(tab) do |
if not refTbl[k] then -- a plugin overriding something in .args |
table.insert(sortTbl, k) |
tinsert(sortTbl, k) |
refTbl[k] = v |
end |
end |
table.sort(sortTbl, function(one, two) |
tsort(sortTbl, function(one, two) |
local o1 = refTbl[one].order or 100 |
local o2 = refTbl[two].order or 100 |
if type(o1) == "function" or type(o1) == "string" then |
return o1<o2 |
end) |
for _,k in ipairs(sortTbl) do |
for i = 1, #sortTbl do |
local k = sortTbl[i] |
local v = refTbl[k] |
if not pickfirstset(v.cmdHidden, v.hidden, false) then |
if not checkhidden(info, inputpos, v) then |
-- recursively show all inline groups |
local name, desc = v.name, v.desc |
if type(name) == "function" then |
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end |
-- grab next arg from input |
local _,nextpos,arg = string.find(info.input, " *([^ ]+) *", inputpos) |
local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos) |
if not arg then |
showhelp(info, inputpos, tab) |
return |
--parse for =on =off =default in the process |
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set |
local sels = {} |
for v in string.gmatch(str, "[^ ]+") do |
for v in str:gmatch("[^ ]+") do |
--parse option=on etc |
local opt, val = string.match(v,'(.+)=(.+)') |
local opt, val = v:match('(.+)=(.+)') |
--get option if toggling |
if not opt then |
opt = v |