handleWindowSize tracks new dimensions, rebuilds the glamour renderer on a wrap-width change, emits the splash on the first frame, and on a true width change starts the debounced resize-settle cycle (suppressView until the settle tick lands at the matching gen).
(msg tea.WindowSizeMsg)
| 511 | // change starts the debounced resize-settle cycle (suppressView until the |
| 512 | // settle tick lands at the matching gen). |
| 513 | func (m Model) handleWindowSize(msg tea.WindowSizeMsg) (tea.Model, tea.Cmd) { |
| 514 | first := !m.splashShown |
| 515 | widthChanged := m.width > 0 && m.width != msg.Width |
| 516 | m.width, m.height = msg.Width, msg.Height |
| 517 | m.ta.SetWidth(msg.Width - 2) |
| 518 | if first || widthChanged { |
| 519 | // Glamour compiles a stylesheet + template tree per build, so rebuild |
| 520 | // only on a real wrap-width change; height-only events and intra-drag |
| 521 | // duplicates reuse the existing renderer. |
| 522 | if r, err := glamour.NewTermRenderer(glamour.WithStandardStyle("dark"), |
| 523 | glamour.WithWordWrap(max(msg.Width-4, 1))); err == nil { |
| 524 | m.renderer = r |
| 525 | } |
| 526 | } |
| 527 | m.recomputeLayout() |
| 528 | if first { |
| 529 | m.splashShown = true |
| 530 | m.outbox = append(m.outbox, m.splashLines()...) |
| 531 | return m, nil |
| 532 | } |
| 533 | if !widthChanged { |
| 534 | return m, nil |
| 535 | } |
| 536 | m.suppressView = true |
| 537 | m.resizeGen++ |
| 538 | gen := m.resizeGen |
| 539 | return m, tea.Tick(resizeSettleDelay, func(time.Time) tea.Msg { |
| 540 | return resizeSettleMsg{gen: gen} |
| 541 | }) |
| 542 | } |
| 543 | |
| 544 | // handleResizeSettle fires once the post-resize debounce expires for the |
| 545 | // matching gen. Wipes the terminal (so previous-width rows can't soft-wrap into |
no test coverage detected