package ui import "charm.land/lipgloss/v2" // overlay composites box on top of base, centered over the current // terminal size, using lipgloss/v2's real layer compositor. This is what // makes confirm dialogs, the help screen, and the profile picker float // over the current screen instead of being appended below it. func (m *Model) overlay(base, box string) string { bw, bh := lipgloss.Size(box) x := (m.lay.w - bw) / 2 y := (m.lay.h - bh) / 2 if x < 0 { x = 0 } if y < 0 { y = 0 } return lipgloss.NewCompositor( lipgloss.NewLayer(base), lipgloss.NewLayer(box).X(x).Y(y).Z(1), ).Render() } const ( modalMaxContentWidth = 64 modalFrameWidth = 10 // border(2) + padding(4, from Padding(1,2)) + a little breathing room modalMinContentWidth = 24 ) // modalWrapWidth is the text-wrap width a screen should use before handing // content to styles.Modal/ModalDanger — keeps the box from ever exceeding // the terminal or the design's max modal width. func (m *Model) modalWrapWidth() int { w := m.lay.w - modalFrameWidth if w > modalMaxContentWidth { w = modalMaxContentWidth } if w < modalMinContentWidth { w = modalMinContentWidth } return w }