-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathwriter.go
More file actions
28 lines (23 loc) · 776 Bytes
/
Copy pathwriter.go
File metadata and controls
28 lines (23 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package gotoon
import "strings"
// LineWriter manages indented line output for TOON format
type LineWriter struct {
lines []string
indentationString string
}
// NewLineWriter creates a new LineWriter with the specified indentation size
func NewLineWriter(indentSize int) *LineWriter {
return &LineWriter{
lines: make([]string, 0),
indentationString: strings.Repeat(" ", indentSize),
}
}
// Push adds a new line with the specified depth and content
func (w *LineWriter) Push(depth int, content string) {
indent := strings.Repeat(w.indentationString, depth)
w.lines = append(w.lines, indent+content)
}
// String returns the accumulated lines joined with newlines
func (w *LineWriter) String() string {
return strings.Join(w.lines, "\n")
}