@ -6,18 +6,17 @@ local DiesalTools = LibStub:NewLibrary(MAJOR, MINOR)
if not DiesalTools then
return
end -- No Upgrade needed.
-- ~~| Libraries |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~| Lua Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end
local type , select , pairs , tonumber , tostring = type , select , pairs , tonumber , tostring
local table_concat = table.concat
local setmetatable , getmetatable , next = setmetatable , getmetatable , next
local sub , format , lower , upper , gsub = string.sub , string.format , string.lower , string.upper , string.gsub
local floor , ceil , abs , modf = math.floor , math.ceil , math.abs , math.modf
-- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local CreateFrame , UIParent , GetCursorPosition = CreateFrame , UIParent , GetCursorPosition
local GetScreenWidth , GetScreenHeight = GetScreenWidth , GetScreenHeight
-- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local escapeSequences = {
[ " \a " ] = " \\ a " , -- Bell
[ " \b " ] = " \\ b " , -- Backspace
@ -30,6 +29,7 @@ local escapeSequences = {
[ ' " ' ] = ' \\ " ' , -- Quotation mark
[ " | " ] = " || " ,
}
local lua_keywords = {
[ " and " ] = true ,
[ " break " ] = true ,
@ -72,7 +72,6 @@ local formattedArgs = {}
---@param level number
local function GetCaller ( level )
-- ADDON:LogMessage(debugstack(10,2, 0))
for trace in debugstack ( level , 2 , 0 ) : gmatch ( " (.-) \n " ) do
-- Blizzard Sandbox
local match , _ , file , line = trace : find ( " ^.* \\ (.-):(%d+) " )
@ -92,12 +91,14 @@ local function GetCaller(level)
end
return format ( " %s[%sUnknown Caller%s]|r " , colors.orange , colors.red , colors.orange )
end
---@param number number
---@param base? number
local function round ( number , base )
base = base or 1
return floor ( ( number + base / 2 ) / base ) * base
end
---@param color string | number | table
---@param g? number
---@param b? number
@ -117,9 +118,10 @@ local function getRGBColorValues(color, g, b)
end
end
---@param value string | number[]
function DiesalTools . GetColor ( value )
if not value then
return
return nil
end
if type ( value ) == " table " and # value >= 3 then
@ -132,8 +134,11 @@ end
-- ~~| API |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function DiesalTools . Stack ( )
print ( " |r------------------------------| Stack Trace |------------------------------- " )
local stack = debugstack ( 1 , 12 , 0 )
if not stack then
return
end
print ( " |r--------------------------------| Stack Trace |--------------------------------- " )
for trace in stack : gmatch ( " (.-) \n " ) do
local match , _ , file , line , func = trace : find ( " ^.* \\ (.-):(%d+).-`(.*)'$ " )
if match then
@ -143,14 +148,11 @@ function DiesalTools.Stack()
print ( " |r-------------------------------------------------------------------------------- " )
end
--[[ copy = TableCopy(src, dest, metatable)
@ Arguments :
dest Table to copy to
src Table to copy
metatable if true copies the metatable as well ( boolean )
@ Returns :
table copy of table
--]]
---@generic S
---@param src S
---@param dest? table
---@param metatable? boolean
---@return S
function DiesalTools . TableCopy ( src , dest , metatable )
if type ( src ) == " table " then
if not dest then