refreshLogViewportContent re-renders log entries with current viewport wrapping.
()
| 35 | |
| 36 | // refreshLogViewportContent re-renders log entries with current viewport wrapping. |
| 37 | func (m *RootModel) refreshLogViewportContent() { |
| 38 | width := m.logViewport.Width() |
| 39 | if width <= 0 { |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | // Render each entry at the viewport width so the content fills the pane. |
| 44 | // TruncateTwoLines ensures long messages don't overflow the UI. |
| 45 | |
| 46 | var wrappedEntries []string |
| 47 | for _, entry := range m.logEntries { |
| 48 | wrapped := utils.TruncateTwoLines(entry, width) |
| 49 | wrappedEntries = append(wrappedEntries, strings.Split(wrapped, "\n")...) |
| 50 | } |
| 51 | |
| 52 | // Bottom-align entries if they don't fill the viewport |
| 53 | height := m.logViewport.Height() |
| 54 | if height > 0 && len(wrappedEntries) < height { |
| 55 | padding := make([]string, height-len(wrappedEntries)) |
| 56 | wrappedEntries = append(padding, wrappedEntries...) |
| 57 | } |
| 58 | |
| 59 | m.logViewport.SetContent(strings.Join(wrappedEntries, "\n")) |
| 60 | } |
| 61 | |
| 62 | // removeDownloadByID removes a download from the in-memory list. |
| 63 | // Returns true if a download was removed. |
no test coverage detected