aboutsummaryrefslogtreecommitdiff
path: root/go/ui/buffer.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-03 14:05:14 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:46:38 +0200
commit8802f30ff720fcb64d9207c4cb673dc6805390c2 (patch)
tree9be529221105fc8681e3afb0e673e229ef9504d4 /go/ui/buffer.go
parente8f44219976edf8cf57cbd9e964f66fe9d145a9c (diff)
downloadmuhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.tar.gz
muhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.zip
add text input and properly center text
Diffstat (limited to 'go/ui/buffer.go')
-rw-r--r--go/ui/buffer.go13
1 files changed, 13 insertions, 0 deletions
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()
+}