diff --git a/write_string.go b/write_string.go index aa046b0..dd7412e 100644 --- a/write_string.go +++ b/write_string.go @@ -3,11 +3,13 @@ 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) { - for dx, r := range str { - if x+dx >= b.width { + dx := x + for _, r := range str { + if dx >= b.width { return } - b.Set(x+dx, y, r) + b.Set(dx, y, r) + dx++ } }