Files
zyedidia.micro/cmd/micro/scrollbar.go
Zachary Yedidia 423f4675d2 Add a scroll bar option
The option is `scrollbar` and is off by default. The scroll bar is
not interactive (you can't click and drag it) but this will likely
be fixed in the future.

Ref #869
2017-11-05 20:07:14 -05:00

19 lines
395 B
Go

package main
type ScrollBar struct {
view *View
}
func (sb *ScrollBar) Display() {
style := defStyle.Reverse(true)
screen.SetContent(sb.view.x+sb.view.Width-1, sb.view.y+sb.Pos(), ' ', nil, style)
}
func (sb *ScrollBar) Pos() int {
numlines := sb.view.Buf.NumLines
h := sb.view.Height
filepercent := float32(sb.view.Topline) / float32(numlines)
return int(filepercent * float32(h))
}