From 462331590c8929bc2f1eb6266c701ff319dd38c3 Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 9 Jun 2025 15:20:56 -0500 Subject: only open history view if message is not onscreen --- tui/layout.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tui/layout.go') diff --git a/tui/layout.go b/tui/layout.go index d230a87..1cd3124 100644 --- a/tui/layout.go +++ b/tui/layout.go @@ -23,6 +23,7 @@ type Box struct { computedSize [2]int computedRect rect isOverflow bool + isVisible bool mouseEvent MouseEvent contextMenu []string } @@ -97,6 +98,14 @@ func Pop() { } } +func IsVisible(id string) bool { + b := layout.back[id] + if b != nil { + return b.isVisible + } + return false +} + func (b Box) axes() [2]BoxSize { return [2]BoxSize {b.Width, b.Height} } @@ -372,6 +381,8 @@ func (b *Box) drawComputed( bMax := b.computedRect.max[i] - b.Margins[i * 2 + 1] viewRect.max[i] = min(bMax, parentRect.max[i]) } + b.isVisible = viewRect.max[0] - viewRect.min[0] > 0 && + viewRect.max[1] - viewRect.min[1] > 0 style := parentStyle if b.Style != nil { -- cgit v1.2.3