resizeAll recalculates all component sizes based on current window dimensions.
()
| 1831 | |
| 1832 | // resizeAll recalculates all component sizes based on current window dimensions. |
| 1833 | func (m *appModel) resizeAll() tea.Cmd { |
| 1834 | var cmds []tea.Cmd |
| 1835 | |
| 1836 | width, height := m.width, m.height |
| 1837 | innerWidth := width - appPaddingHorizontal |
| 1838 | |
| 1839 | // Calculate chrome height (everything that isn't content or editor) |
| 1840 | chromeHeight := 0 |
| 1841 | if m.leanMode { |
| 1842 | if m.chatPage.IsWorking() || m.sessionState.PauseState() != service.PauseNone { |
| 1843 | chromeHeight = 1 // working/pause indicator line |
| 1844 | } |
| 1845 | } else { |
| 1846 | chromeHeight = m.tabBar.Height() + m.statusBar.Height() + 1 // +1 for resize handle |
| 1847 | } |
| 1848 | |
| 1849 | // Calculate editor height |
| 1850 | minLines := 4 |
| 1851 | maxLines := max(minLines, (height-6)/2) |
| 1852 | m.editorLines = max(minLines, min(m.editorLines, maxLines)) |
| 1853 | |
| 1854 | targetEditorHeight := m.editorLines - 1 |
| 1855 | cmds = append(cmds, m.editor.SetSize(innerWidth, targetEditorHeight)) |
| 1856 | _, editorHeight := m.editor.GetSize() |
| 1857 | // The editor's View() adds MarginBottom(1) which isn't included in GetSize(), |
| 1858 | // so account for it in the layout calculation. |
| 1859 | editorRenderedHeight := editorHeight + 1 |
| 1860 | |
| 1861 | // Content gets remaining space |
| 1862 | m.contentHeight = max(1, height-chromeHeight-editorRenderedHeight) |
| 1863 | cmds = append(cmds, m.chatPage.SetSize(width, m.contentHeight)) |
| 1864 | |
| 1865 | if m.leanMode { |
| 1866 | return tea.Batch(cmds...) |
| 1867 | } |
| 1868 | |
| 1869 | // Full mode: update overlay components |
| 1870 | cmds = append(cmds, m.updateDialogCmd(tea.WindowSizeMsg{Width: width, Height: height})) |
| 1871 | |
| 1872 | m.tour.SetSize(width, height, m.contentHeight) |
| 1873 | |
| 1874 | m.completions.SetEditorBottom(editorHeight + m.tabBar.Height()) |
| 1875 | m.completions.Update(tea.WindowSizeMsg{Width: width, Height: height}) |
| 1876 | |
| 1877 | m.notification.SetSize(width, height) |
| 1878 | |
| 1879 | return tea.Batch(cmds...) |
| 1880 | } |
| 1881 | |
| 1882 | // Help returns help information for the status bar. |
| 1883 | func (m *appModel) Help() help.KeyMap { |
no test coverage detected