on main help sign in
Merge pull request #237 from charmbracelet/too-small
e854fe4Kujtim Hoxha
internal/tui/tui.go+22−4
@@ -113,6 +113,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
113 }
113 }
114 return a, tea.Batch(cmds...)
114 return a, tea.Batch(cmds...)
115 case tea.WindowSizeMsg:
115 case tea.WindowSizeMsg:
116+ a.wWidth, a.wHeight = msg.Width, msg.Height
116 a.completions.Update(msg)
117 a.completions.Update(msg)
117 return a, a.handleWindowResize(msg.Width, msg.Height)
118 return a, a.handleWindowResize(msg.Width, msg.Height)
118
119
@@ -291,7 +292,6 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
291// handleWindowResize processes window resize events and updates all components.
292// handleWindowResize processes window resize events and updates all components.
292func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
293func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
293 var cmds []tea.Cmd
294 var cmds []tea.Cmd
294− a.wWidth, a.wHeight = width, height
295 if a.showingFullHelp {
295 if a.showingFullHelp {
296 height -= 5
296 height -= 5
297 } else {
297 } else {
@@ -424,6 +424,27 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
424
424
425// View renders the complete application interface including pages, dialogs, and overlays.
425// View renders the complete application interface including pages, dialogs, and overlays.
426func (a *appModel) View() tea.View {
426func (a *appModel) View() tea.View {
427+ var view tea.View
428+ t := styles.CurrentTheme()
429+ view.BackgroundColor = t.BgBase
430+ if a.wWidth < 25 || a.wHeight < 15 {
431+ view.Layer = lipgloss.NewCanvas(
432+ lipgloss.NewLayer(
433+ t.S().Base.Width(a.wWidth).Height(a.wHeight).
434+ Align(lipgloss.Center, lipgloss.Center).
435+ Render(
436+ t.S().Base.
437+ Padding(1, 4).
438+ Foreground(t.White).
439+ BorderStyle(lipgloss.RoundedBorder()).
440+ BorderForeground(t.Primary).
441+ Render("Window too small!"),
442+ ),
443+ ),
444+ )
445+ return view
446+ }
447+
427 page := a.pages[a.currentPage]
448 page := a.pages[a.currentPage]
428 if withHelp, ok := page.(core.KeyMapHelp); ok {
449 if withHelp, ok := page.(core.KeyMapHelp); ok {
429 a.status.SetKeyMap(withHelp.Help())
450 a.status.SetKeyMap(withHelp.Help())
@@ -475,10 +496,7 @@ func (a *appModel) View() tea.View {
475 layers...,
496 layers...,
476 )
497 )
477
498
478− var view tea.View
479− t := styles.CurrentTheme()
480 view.Layer = canvas
499 view.Layer = canvas
481− view.BackgroundColor = t.BgBase
482 view.Cursor = cursor
500 view.Cursor = cursor
483 return view
501 return view
484}
502}