20 lines
542 B
Go
20 lines
542 B
Go
package tui
|
|
|
|
import "charm.land/lipgloss/v2"
|
|
|
|
// placeOverlayCenter composites fg centered on top of bg using lipgloss v2
|
|
// layers, keeping the background visible around the overlay (a true modal).
|
|
func placeOverlayCenter(bg, fg string) string {
|
|
x := (lipgloss.Width(bg) - lipgloss.Width(fg)) / 2
|
|
y := (lipgloss.Height(bg) - lipgloss.Height(fg)) / 2
|
|
if x < 0 {
|
|
x = 0
|
|
}
|
|
if y < 0 {
|
|
y = 0
|
|
}
|
|
base := lipgloss.NewLayer(bg).X(0).Y(0)
|
|
base.AddLayers(lipgloss.NewLayer(fg).X(x).Y(y).Z(1))
|
|
return lipgloss.NewCompositor(base).Render()
|
|
}
|