mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
Change popup width/height
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,10 @@ import (
|
|||||||
"github.com/anotherhadi/spilltea/internal/style"
|
"github.com/anotherhadi/spilltea/internal/style"
|
||||||
)
|
)
|
||||||
|
|
||||||
const popupInnerW = 40
|
const (
|
||||||
|
popupW = 55
|
||||||
|
popupH = 20
|
||||||
|
)
|
||||||
|
|
||||||
func writeClipboard(text string) {
|
func writeClipboard(text string) {
|
||||||
encoded := base64.StdEncoding.EncodeToString([]byte(text))
|
encoded := base64.StdEncoding.EncodeToString([]byte(text))
|
||||||
@@ -66,7 +69,7 @@ func New() Model {
|
|||||||
BorderForeground(s.Primary).
|
BorderForeground(s.Primary).
|
||||||
Foreground(s.MutedFg).PaddingLeft(1)
|
Foreground(s.MutedFg).PaddingLeft(1)
|
||||||
|
|
||||||
l := list.New(allItems, delegate, popupInnerW, 8)
|
l := list.New(allItems, delegate, popupW, 8)
|
||||||
l.SetShowTitle(false)
|
l.SetShowTitle(false)
|
||||||
l.SetShowStatusBar(false)
|
l.SetShowStatusBar(false)
|
||||||
l.SetShowHelp(false)
|
l.SetShowHelp(false)
|
||||||
@@ -89,17 +92,25 @@ func (m *Model) Open(msg OpenMsg) {
|
|||||||
m.open = true
|
m.open = true
|
||||||
m.list.ResetFilter()
|
m.list.ResetFilter()
|
||||||
m.list.Select(0)
|
m.list.Select(0)
|
||||||
m.list.SetSize(popupInnerW, m.listHeight())
|
m.list.SetSize(m.popupInnerWidth(), m.listHeight())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) SetSize(w, h int) {
|
func (m *Model) SetSize(w, h int) {
|
||||||
m.width = w
|
m.width = w
|
||||||
m.height = h
|
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 {
|
func (m Model) popupHeight() int {
|
||||||
h := 12
|
h := popupH
|
||||||
if m.height > 0 && m.height-4 < h {
|
if m.height > 0 && m.height-4 < h {
|
||||||
h = m.height - 4
|
h = m.height - 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func (m *Model) View(background string) string {
|
|||||||
BorderForeground(s.Primary)
|
BorderForeground(s.Primary)
|
||||||
|
|
||||||
popupH := m.popupHeight()
|
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)
|
return copyasUI.OverlayCenter(background, popup, m.width, m.height)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import (
|
|||||||
"github.com/anotherhadi/spilltea/internal/style"
|
"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.
|
// writeClipboard uses the OSC 52 terminal escape sequence to set the clipboard.
|
||||||
// Supported by most modern terminals (foot, kitty, wezterm, alacritty, xterm…).
|
// Supported by most modern terminals (foot, kitty, wezterm, alacritty, xterm…).
|
||||||
@@ -69,7 +72,7 @@ func New() Model {
|
|||||||
BorderForeground(s.Primary).
|
BorderForeground(s.Primary).
|
||||||
Foreground(s.MutedFg).PaddingLeft(1)
|
Foreground(s.MutedFg).PaddingLeft(1)
|
||||||
|
|
||||||
l := list.New(allFormats, delegate, popupInnerW, 8)
|
l := list.New(allFormats, delegate, popupW, 8)
|
||||||
l.SetShowTitle(false)
|
l.SetShowTitle(false)
|
||||||
l.SetShowStatusBar(false)
|
l.SetShowStatusBar(false)
|
||||||
l.SetShowHelp(false)
|
l.SetShowHelp(false)
|
||||||
@@ -92,17 +95,25 @@ func (m *Model) Open(msg OpenMsg) {
|
|||||||
m.open = true
|
m.open = true
|
||||||
m.list.ResetFilter()
|
m.list.ResetFilter()
|
||||||
m.list.Select(0)
|
m.list.Select(0)
|
||||||
m.list.SetSize(popupInnerW, m.listHeight())
|
m.list.SetSize(m.popupInnerWidth(), m.listHeight())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) SetSize(w, h int) {
|
func (m *Model) SetSize(w, h int) {
|
||||||
m.width = w
|
m.width = w
|
||||||
m.height = h
|
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 {
|
func (m Model) popupHeight() int {
|
||||||
h := 14
|
h := popupH
|
||||||
if m.height > 0 && m.height-4 < h {
|
if m.height > 0 && m.height-4 < h {
|
||||||
h = m.height - 4
|
h = m.height - 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func (m *Model) View(background string) string {
|
|||||||
BorderForeground(s.Primary)
|
BorderForeground(s.Primary)
|
||||||
|
|
||||||
popupH := m.popupHeight()
|
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)
|
return OverlayCenter(background, popup, m.width, m.height)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user