MCPcopy
hub / github.com/SurgeDM/Surge / refreshLogViewportContent

Method refreshLogViewportContent

internal/tui/helpers.go:37–60  ·  view source on GitHub ↗

refreshLogViewportContent re-renders log entries with current viewport wrapping.

()

Source from the content-addressed store, hash-verified

35
36// refreshLogViewportContent re-renders log entries with current viewport wrapping.
37func (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.

Callers 2

addLogEntryMethod · 0.95
UpdateMethod · 0.95

Calls 2

TruncateTwoLinesFunction · 0.92
HeightMethod · 0.80

Tested by

no test coverage detected