SetContent provides the full content buffer and total height. totalHeight may be >= len(lines) for virtual blank lines (e.g. bottomSlack). The lines slice must not be mutated in place after being passed here; callers rebuild a fresh slice when content changes.
(lines []string, totalHeight int)
| 123 | // The lines slice must not be mutated in place after being passed here; |
| 124 | // callers rebuild a fresh slice when content changes. |
| 125 | func (m *Model) SetContent(lines []string, totalHeight int) { |
| 126 | if len(lines) != len(m.lines) || (len(lines) > 0 && &lines[0] != &m.lines[0]) { |
| 127 | m.lineWidths = nil |
| 128 | } |
| 129 | m.lines = lines |
| 130 | m.totalHeight = max(totalHeight, len(lines)) |
| 131 | m.sb.SetDimensions(m.height, m.totalHeight) |
| 132 | } |
| 133 | |
| 134 | // lineWidth returns the display width of content line i, memoized across frames. |
| 135 | func (m *Model) lineWidth(i int) int { |