From 1ac5eb26e813d5d6ffc7c11278959ec2149e9f1b Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Mon, 18 May 2026 20:34:52 +0200 Subject: [PATCH] Change popup width/height Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- internal/ui/components/copy/model.go | 21 ++++++++++++++++----- internal/ui/components/copy/view.go | 2 +- internal/ui/components/copyas/model.go | 21 ++++++++++++++++----- internal/ui/components/copyas/view.go | 2 +- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/internal/ui/components/copy/model.go b/internal/ui/components/copy/model.go index 519e18e..39eeaf8 100644 --- a/internal/ui/components/copy/model.go +++ b/internal/ui/components/copy/model.go @@ -12,7 +12,10 @@ import ( "github.com/anotherhadi/spilltea/internal/style" ) -const popupInnerW = 40 +const ( + popupW = 55 + popupH = 20 +) func writeClipboard(text string) { encoded := base64.StdEncoding.EncodeToString([]byte(text)) @@ -66,7 +69,7 @@ func New() Model { BorderForeground(s.Primary). Foreground(s.MutedFg).PaddingLeft(1) - l := list.New(allItems, delegate, popupInnerW, 8) + l := list.New(allItems, delegate, popupW, 8) l.SetShowTitle(false) l.SetShowStatusBar(false) l.SetShowHelp(false) @@ -89,17 +92,25 @@ func (m *Model) Open(msg OpenMsg) { m.open = true m.list.ResetFilter() m.list.Select(0) - m.list.SetSize(popupInnerW, m.listHeight()) + m.list.SetSize(m.popupInnerWidth(), m.listHeight()) } func (m *Model) SetSize(w, h int) { m.width = w m.height = h - m.list.SetSize(popupInnerW, m.listHeight()) + m.list.SetSize(m.popupInnerWidth(), m.listHeight()) +} + +func (m Model) popupInnerWidth() int { + w := popupW + if m.width > 0 && m.width-4 < w { + w = m.width - 4 + } + return w } func (m Model) popupHeight() int { - h := 12 + h := popupH if m.height > 0 && m.height-4 < h { h = m.height - 4 } diff --git a/internal/ui/components/copy/view.go b/internal/ui/components/copy/view.go index 8781bc6..f96b1eb 100644 --- a/internal/ui/components/copy/view.go +++ b/internal/ui/components/copy/view.go @@ -22,7 +22,7 @@ func (m *Model) View(background string) string { BorderForeground(s.Primary) popupH := m.popupHeight() - popup := style.RenderWithTitle(border, "Copy", inner, popupInnerW+2, popupH) + popup := style.RenderWithTitle(border, "Copy", inner, m.popupInnerWidth()+2, popupH) return copyasUI.OverlayCenter(background, popup, m.width, m.height) } diff --git a/internal/ui/components/copyas/model.go b/internal/ui/components/copyas/model.go index 0d9cc94..b2a8680 100644 --- a/internal/ui/components/copyas/model.go +++ b/internal/ui/components/copyas/model.go @@ -11,7 +11,10 @@ import ( "github.com/anotherhadi/spilltea/internal/style" ) -const popupInnerW = 46 +const ( + popupW = 61 + popupH = 20 +) // writeClipboard uses the OSC 52 terminal escape sequence to set the clipboard. // Supported by most modern terminals (foot, kitty, wezterm, alacritty, xterm…). @@ -69,7 +72,7 @@ func New() Model { BorderForeground(s.Primary). Foreground(s.MutedFg).PaddingLeft(1) - l := list.New(allFormats, delegate, popupInnerW, 8) + l := list.New(allFormats, delegate, popupW, 8) l.SetShowTitle(false) l.SetShowStatusBar(false) l.SetShowHelp(false) @@ -92,17 +95,25 @@ func (m *Model) Open(msg OpenMsg) { m.open = true m.list.ResetFilter() m.list.Select(0) - m.list.SetSize(popupInnerW, m.listHeight()) + m.list.SetSize(m.popupInnerWidth(), m.listHeight()) } func (m *Model) SetSize(w, h int) { m.width = w m.height = h - m.list.SetSize(popupInnerW, m.listHeight()) + m.list.SetSize(m.popupInnerWidth(), m.listHeight()) +} + +func (m Model) popupInnerWidth() int { + w := popupW + if m.width > 0 && m.width-4 < w { + w = m.width - 4 + } + return w } func (m Model) popupHeight() int { - h := 14 + h := popupH if m.height > 0 && m.height-4 < h { h = m.height - 4 } diff --git a/internal/ui/components/copyas/view.go b/internal/ui/components/copyas/view.go index ad13ab3..bd211e3 100644 --- a/internal/ui/components/copyas/view.go +++ b/internal/ui/components/copyas/view.go @@ -24,7 +24,7 @@ func (m *Model) View(background string) string { BorderForeground(s.Primary) popupH := m.popupHeight() - popup := style.RenderWithTitle(border, "Copy as", inner, popupInnerW+2, popupH) + popup := style.RenderWithTitle(border, "Copy as", inner, m.popupInnerWidth()+2, popupH) return OverlayCenter(background, popup, m.width, m.height) }