diff --git a/internal/tui/tui.go b/internal/tui/tui.go index cd6e46c88e7720c6dd2b176c21040dbd4405eb06..0e2587666f5a8c58be1466149a6b6f7a9dfb2a59 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -113,6 +113,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return a, tea.Batch(cmds...) case tea.WindowSizeMsg: + a.wWidth, a.wHeight = msg.Width, msg.Height a.completions.Update(msg) return a, a.handleWindowResize(msg.Width, msg.Height) @@ -291,7 +292,6 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // handleWindowResize processes window resize events and updates all components. func (a *appModel) handleWindowResize(width, height int) tea.Cmd { var cmds []tea.Cmd - a.wWidth, a.wHeight = width, height if a.showingFullHelp { height -= 5 } else { @@ -424,6 +424,27 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd { // View renders the complete application interface including pages, dialogs, and overlays. func (a *appModel) View() tea.View { + var view tea.View + t := styles.CurrentTheme() + view.BackgroundColor = t.BgBase + if a.wWidth < 25 || a.wHeight < 15 { + view.Layer = lipgloss.NewCanvas( + lipgloss.NewLayer( + t.S().Base.Width(a.wWidth).Height(a.wHeight). + Align(lipgloss.Center, lipgloss.Center). + Render( + t.S().Base. + Padding(1, 4). + Foreground(t.White). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(t.Primary). + Render("Window too small!"), + ), + ), + ) + return view + } + page := a.pages[a.currentPage] if withHelp, ok := page.(core.KeyMapHelp); ok { a.status.SetKeyMap(withHelp.Help()) @@ -475,10 +496,7 @@ func (a *appModel) View() tea.View { layers..., ) - var view tea.View - t := styles.CurrentTheme() view.Layer = canvas - view.BackgroundColor = t.BgBase view.Cursor = cursor return view }