mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
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:
18
cmd/micro/scrollbar.go
Normal file
18
cmd/micro/scrollbar.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user