diff options
Diffstat (limited to 'go/ui')
| -rw-r--r-- | go/ui/buffer.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/go/ui/buffer.go b/go/ui/buffer.go index 3abbc2cc..8294c905 100644 --- a/go/ui/buffer.go +++ b/go/ui/buffer.go @@ -2,6 +2,7 @@ package ui import ( "image/color" + "iter" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/text/v2" @@ -72,6 +73,21 @@ func (b *Buffer) Remove(idx int) { b.ForceRedraw() } +func (b *Buffer) PrefixLine(idx int, prefix string) { + b.lines[idx] = prefix + b.lines[idx] + b.ForceRedraw() +} + +func (b *Buffer) LinesSeq() iter.Seq[string] { + return func(yield func(string) bool) { + for _, l := range b.lines { + if !yield(l) { + return + } + } + } +} + func (*Buffer) IsScrollable() bool { return true } func (b *Buffer) Scroll(x, y int) { |
