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
This commit is contained in:
Zachary Yedidia
2017-11-05 20:07:14 -05:00
parent c01ba97215
commit 423f4675d2
6 changed files with 89 additions and 17 deletions

18
cmd/micro/scrollbar.go Normal file
View File

@@ -0,0 +1,18 @@
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))
}