mirror of
https://github.com/diamondburned/cchat-discord.git
synced 2024-11-01 12:24:15 +00:00
28 lines
459 B
Go
28 lines
459 B
Go
|
package segutil
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
|
||
|
"github.com/diamondburned/cchat/text"
|
||
|
)
|
||
|
|
||
|
// helper global functions
|
||
|
|
||
|
func WriteBuf(w *bytes.Buffer, b []byte) (start, end int) {
|
||
|
start = w.Len()
|
||
|
w.Write(b)
|
||
|
end = w.Len()
|
||
|
return start, end
|
||
|
}
|
||
|
|
||
|
func WriteStringBuf(w *bytes.Buffer, b string) (start, end int) {
|
||
|
start = w.Len()
|
||
|
w.WriteString(b)
|
||
|
end = w.Len()
|
||
|
return start, end
|
||
|
}
|
||
|
|
||
|
func Add(r *text.Rich, seg ...text.Segment) {
|
||
|
r.Segments = append(r.Segments, seg...)
|
||
|
}
|