From 157e4f302d01664e3583cae61c3a2271158c2495 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sat, 2 Apr 2022 11:33:59 +0200 Subject: [PATCH] ForEachLine added --- buffer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/buffer.go b/buffer.go index 2cd85fd..80fe593 100644 --- a/buffer.go +++ b/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 {