Add visual scroll bar
This commit is contained in:
parent
bc3f845c0d
commit
4dccfc095d
1 changed files with 26 additions and 2 deletions
|
@ -368,6 +368,11 @@ func (w *BufWindow) displayBuffer() {
|
||||||
bufHeight--
|
bufHeight--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bufWidth := w.Width
|
||||||
|
if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height {
|
||||||
|
bufWidth--
|
||||||
|
}
|
||||||
|
|
||||||
w.hasCalcHeight = true
|
w.hasCalcHeight = true
|
||||||
start := w.StartLine
|
start := w.StartLine
|
||||||
if b.Settings["syntax"].(bool) && b.SyntaxDef != nil {
|
if b.Settings["syntax"].(bool) && b.SyntaxDef != nil {
|
||||||
|
@ -564,7 +569,7 @@ func (w *BufWindow) displayBuffer() {
|
||||||
totalwidth += width
|
totalwidth += width
|
||||||
|
|
||||||
// If we reach the end of the window then we either stop or we wrap for softwrap
|
// If we reach the end of the window then we either stop or we wrap for softwrap
|
||||||
if vloc.X >= w.Width {
|
if vloc.X >= bufWidth {
|
||||||
if !softwrap {
|
if !softwrap {
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
|
@ -590,7 +595,7 @@ func (w *BufWindow) displayBuffer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := vloc.X; i < w.Width; i++ {
|
for i := vloc.X; i < bufWidth; i++ {
|
||||||
curStyle := style
|
curStyle := style
|
||||||
if s, ok := config.Colorscheme["color-column"]; ok {
|
if s, ok := config.Colorscheme["color-column"]; ok {
|
||||||
if colorcolumn != 0 && i-w.gutterOffset == colorcolumn {
|
if colorcolumn != 0 && i-w.gutterOffset == colorcolumn {
|
||||||
|
@ -635,8 +640,27 @@ func (w *BufWindow) displayStatusLine() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *BufWindow) displayScrollBar() {
|
||||||
|
if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height {
|
||||||
|
scrollX := w.X + w.Width - 1
|
||||||
|
bufHeight := w.Height
|
||||||
|
if w.drawStatus {
|
||||||
|
bufHeight--
|
||||||
|
}
|
||||||
|
barsize := int(float64(w.Height) / float64(w.Buf.LinesNum()) * float64(w.Height))
|
||||||
|
if barsize < 1 {
|
||||||
|
barsize = 1
|
||||||
|
}
|
||||||
|
barstart := int(float64(w.StartLine) / float64(w.Buf.LinesNum()) * float64(w.Height))
|
||||||
|
for y := barstart; y < util.Min(barstart+barsize, w.Y+bufHeight); y++ {
|
||||||
|
screen.Screen.SetContent(scrollX, y, '|', nil, config.DefStyle.Reverse(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Display displays the buffer and the statusline
|
// Display displays the buffer and the statusline
|
||||||
func (w *BufWindow) Display() {
|
func (w *BufWindow) Display() {
|
||||||
w.displayStatusLine()
|
w.displayStatusLine()
|
||||||
|
w.displayScrollBar()
|
||||||
w.displayBuffer()
|
w.displayBuffer()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue