Files
coa-chatter/Chatter/Modules/EditBoxHistory.lua
T
florian.berthold 5eaec81f02 chore: move addon into Chatter/ + add standard .gitignore
Matches the Exiles fork-layout convention (each addon in its own folder).
2026-05-25 10:59:27 +02:00

42 lines
1.1 KiB
Lua

local mod = Chatter:NewModule("Editbox History", "AceHook-3.0" )
local L = LibStub("AceLocale-3.0"):GetLocale("Chatter")
mod.modName = L["Edit Box History"]
local history, enabled
local defaults = { realm = { history = { } } }
local editbox = DEFAULT_CHAT_FRAME.editBox
function mod:OnInitialize()
self.db = Chatter.db:RegisterNamespace("Editbox History", defaults)
history = self.db.realm.history
-- Hook adding lines
self:SecureHook( editbox, "AddHistoryLine" )
end
function mod:OnEnable()
-- Keeping state if we're enabled or not
enable = false
for _, line in ipairs( history ) do
editbox:AddHistoryLine( line )
end
enabled = true
end
function mod:AddHistoryLine( object, line )
-- While in 'OnEnable' this code just returns
if not self:IsEnabled() or not enabled then return end
local history = history
tinsert( history, line )
-- clear out the excess values
for i=1, #history - object:GetHistoryLines() do
tremove( history, 1 )
end
end
function mod:Info()
return L["Remembers the history of the editbox across sessions."]
end