From 38364646a73a5e666f2db6a34025e2a5a0e3999a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 23 Mar 2018 23:39:17 +0200 Subject: Refactoring and documentation --- ui/widget/message-view.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ui/widget') diff --git a/ui/widget/message-view.go b/ui/widget/message-view.go index e482b25..a3a7942 100644 --- a/ui/widget/message-view.go +++ b/ui/widget/message-view.go @@ -325,10 +325,10 @@ func (view *MessageView) Draw(screen tcell.Screen) { } totalHeight := float64(len(view.textBuffer)) - // ceil(height / (totalHeight / height)) + // The height of the scrollbar: ceil(height / (totalHeight / height)) scrollBarHeight := int(math.Ceil(float64(height) / (totalHeight / float64(height)))) - // height - ceil(scrollOffset) / totalHeight * height - scrollBarPos := height - int(math.Ceil(float64(view.ScrollOffset) / totalHeight * float64(height))) + // The position of the scrollbar from the bottom: height - ceil(scrollOffset) / totalHeight * height + scrollBarPos := height - int(math.Ceil(float64(view.ScrollOffset)/totalHeight*float64(height))) var prevMeta types.MessageMeta firstLine := true @@ -349,7 +349,7 @@ func (view *MessageView) Draw(screen tcell.Screen) { } else if line == height-1 && view.ScrollOffset == 0 { // At bottom of message history borderChar = '┴' - } else if line >= scrollBarPos && line < scrollBarPos + scrollBarHeight { + } else if line >= scrollBarPos && line < scrollBarPos+scrollBarHeight { // Scroll bar borderChar = '║' borderStyle = borderStyle.Foreground(tcell.ColorGreen) -- cgit v1.2.3