From 2a233c2fec2278610173b27605cad5232ed26609 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sun, 10 Nov 2024 21:10:05 +0100 Subject: WIP: xA: fix buffer position indicator --- xA/xA.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'xA/xA.go') diff --git a/xA/xA.go b/xA/xA.go index f61102e..2357711 100644 --- a/xA/xA.go +++ b/xA/xA.go @@ -219,6 +219,7 @@ var ( wRichText *widget.RichText wRichScroll *container.Scroll wPrompt *widget.Label + wDown *widget.Icon wStatus *widget.Label wEntry *customEntry ) @@ -323,8 +324,8 @@ func bufferToggleUnimportant(name string) { // --- Current buffer ---------------------------------------------------------- func bufferAtBottom() bool { - // TODO(p): Figure out how to implement this. - return false + return wRichScroll.Offset.Y >= + wRichScroll.Content.Size().Height-wRichScroll.Size().Height } func bufferScrollToBottom() { @@ -396,12 +397,13 @@ func refreshPrompt() { } func refreshStatus() { - var status string - if !bufferAtBottom() { - status += "🡇 " + if bufferAtBottom() { + wDown.Hide() + } else { + wDown.Show() } - status += bufferCurrent + status := bufferCurrent if b := bufferByName(bufferCurrent); b != nil { if b.modes != "" { status += "(+" + b.modes + ")" @@ -1119,9 +1121,14 @@ func main() { wTopic = widget.NewRichText() wTopic.Truncation = fyne.TextTruncateEllipsis + wRichText = widget.NewRichText() wRichText.Wrapping = fyne.TextWrapWord wRichScroll = container.NewVScroll(wRichText) + wRichScroll.OnScrolled = func(position fyne.Position) { + refreshStatus() + } + wPrompt = widget.NewLabelWithStyle( "", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}) wStatus = widget.NewLabelWithStyle( @@ -1140,9 +1147,11 @@ func main() { wTopic, widget.NewSeparator(), ) + wDown = widget.NewIcon(theme.MoveDownIcon()) bottom := container.NewVBox( widget.NewSeparator(), - container.NewBorder(nil, nil, wPrompt, wStatus), + container.NewBorder(nil, nil, + wPrompt, container.NewHBox(wDown, wStatus)), wEntry, ) split := container.NewHSplit(wBufferList, wRichScroll) -- cgit v1.2.3-70-g09d2