diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 21:10:05 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 21:10:05 +0100 |
commit | 2a233c2fec2278610173b27605cad5232ed26609 (patch) | |
tree | ddd522f482f5399b911019a05c78cbd3ec9de9fd /xA | |
parent | ad61b790fdef156179b843e439be28613369ded7 (diff) | |
download | xK-2a233c2fec2278610173b27605cad5232ed26609.tar.gz xK-2a233c2fec2278610173b27605cad5232ed26609.tar.xz xK-2a233c2fec2278610173b27605cad5232ed26609.zip |
WIP: xA: fix buffer position indicator
Diffstat (limited to 'xA')
-rw-r--r-- | xA/xA.go | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -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) |