You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
552 B

package femto
import (
"github.com/gdamore/tcell/v2"
)
// ScrollBar represents an optional scrollbar that can be used
type ScrollBar struct {
view *View
}
// Display shows the scrollbar
func (sb *ScrollBar) Display(screen tcell.Screen) {
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))
}