From 58281da28614386809eab60c9dcbb86082354f1b Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 2 Jun 2025 06:40:29 -0500 Subject: indicate when the user is scrolled up --- client/buffer/buffer.go | 4 ++++ client/ui.go | 20 ++++++++++++++++++-- tui/layout.go | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/client/buffer/buffer.go b/client/buffer/buffer.go index 921ad00..3fea156 100644 --- a/client/buffer/buffer.go +++ b/client/buffer/buffer.go @@ -77,6 +77,10 @@ func (b *Buffer) ScrollBottom() { b.scroll.ToStart() } +func (b *Buffer) ScrollPos() int { + return b.scroll.Get() +} + func (b *Buffer) AtBottom() bool { return b.scroll.AtFirst() } diff --git a/client/ui.go b/client/ui.go index 2fc71f6..37b7d4e 100644 --- a/client/ui.go +++ b/client/ui.go @@ -65,13 +65,29 @@ func (a *application) show() { }) a.getWin().Buffer().Show("buffer") - tui.Push("status", tui.Box { - Width: tui.Fill, Height: tui.BoxSize(1), Dir: tui.Right, + tui.Push("input border", tui.Box { + Width: tui.Fill, Height: 1, Dir: tui.Left, Style: &tui.Style {Bg: tui.White, Fg: tui.Black}, }) + + if a.getWin().Buffer().ScrollPos() > 0 { + tui.Push("", tui.Box {Width: tui.TextSize, Height: 1, NoWrap: true}) + if a.getWin().Buffer().AtTop() { + tui.Text("[TOP]", nil) + } else { + tui.Text("[MORE]", nil) + } + tui.Pop() + } + tui.Push("", tui.Box {Width: tui.Fill, Height: 1}) + tui.Pop() + + tui.Push("status", tui.Box {Width: tui.TextSize, Height: 1, NoWrap: true}) a.getWin().ShowStatusLine() tui.Pop() + tui.Pop() + tui.Push("input container", tui.Box { Width: tui.Fill, Height: tui.Children, Dir: tui.Right, }) diff --git a/tui/layout.go b/tui/layout.go index 480f3cc..2becbb8 100644 --- a/tui/layout.go +++ b/tui/layout.go @@ -66,6 +66,10 @@ func (s *ScrollState) Scroll(amnt int) { s.absolute += amnt } +func (s *ScrollState) Get() int { + return s.absolute +} + var layout struct { front map[string]*Box back map[string]*Box -- cgit v1.2.3