From c6ce03ba6025959f51bc8704a7b0f1ec2714dd6e Mon Sep 17 00:00:00 2001 From: Lacustat Date: Mon, 2 Nov 2026 00:49:28 +0100 Subject: [PATCH] 0.1.234: Kanaele: LFT-Log zeigt nur die letzten ca. 4000 Zeichen, aktualisiert hoechstens alle 1,5 s und bleibt stehen, wenn man hochscrollt oder markiert [ungeprueft] Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9 --- Freewood-OctoWoW-Core.toc | 2 +- UI/ChannelsTab.lua | 51 ++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Freewood-OctoWoW-Core.toc b/Freewood-OctoWoW-Core.toc index d6fcc74..f5dc2ba 100644 --- a/Freewood-OctoWoW-Core.toc +++ b/Freewood-OctoWoW-Core.toc @@ -3,7 +3,7 @@ ## Notes: Base addon of the Freewood family: data storage, UI kit, export/import and the main window. ## Notes-deDE: Basis-Addon der Freewood-Familie: Datenspeicher, UI-Bausteine, Export/Import und Hauptfenster. ## Author: Lacustat -## Version: 0.1.233 +## Version: 0.1.234 ## SavedVariables: FreewoodDB ## SavedVariablesPerCharacter: FreewoodCharDB diff --git a/UI/ChannelsTab.lua b/UI/ChannelsTab.lua index 7c50d9e..44b1b07 100644 --- a/UI/ChannelsTab.lua +++ b/UI/ChannelsTab.lua @@ -10,7 +10,7 @@ local CL = FW.ChatLog local WIDE_W, NARROW_W, RIGHT_W = 270, 56, 220 local ROW = 24 local MAX_BUBBLES = 60 -local LOG_LINES = 200 +local LOG_CHARS = 4000 local LOGO = "Interface\\AddOns\\Freewood-OctoWoW-Core\\Media\\FreeWood_Logo.tga" local QMARK = "Interface\\Icons\\INV_Misc_QuestionMark" @@ -959,30 +959,43 @@ local function Build(content) return n end + local logT = 0 local function DrawLog(key) local lines = CL.Lines(key) or {} local n = table.getn(lines) - local first = math.max(1, n - LOG_LINES + 1) + -- nur die letzten ca. LOG_CHARS Zeichen zeigen, damit das Fenster ruhig bleibt local parts = {} - local i = first - while i <= n do + local total = 0 + local i = n + while i >= 1 do local ln = lines[i] - parts[table.getn(parts) + 1] = "[" .. Stamp(ln.t, L) .. "] " .. (ln.s or "?") .. ": " .. Plain(ln.m or "") - i = i + 1 + local row = "[" .. Stamp(ln.t, L) .. "] " .. (ln.s or "?") .. ": " .. Plain(ln.m or "") + total = total + string.len(row) + 1 + if total > LOG_CHARS and table.getn(parts) > 0 then break end + parts[table.getn(parts) + 1] = row + i = i - 1 end - if not logArea.edit:HasFocus() then - local text = table.concat(parts, "\n") - if logArea.lastText ~= text then - logArea.lastText = text - logArea:SetText(text) - if C_Timer and C_Timer.After then - C_Timer.After(0.15, function() - local h = logArea.child:GetHeight() or 0 - local v = logArea.scroll:GetHeight() or 0 - logArea.scroll:SetVerticalScroll(math.max(0, h - v)) - logArea.UpdateScroll() - end) - end + -- Reihenfolge umdrehen (aelteste oben) + local ordered, k = {}, table.getn(parts) + while k >= 1 do ordered[table.getn(ordered) + 1] = parts[k]; k = k - 1 end + local text = table.concat(ordered, "\n") + local now = (GetTime and GetTime()) or 0 + local h = logArea.child:GetHeight() or 0 + local v = logArea.scroll:GetHeight() or 0 + local atBottom = (logArea.scroll:GetVerticalScroll() >= h - v - 24) + -- beim Lesen (oben/markiert) nichts verschieben; sonst hoechstens alle 1,5 s aktualisieren + local calm = logArea.edit:HasFocus() or (not atBottom and logArea.lastText ~= nil) + if not calm and logArea.lastText ~= text and (now - logT >= 1.5 or logArea.lastText == nil) then + logT = now + logArea.lastText = text + logArea:SetText(text) + if C_Timer and C_Timer.After then + C_Timer.After(0.15, function() + local h2 = logArea.child:GetHeight() or 0 + local v2 = logArea.scroll:GetHeight() or 0 + logArea.scroll:SetVerticalScroll(math.max(0, h2 - v2)) + logArea.UpdateScroll() + end) end end return n