Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e2be025b3 | |||
157e4f302d |
11
buffer.go
11
buffer.go
@ -65,6 +65,13 @@ func (b *Buffer[T]) Height() int {
|
||||
return b.height
|
||||
}
|
||||
|
||||
// ForEach calls f for every value in this buffer
|
||||
func (b *Buffer[T]) ForEachLine(f func(line int, content []T)) {
|
||||
for line, content := range b.data {
|
||||
f(line, content)
|
||||
}
|
||||
}
|
||||
|
||||
// ForEach calls f for every value in this buffer
|
||||
func (b *Buffer[T]) ForEach(f func(x, y int, v T)) {
|
||||
for y, col := range b.data {
|
||||
@ -95,8 +102,8 @@ func (b *Buffer[T]) Sub(x, y, w, h int) *Buffer[T] {
|
||||
// sanitize inputs
|
||||
x = limit(x, 0, b.width-1)
|
||||
y = limit(y, 0, b.height-1)
|
||||
w = limit(w, 1, b.width-x)
|
||||
h = limit(h, 1, b.height-y)
|
||||
w = limit(w, 0, b.width-x)
|
||||
h = limit(h, 0, b.height-y)
|
||||
|
||||
// make slice references
|
||||
data := make([][]T, h)
|
||||
|
Reference in New Issue
Block a user