1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-19 00:28:03 +02:00

Use slimmer scrollbars

The previous scrollbars were too chunky and encroached too much on a view's content.

The new ones are slim and right-aligned so they encroach into dead space between views
which is much better
This commit is contained in:
Jesse Duffield
2024-01-30 08:42:10 +11:00
parent 9d840088ac
commit f9e8428061
24 changed files with 1098 additions and 587 deletions

View File

@ -860,7 +860,7 @@ func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
}
}
if v.x1 > -1 && v.x1 < g.maxX {
runeToPrint := calcScrollbarRune(showScrollbar, realScrollbarStart, realScrollbarEnd, v.y0+1, v.y1-1, y, runeV)
runeToPrint := calcScrollbarRune(showScrollbar, realScrollbarStart, realScrollbarEnd, y, runeV)
if err := g.SetRune(v.x1, y, runeToPrint, fgColor, bgColor); err != nil {
return err
@ -870,18 +870,11 @@ func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
return nil
}
func calcScrollbarRune(showScrollbar bool, scrollbarStart int, scrollbarEnd int, rangeStart int, rangeEnd int, position int, runeV rune) rune {
if !showScrollbar {
return runeV
} else if position == rangeStart {
return ''
} else if position == rangeEnd {
return '▼'
} else if position > scrollbarStart && position < scrollbarEnd {
return '█'
} else if position > rangeStart && position < rangeEnd {
// keeping this as a separate branch in case we later want to render something different here.
return runeV
func calcScrollbarRune(
showScrollbar bool, scrollbarStart int, scrollbarEnd int, position int, runeV rune,
) rune {
if showScrollbar && (position >= scrollbarStart && position <= scrollbarEnd) {
return ''
} else {
return runeV
}

View File

@ -23,11 +23,6 @@ func calcScrollbarHeight(listSize int, pageSize int, scrollAreaSize int) int {
if pageSize >= listSize {
return scrollAreaSize
}
height := int((float64(pageSize) / float64(listSize)) * float64(scrollAreaSize))
minHeight := 2
if height < minHeight {
return minHeight
}
return height
return int((float64(pageSize) / float64(listSize)) * float64(scrollAreaSize))
}