The bubbletea v2 Cursed Renderer in alt screen mode is stricter about content fitting within terminal dimensions. The RootStyle margin (1,2) was adding padding outside the placed content, causing total width to exceed the terminal and producing ghost text at screen edges. Remove RootStyle and its frame size subtraction -- use full terminal dimensions directly with lipgloss.Place() for centering. The Place() call alone provides sufficient visual centering without outer margins.
- commit
- 77225ac6dc23baea791c16b2d5fc472440e9f580
- parent
- 098f74916781034ff46f1feddc5a25d6948419f6
- author
- Dami <dami.etoile@gmail.com>
| M | ui/ | 12 | ++---------- |
| M | update.go | 16 | +++++++--------- |
@@ -14,20 +14,12 @@ var (
1414 MenuDim = compat.AdaptiveColor{Light: lipgloss.Color("250"), Dark: lipgloss.Color("238")}1515 MenuTableHeader = compat.AdaptiveColor{Light: lipgloss.Color("130"), Dark: lipgloss.Color("180")}1616 17- RootStyle = lipgloss.NewStyle().Margin(1, 2)1817 DebugStyle = lipgloss.NewStyle().1918 Border(lipgloss.RoundedBorder(), true).2019 BorderForeground(compat.AdaptiveColor{Light: lipgloss.Color("124"), Dark: lipgloss.Color("124")})2120 )2221 23-// RootFrameSize returns the horizontal and vertical frame size of RootStyle.24-// Isolates the lipgloss v1 GetFrameSize() call for easier v2 migration.25-func RootFrameSize() (int, int) {26- return RootStyle.GetFrameSize()27-}28-29-// CenterView wraps content in centered placement within the root frame.30-// Isolates the lipgloss.Place() call for easier v2 migration.22+// CenterView wraps content in centered placement within the available area.3123 func CenterView(width, height int, content string) string {32- return RootStyle.Render(lipgloss.Place(width, height, lipgloss.Center, lipgloss.Center, content))24+ return lipgloss.Place(width, height, lipgloss.Center, lipgloss.Center, content)3325 }@@ -23,26 +23,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2323 return m.handleSpawnComplete(msg)2424 2525 case tea.WindowSizeMsg:26- h, v := ui.RootFrameSize()27- w, ht := msg.Width-h, msg.Height-v28- m.width = w29- m.height = ht30- menuW, menuH := min(w, 64), min(ht, 24)26+ m.width = msg.Width27+ m.height = msg.Height28+ menuW, menuH := min(m.width, 64), min(m.height, 24)3129 m.mainMenuList.SetSize(menuW, menuH)3230 m.gameSelectList.SetSize(menuW, menuH)3331 if m.state == modeSelectView {3432 m.modeSelectList.SetSize(menuW, menuH)3533 }3634 if m.state == continueView {37- m.continueTable.SetWidth(w)38- m.continueTable.SetHeight(ht)35+ m.continueTable.SetWidth(m.width)36+ m.continueTable.SetHeight(m.height)3937 }4038 if m.state == helpSelectView {4139 m.helpSelectList.SetSize(menuW, menuH)4240 }4341 if m.state == helpDetailView {44- m.helpViewport.SetWidth(w)45- m.helpViewport.SetHeight(ht - 2)42+ m.helpViewport.SetWidth(m.width)43+ m.helpViewport.SetHeight(m.height - 2)4644 }4745 4846 case tea.KeyMsg: