]> git.lizzy.rs Git - micro.git/blob - cmd/micro/scrollbar.go
Code optimisation (#1117)
[micro.git] / cmd / micro / scrollbar.go
1 package main
2
3 // ScrollBar represents an optional scrollbar that can be used
4 type ScrollBar struct {
5         view *View
6 }
7
8 // Display shows the scrollbar
9 func (sb *ScrollBar) Display() {
10         style := defStyle.Reverse(true)
11         screen.SetContent(sb.view.x+sb.view.Width-1, sb.view.y+sb.pos(), ' ', nil, style)
12 }
13
14 func (sb *ScrollBar) pos() int {
15         numlines := sb.view.Buf.NumLines
16         h := sb.view.Height
17         filepercent := float32(sb.view.Topline) / float32(numlines)
18
19         return int(filepercent * float32(h))
20 }