buf2d/write_string.go

24 lines
469 B
Go
Raw Normal View History

2020-10-01 13:56:05 +02:00
package buf2d
// WriteString writes a whole string to the buffer at position (x,y)
// no word wrap is applied at all. If the string does not fit, it will be truncated
func (b *Buffer) WriteString(str string, x, y int) {
dx := x
for _, r := range str {
if dx >= b.width {
2020-10-01 13:56:05 +02:00
return
}
b.Set(dx, y, r)
dx++
2020-10-01 13:56:05 +02:00
}
}
2020-10-01 14:14:43 +02:00
// Fill fills the whole buffer with c
func (b *Buffer) Fill(c rune) {
for _, col := range b.data {
for ri := range col {
col[ri] = c
}
}
}