aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-23 23:39:17 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-23 23:39:17 +0200
commit38364646a73a5e666f2db6a34025e2a5a0e3999a (patch)
treec84911c6e8530f55c2fcfc06da587b10bec63547 /ui
parent997948ccad0ddd8e7ed2e87cbef1df10e14a3354 (diff)
Refactoring and documentation
Diffstat (limited to 'ui')
-rw-r--r--ui/widget/message-view.go8
1 files changed, 4 insertions, 4 deletions
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)