annotate Devian.lua @ 36:bec37163b7fe v2.0-beta

rewrote the blocks for '/dvn tag' and SetChannel to be more predictable; currently follows: /dvn tag <source> <dest> if <dest> matches a channel, then the tag for <source> is added or removed if <dest> is a string and it doesn't match a channel, then that channel is created with <dest> as a signature if <dest> is a number that doesn't match a channel index, then <dest> is set to <highest valid index + 1>, the channel is created under that, and <source> is used as its signature SetChannel(cinfo, key) start with an empty table t_info that is filled in as follows: if key doesn't match a valid index/signature, then a channel is being created if key does match a valid index, then a channel is being updated if cinfo is a string, then only the signature value is imposed if cinfo is a table, the values from that table are imposed if a channel is being created, then the new channel info is filled in from primary channel, the index is auto-generated, and the signature value is checked for collision, and the information is passed through CreateConsole to form internal assignments if a channel is being updated, then t_info is populated from the channel data, and any internal table assignments are switched over to t_info the old tables sink into garbage collection
author Nenue
date Sun, 27 Dec 2015 08:19:45 -0500
parents 3304455a3f45
children d432f49e340e
rev   line source
Nenue@32 1 --- ${PACKAGE_NAME}
Nenue@32 2 -- @file-author@
Nenue@32 3 -- @project-revision@ @project-hash@
Nenue@32 4 -- @file-revision@ @file-hash@
Nenue@0 5 if not LibStub then
Nenue@0 6 print('Something has happened...')
Nenue@0 7 end
Nenue@0 8 Devian = LibStub("AceAddon-3.0"):NewAddon("Devian", "AceConsole-3.0", "AceEvent-3.0")
Nenue@13 9 local MAJOR, MINOR = 'Devian-1.3', 'r@project-revision@'
Nenue@0 10 local D = _G.Devian
Nenue@36 11 local MSG_NEED_DEV_MODE = 'Must be in development mode to use this function.'
Nenue@32 12 local WORKSPACE_ON, WORKSPACE_OFF = 1, 2
Nenue@0 13 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName()
Nenue@18 14 local print = _G.print
Nenue@9 15 local db
Nenue@13 16 local defaults = {
Nenue@32 17 ['global'] = {{}, {}},
Nenue@13 18 ['tags'] = {},
Nenue@32 19 ['channels'] = {[1] = {signature = 'Main', index = 1, x = 100, y = 800, height = 500, width = 600, enabled = true}},
Nenue@33 20 primary_channel = 1, -- the channel to which default output is sent
Nenue@33 21 current_channel = 1, -- the front channel
Nenue@33 22 max_channel = 1, -- the highest created channel id
Nenue@33 23 enable = true, -- allow enabled consoles to appear
Nenue@33 24 load_message = "Defaults loaded.", -- messages to be displayed after reload
Nenue@33 25 font = [[Interface\Addons\Devian\font\SourceCodePro-Regular.ttf]], -- font info
Nenue@13 26 fontsize = 13,
Nenue@13 27 fontoutline = 'NONE',
Nenue@33 28 headergrad = {'VERTICAL', 0, 0, 0, 0.5, 0.1, 0.1, 0.1, 0.3}, -- header info
Nenue@33 29 headerdrop = {1,1,1,1},
Nenue@33 30 headeralpha = 1,
Nenue@36 31 headerfontcolor = {1,0.2,0.2,1},
Nenue@36 32 backdrop = {1,1,1,1}, -- background frame info
Nenue@14 33 backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5},
Nenue@33 34 backblend = 'MOD',
Nenue@33 35 backalpha = 0.7,
Nenue@33 36 backborder = {0,0,1,0.75},
Nenue@36 37 frontdrop = {1,1,1,1}, -- foreground frame info
Nenue@36 38 frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.8, 0, 0, 0, 0.6},
Nenue@33 39 frontblend = 'MOD',
Nenue@28 40 frontalpha = 1,
Nenue@22 41 frontborder = {1,0,0,1},
Nenue@33 42 tagcolor = {}, -- tag color repository
Nenue@36 43 workspace = 2, -- current profile
Nenue@33 44 last_workspace = 2 -- default workspace to alternate with when just "/dvn" is issued
Nenue@13 45 }
Nenue@9 46
Nenue@13 47 local function ScanAddOnList(cmd, ...)
Nenue@0 48 local list_state
Nenue@0 49
Nenue@14 50 local args = {}
Nenue@14 51 local arg, n = D:GetArgs(cmd, 1)
Nenue@14 52 while arg do
Nenue@14 53 table.insert(args, arg)
Nenue@14 54 arg, n = D:GetArgs(cmd,1,n)
Nenue@14 55 end
Nenue@14 56 local mode, tag, dest = unpack(args)
Nenue@0 57
Nenue@13 58
Nenue@14 59 -- no args, toggle ui
Nenue@32 60 if mode == 'dock' then
Nenue@33 61 if db.workspace == 1 then
Nenue@33 62 D:Print('Must be in dev mode to use this.')
Nenue@33 63 return
Nenue@33 64 end
Nenue@32 65 if #args <= 2 then
Nenue@32 66 D:Print("Not enough arguments for dock command.")
Nenue@32 67 return
Nenue@32 68 end
Nenue@0 69
Nenue@32 70 local target
Nenue@32 71 local worklist = {}
Nenue@32 72 for i = 2, #args do
Nenue@32 73 local ch
Nenue@32 74 local k = tostring(args[i])
Nenue@32 75 local j = tonumber(args[i])
Nenue@32 76 if db.channels[j] then
Nenue@32 77 ch = db.channels[j]
Nenue@32 78 elseif D.sig[k] then
Nenue@32 79 ch = D.sig[k]
Nenue@32 80 elseif D.sigID[k] then
Nenue@32 81 ch = db.channels[D.sigID[k]]
Nenue@32 82 elseif db.tags[k] and db.tags[k][1] then
Nenue@32 83 ch = db.channels[db.tags[j][1]]
Nenue@32 84 -- last resort
Nenue@32 85 else
Nenue@32 86 D:Print('No entry for argument #'..i..': '..tostring(args[i]))
Nenue@32 87 return
Nenue@32 88 end
Nenue@35 89 --@debug@
Nenue@35 90 --print(i, '->', ch.index, '-', ch.signature)--@end-debug@
Nenue@32 91 if i > 2 then
Nenue@32 92 table.insert(worklist, ch.index)
Nenue@32 93 else
Nenue@32 94 target = ch
Nenue@32 95
Nenue@35 96 --@debug@
Nenue@35 97 --print('arg1', args[2], target)--@end-debug@
Nenue@32 98 end
Nenue@0 99 end
Nenue@32 100 D:Print("Docking |cFF88FFFF"..table.concat(worklist, "|r, |cFF88FFFF").."|r with |cFFFFFF00"..target.index..', '..target.signature.."|r.")
Nenue@32 101 return D:DockFrame(target.index, unpack(worklist))
Nenue@32 102
Nenue@32 103
Nenue@14 104 elseif mode == 'stack' then
Nenue@33 105 if db.workspace == 1 then
Nenue@33 106 return D:Print(MSG_NEED_DEV_MODE)
Nenue@33 107 end
Nenue@14 108 return D:StackFrames()
Nenue@14 109 elseif mode == 'grid' then
Nenue@33 110 if db.workspace == 1 then
Nenue@33 111 return D:Print(MSG_NEED_DEV_MODE)
Nenue@33 112 end
Nenue@14 113 return D:DistributeFrames()
Nenue@14 114 elseif mode == 'tag' then -- tagging
Nenue@33 115 if db.workspace == 1 then
Nenue@33 116 return D:Print(MSG_NEED_DEV_MODE)
Nenue@33 117 end
Nenue@32 118
Nenue@36 119 local sig
Nenue@14 120 if tag ~= nil and dest ~= nil then
Nenue@36 121 --@debug@
Nenue@36 122 print(tag, dest)
Nenue@36 123 --@end-debug@
Nenue@36 124
Nenue@32 125 -- convert to ID
Nenue@36 126 if tonumber(dest) == nil then
Nenue@36 127 if D.sigID[dest] then
Nenue@36 128 dest = db.channels[D.sigID[dest]].index
Nenue@36 129 else
Nenue@36 130 sig = dest
Nenue@36 131 end
Nenue@18 132 end
Nenue@36 133 print('2 tag,dest,sig', tag, dest, sig)
Nenue@18 134
Nenue@32 135 -- make a new channel?
Nenue@36 136 local channel
Nenue@32 137 if not db.channels[dest] then
Nenue@36 138 dest = D.max_channel + 1
Nenue@36 139 D:Print('Created channel |cFF88FFFF'.. (sig and (dest..':'..sig) or dest ) .. '|r')
Nenue@36 140 channel = D:SetChannel(sig or tag,dest)
Nenue@32 141 end
Nenue@36 142 print('3',tag, dest)
Nenue@32 143
Nenue@32 144 if db.tags[tag] and db.tags[tag][dest] then
Nenue@32 145 db.tags[tag][dest] = nil
Nenue@34 146 D:Print('Hiding |cFF88FFFF'..tag..'|r messages in |cFFFFFF00'..db.channels[dest].index ..':'.. db.channels[dest].signature)
Nenue@32 147 else
Nenue@32 148 if not db.tags[tag] then
Nenue@32 149 db.tags[tag] = {}
Nenue@32 150 end
Nenue@32 151 db.tags[tag][dest] = dest
Nenue@34 152 D:Print('Showing |cFF88FFFF'..tag..'|r messages in |cFFFFFF00'..db.channels[dest].index ..':'.. db.channels[dest].signature)
Nenue@32 153 end
Nenue@14 154 else
Nenue@14 155 D:Print('Usage: /dvn tag <prefix> <console name or number>')
Nenue@14 156 end
Nenue@14 157 return
Nenue@32 158 elseif tonumber(mode) ~= nil or mode == 'save' then
Nenue@32 159 -- iterating for something
Nenue@32 160 if mode == 'save' then
Nenue@32 161 if tonumber(tag) == nil then
Nenue@32 162 T:Print('Save ID is invalid:', tag)
Nenue@32 163 end
Nenue@32 164 list_state = tonumber(tag)
Nenue@32 165 else
Nenue@32 166 list_state = tonumber(mode)
Nenue@32 167 db.workspace = list_state
Nenue@33 168 if list_state ~= 1 then
Nenue@33 169 db.last_workspace = list_state
Nenue@33 170 end
Nenue@33 171
Nenue@0 172 end
Nenue@32 173 elseif mode == nil then
Nenue@33 174 list_state = (db.workspace == 1) and db.last_workspace or 1
Nenue@33 175 db.workspace = list_state
Nenue@33 176 db.load_message = "quick swapped workspace #"..list_state
Nenue@32 177 else
Nenue@32 178 return D:PrintHelp()
Nenue@0 179 end
Nenue@32 180
Nenue@32 181 -- start the iterating
Nenue@36 182 if not db[PLAYER_REALM][list_state] then
Nenue@36 183 db[PLAYER_REALM][list_state] = {}
Nenue@36 184 end
Nenue@36 185 if not db.global[list_state] then
Nenue@36 186 db.global[list_state] = {}
Nenue@36 187 end
Nenue@36 188
Nenue@0 189 local char_list, global_list = db[PLAYER_REALM][list_state], db.global[list_state]
Nenue@0 190 local playername = UnitName("player")
Nenue@0 191
Nenue@0 192 for i = 1, GetNumAddOns() do
Nenue@0 193 local name = GetAddOnInfo(i)
Nenue@0 194 local enableState, globalState = GetAddOnEnableState(playername, i), GetAddOnEnableState(nil, i)
Nenue@0 195
Nenue@32 196 if mode == 'save' then
Nenue@0 197 char_list[name] = enableState
Nenue@0 198 global_list[name] = globalState
Nenue@0 199 else
Nenue@13 200 if char_list[name] or global_list[name] then
Nenue@32 201 if char_list[name] ~= 0 and global_list[name] ~= 0 then
Nenue@32 202 local value = false
Nenue@32 203 if char_list[name] == 2 and global_list[name] == 1 then
Nenue@32 204 value = UnitName("player")
Nenue@32 205 elseif global_list[name] == 2 then
Nenue@32 206 value = true
Nenue@32 207 end
Nenue@32 208 --print('EnableAddOn(', i, ',', value,')')
Nenue@32 209 EnableAddOn(i, value)
Nenue@32 210 else
Nenue@32 211 local value = true
Nenue@32 212 if char_list[name] == 2 and global_list[name] == 1 then
Nenue@32 213 value = UnitName("player")
Nenue@32 214 end
Nenue@32 215 --print('DisableAddOn(', i, ',', value,')')
Nenue@32 216 DisableAddOn(i,value)
Nenue@0 217 end
Nenue@33 218 elseif mode ~= 'save' then
Nenue@32 219 if type(db.unlisted) ~= 'table' then
Nenue@32 220 db.unlisted = {}
Nenue@0 221 end
Nenue@32 222 table.insert(db.unlisted, name)
Nenue@13 223 end
Nenue@0 224
Nenue@0 225 end
Nenue@0 226 end
Nenue@0 227
Nenue@32 228 if mode ~= 'save' then
Nenue@33 229 --db.load_message = "AddOn profile ".. list_state .." was loaded."
Nenue@0 230 ReloadUI()
Nenue@0 231 else
Nenue@32 232 D:Print('Profile #'.. (list_state)..' saved.')
Nenue@32 233 if list_state == 1 then
Nenue@32 234 D:Print('This will be your main AddOn list.')
Nenue@32 235 elseif list_state == db.default_list then
Nenue@32 236 db.last_workspace = list_state
Nenue@32 237 D:Print('This will be your default workspace')
Nenue@32 238 end
Nenue@0 239 end
Nenue@0 240 end
Nenue@0 241
Nenue@0 242
Nenue@13 243
Nenue@18 244 --- Creates a Devian-style output.
Nenue@18 245 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print()
Nenue@18 246 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint().
Nenue@18 247 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel.
Nenue@18 248 -- @param ... Output contents.
Nenue@0 249 local function Message(prefix, ...)
Nenue@33 250 if not db.enabled then
Nenue@23 251 return D.oldprint(prefix, ...)
Nenue@23 252 end
Nenue@23 253
Nenue@1 254 if prefix == nil then
Nenue@13 255 prefix = 1
Nenue@1 256 end
Nenue@9 257
Nenue@18 258 local sendq = {}
Nenue@30 259 local tag, id, tagged
Nenue@13 260 local byName = true
Nenue@18 261 if D.tags[prefix] then
Nenue@18 262 for _, id in pairs(D.tags[prefix]) do
Nenue@18 263 if D.console[id] then
Nenue@18 264 sendq[id] = D.console[id]
Nenue@30 265 tagged = true
Nenue@18 266 end
Nenue@18 267 end
Nenue@18 268 end
Nenue@18 269
Nenue@13 270 if D.sig[prefix] then
Nenue@18 271 sendq[D.sig[prefix].index] = D.sig[prefix]
Nenue@13 272 elseif D.console[prefix] then
Nenue@18 273 sendq[D.console[prefix]] = D.console[prefix]
Nenue@30 274 elseif not tagged then
Nenue@18 275 sendq[D.primary_channel] = D.console[D.primary_channel]
Nenue@13 276 end
Nenue@18 277
Nenue@9 278 -- color me timbers
Nenue@9 279 local pcolor
Nenue@18 280 if (not db.tagcolor[prefix]) and byName then
Nenue@30 281 local c = {
Nenue@30 282 math.random(64,255), math.random(64,255), math.random(64,255)
Nenue@30 283 }
Nenue@30 284 if c[1] > 223 and c[2] > 223 and c[3] > 223 then
Nenue@30 285 c[math.random(1,3)] = math.random(64,223)
Nenue@0 286 end
Nenue@30 287
Nenue@18 288 db.tagcolor[prefix] = string.format('%02X%02X%02X', unpack(c))
Nenue@0 289 end
Nenue@18 290 pcolor = db.tagcolor[prefix]
Nenue@0 291
Nenue@18 292 local buffer = {'|cFF'.. pcolor..prefix ..'|r'}
Nenue@0 293 for i = 1, select('#',...) do
Nenue@0 294 local var = select(i, ...)
Nenue@0 295
Nenue@0 296 if type(var) == 'table' then
Nenue@20 297 if type(var.GetName) == 'function' then
Nenue@32 298 var = '<table:'..var:GetName()..'>'
Nenue@20 299 else
Nenue@32 300 var = '<'..tostring(var)..'>'
Nenue@20 301 end
Nenue@20 302
Nenue@0 303 elseif type(var) == 'boolean' then
Nenue@0 304 var = var and 'true' or 'false'
Nenue@0 305 elseif type(var) == 'function' then
Nenue@0 306 var = '<funcref>'
Nenue@0 307 elseif type(var) == 'nil' then
Nenue@0 308 var = 'nil'
Nenue@0 309 end
Nenue@0 310
Nenue@0 311 table.insert(buffer, var)
Nenue@0 312 end
Nenue@18 313 local message = table.concat(buffer, ' ')
Nenue@18 314 for id, channel in pairs(sendq) do
Nenue@18 315 channel.out:AddMessage(message)
Nenue@18 316 end
Nenue@0 317 table.wipe(buffer)
Nenue@0 318 end
Nenue@0 319
Nenue@14 320
Nenue@32 321
Nenue@14 322
Nenue@32 323 function D:PrintHelp()
Nenue@32 324 D:Print("|cFFFFFF00/dvn|r",
Nenue@32 325 "\n |cFFFFFF00<number>|r - Loads a saved addon list. List 1 is treated as a gameplay profile and consoles will be disabled by default.")
Nenue@32 326
Nenue@32 327 D:Print("|cFFFFFF00/resetdvn|r", "- Resets all but profile data SavedVariables.")
Nenue@32 328 D:Print("|cFFFFFF00/cleandvn|r", "- Fully resets SavedVariables, profiles and all.")
Nenue@32 329 end
Nenue@32 330
Nenue@0 331 function D:OnEnable()
Nenue@33 332 print(MAJOR, MINOR)
Nenue@33 333
Nenue@33 334 if db.unlisted and #db.unlisted > 0 then
Nenue@33 335 D:Print('New AddOns have been found since the last profile update: '.. table.concat(db.unlisted, ', '))
Nenue@33 336 table.wipe(db.unlisted)
Nenue@33 337 end
Nenue@33 338
Nenue@33 339 if db.workspace == 1 then
Nenue@33 340 D:Print('Gameplay mode active (list #'..db.workspace..'). Print handling turned |cFFFFFF00OFF|r.')
Nenue@33 341 else
Nenue@33 342 D:Print('Development mode active (list #'..db.workspace..'). Print handling |cFF00FF00ON|r.')
Nenue@33 343 end
Nenue@33 344
Nenue@33 345 end
Nenue@33 346
Nenue@33 347 function D:OnInitialize()
Nenue@13 348 -- commands
Nenue@33 349 self:RegisterChatCommand("cleandvn", function(args)
Nenue@33 350 DevianDB = nil
Nenue@33 351 DevianDB = {
Nenue@33 352 load_message = "All SavedVars wiped."
Nenue@33 353 }
Nenue@33 354 ReloadUI()
Nenue@33 355 end)
Nenue@36 356 local blocked = {global = true, [PLAYER_REALM] = true}
Nenue@33 357 self:RegisterChatCommand("resetdvn", function(args)
Nenue@33 358 for k,v in pairs(DevianDB) do
Nenue@36 359 if not blocked[k] then
Nenue@33 360 DevianDB[k] = nil
Nenue@33 361 end
Nenue@33 362 end
Nenue@36 363 for k,v in pairs(defaults) do
Nenue@36 364 if not blocked[k] then
Nenue@36 365 DevianDB[k] = v
Nenue@36 366 end
Nenue@36 367 end
Nenue@33 368 DevianDB.load_message = "Non-user SavedVars have been reset."
Nenue@33 369 ReloadUI()
Nenue@33 370 end)
Nenue@13 371 local cmdlist = {
Nenue@13 372 ['dvn'] = ScanAddOnList,
Nenue@13 373 ['devian'] = ScanAddOnList,
Nenue@36 374 ['dvc'] = "Console_Toggle",
Nenue@13 375 }
Nenue@13 376 for cmd, func in pairs(cmdlist) do
Nenue@13 377 self:RegisterChatCommand(cmd, func, true)
Nenue@13 378 end
Nenue@13 379
Nenue@33 380 -- pull defaults
Nenue@9 381 if not _G.DevianDB then
Nenue@13 382 _G.DevianDB = defaults
Nenue@9 383 end
Nenue@9 384 db = _G.DevianDB
Nenue@32 385 self.tags = db.tags
Nenue@32 386 self.channelinfo = db.channels
Nenue@0 387
Nenue@0 388 if not db[PLAYER_REALM] then
Nenue@32 389 db[PLAYER_REALM] = {[WORKSPACE_ON] = {}, [WORKSPACE_OFF] = {}}
Nenue@0 390 end
Nenue@0 391
Nenue@32 392 if db.load_message then
Nenue@32 393 D:Print(db.load_message)
Nenue@32 394 db.load_message = nil
Nenue@0 395 end
Nenue@0 396 D.oldprint = getprinthandler()
Nenue@0 397 if not _G.oldprint then
Nenue@0 398 _G.oldprint = D.oldprint
Nenue@0 399 end
Nenue@13 400
Nenue@33 401 -- Stop here in game mode
Nenue@33 402 if db.workspace == 1 then
Nenue@33 403 return
Nenue@33 404 end
Nenue@35 405 -----------------------------------------------------------------------
Nenue@35 406 self.db = db
Nenue@35 407 self.channels = db.channels
Nenue@32 408 self.max_channel = 0
Nenue@14 409 self.num_channels = 0
Nenue@13 410 self.console = {}
Nenue@13 411 self.sig = {}
Nenue@14 412 self.sigID = {}
Nenue@14 413 self.IDsig = {}
Nenue@14 414 for i, cinfo in pairs(db.channels) do
Nenue@14 415 i = tonumber(i)
Nenue@14 416 if not self.primary_channel then
Nenue@14 417 self.primary_channel = i
Nenue@14 418 end
Nenue@14 419 self:SetChannel(cinfo, i)
Nenue@32 420 self.max_channel = math.max(i, self.max_channel)
Nenue@32 421 self.num_channels = self.num_channels + 1
Nenue@32 422 end
Nenue@32 423
Nenue@36 424
Nenue@32 425 for i, channel in pairs(db.channels) do
Nenue@32 426 if type(channel.docked) == 'table' then
Nenue@32 427 oldprint('docking',i, unpack(channel.docked))
Nenue@32 428 self.DockFrame(i, unpack(channel.docked))
Nenue@14 429 end
Nenue@13 430 end
Nenue@18 431
Nenue@18 432 if self.console[db.current_channel] then
Nenue@18 433 self.console[db.current_channel]:ToFront()
Nenue@28 434 -- bring the current channel to the front
Nenue@18 435 end
Nenue@33 436 setprinthandler(Message)
Nenue@33 437 print = function(...)
Nenue@33 438 _G.print('Dvn', ...)
Nenue@23 439 end
Nenue@36 440 end
Nenue@36 441
Nenue@36 442 --- Console frame toggler
Nenue@36 443 -- @paramsig [...]
Nenue@36 444 -- @param ... one or more space-seperated channel keys
Nenue@36 445 function D:Console_Toggle(input)
Nenue@36 446 oldprint(input)
Nenue@36 447 if db.workspace == 1 then
Nenue@36 448 return self:Print(MSG_NEED_DEV_MODE)
Nenue@36 449 end
Nenue@36 450 local search = {}
Nenue@36 451 local n = 0
Nenue@36 452 if self:GetArgs(input,1) then
Nenue@36 453 repeat
Nenue@36 454 local key, n = self:GetArgs(input,1,n)
Nenue@36 455 if self.sig[key] then
Nenue@36 456 table.insert(search, self.sigID[key])
Nenue@36 457 elseif self.console[key] then
Nenue@36 458 table.insert(search, tonumber(key))
Nenue@36 459 end
Nenue@36 460 until n == 1e9
Nenue@36 461 else
Nenue@36 462 search = self.sigID
Nenue@36 463 end
Nenue@36 464
Nenue@36 465 db.enabled = (not db.enabled) and true or nil
Nenue@36 466 for i, id in pairs(search) do
Nenue@36 467 oldprint(i, id)
Nenue@36 468 local c = self.console[id]
Nenue@36 469 if db.enabled then
Nenue@36 470 c.enabled = true
Nenue@36 471 c:Show()
Nenue@36 472 if db.current_channel == c.index then
Nenue@36 473 c:ToFront()
Nenue@36 474 end
Nenue@36 475 c:Save()
Nenue@36 476 else
Nenue@36 477 c:Hide()
Nenue@36 478 end
Nenue@36 479 end
Nenue@36 480
Nenue@36 481 if db.enabled then
Nenue@36 482 self:Print('toggled on: '..table.concat(search, ', '))
Nenue@36 483 else
Nenue@36 484 self:Print('toggled off: '..table.concat(search, ', '))
Nenue@36 485 end
Nenue@0 486 end