From 36dd81ce1c5b3f7249076231aec619e773144b3f Mon Sep 17 00:00:00 2001 From: Slendi Date: Sat, 20 Sep 2025 03:03:28 +0300 Subject: [PATCH] irc: fix live updates and preserve default buttons on reopen - Set in so append/refresh repaint. - Build button rows explicitly (Send + TextViewer defaults) and disable automatic default insertion to ensure defaults remain after reinit. Also clarifies behavior when reopening a keep_running view. Signed-off-by: Slendi --- main.lua | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/main.lua b/main.lua index 289c982..0109c1a 100644 --- a/main.lua +++ b/main.lua @@ -48,17 +48,67 @@ local IrcChatView = TextViewer:extend{ } function IrcChatView:init(reinit) - -- Buttons: Send, Close - self.buttons_table = { + -- Mark UI as open so append/refresh paths repaint immediately + self._ui_open = true + -- Build buttons: first our Send row, then TextViewer's default row + -- Disable TextViewer's automatic default buttons to avoid duplication + self.add_default_buttons = false + local send_row = { { - { - text = _("Send"), - callback = function() - self:promptSendMessage() - end, - }, - } + text = _("Send"), + callback = function() + self:promptSendMessage() + end, + }, } + local default_row = { + { + text = _("Find"), + id = "find", + callback = function() + if self._find_next then + self:findCallback() + else + self:findDialog() + end + end, + hold_callback = function() + if self._find_next then + self:findDialog() + else + if self.default_hold_callback then + self.default_hold_callback() + end + end + end, + }, + { + text = "⇱", + id = "top", + callback = function() + if self.scroll_text_w then self.scroll_text_w:scrollToTop() end + end, + hold_callback = self.default_hold_callback, + allow_hold_when_disabled = true, + }, + { + text = "⇲", + id = "bottom", + callback = function() + if self.scroll_text_w then self.scroll_text_w:scrollToBottom() end + end, + hold_callback = self.default_hold_callback, + allow_hold_when_disabled = true, + }, + { + text = _("Close"), + callback = function() + self:onClose() + end, + hold_callback = self.default_hold_callback, + }, + } + self.buttons_table = { send_row, default_row } -- Buffers & title if not reinit then self._buffers = {}