gilo/editor/buffer.go
Timothy Warren 1d4c8f99c0
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
Move file-specific logic to a document struct
2021-04-01 12:02:17 -04:00

47 lines
739 B
Go

package editor
import (
"fmt"
"strings"
)
// ----------------------------------------------------------------------------
// !Output Buffer
// ----------------------------------------------------------------------------
type buffer struct {
buf *strings.Builder
}
func newBuffer() *buffer {
var buf strings.Builder
b := new(buffer)
b.buf = &buf
return b
}
func (b *buffer) appendRune(r rune) int {
size, _ := b.buf.WriteRune(r)
return size
}
func (b *buffer) append(s string) int {
size, _ := b.buf.WriteString(s)
return size
}
func (b *buffer) appendLn(s string) int {
str := fmt.Sprintf("%s\r\n", s)
size, _ := b.buf.WriteString(str)
return size
}
func (b *buffer) toString() string {
return b.buf.String()
}