From 642b2e14532f906fe133bf2d05bb132ebb53d9ef Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 3 Feb 2023 14:05:14 +0100 Subject: add text input and properly center text --- go/ui/buffer.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'go/ui/buffer.go') diff --git a/go/ui/buffer.go b/go/ui/buffer.go index c451d7fc..e95102fe 100644 --- a/go/ui/buffer.go +++ b/go/ui/buffer.go @@ -64,3 +64,16 @@ func (b *Buffer) Remove(idx int) { b.lines = append(b.lines[:idx], b.lines[idx+1:]...) b.ForceRedraw() } + +func (b *Buffer) Scroll(x, y int) { + if y == 0 { + return + } + + if y < 0 && b.pos > 0 { + b.pos-- + } else if y > 0 && b.pos < len(b.lines)-1 { + b.pos++ + } + b.ForceRedraw() +} -- cgit v1.2.3