MCPcopy
hub / github.com/jesseduffield/lazygit / drawFrameEdges

Method drawFrameEdges

pkg/gocui/gui.go:839–880  ·  view source on GitHub ↗

drawFrameEdges draws the horizontal and vertical edges of a view.

(v *View, fgColor, bgColor Attribute)

Source from the content-addressed store, hash-verified

837
838// drawFrameEdges draws the horizontal and vertical edges of a view.
839func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
840 runeH, runeV := '─', '│'
841 if len(v.FrameRunes) >= 2 {
842 runeH, runeV = v.FrameRunes[0], v.FrameRunes[1]
843 }
844
845 for x := v.x0 + 1; x < v.x1 && x < g.maxX; x++ {
846 if x < 0 {
847 continue
848 }
849 if v.y0 > -1 && v.y0 < g.maxY {
850 if err := g.SetRune(x, v.y0, runeH, fgColor, bgColor); err != nil {
851 return err
852 }
853 }
854 if v.y1 > -1 && v.y1 < g.maxY {
855 if err := g.SetRune(x, v.y1, runeH, fgColor, bgColor); err != nil {
856 return err
857 }
858 }
859 }
860
861 showScrollbar, realScrollbarStart, realScrollbarEnd := calcRealScrollbarStartEnd(v)
862 for y := v.y0 + 1; y < v.y1 && y < g.maxY; y++ {
863 if y < 0 {
864 continue
865 }
866 if v.x0 > -1 && v.x0 < g.maxX {
867 if err := g.SetRune(v.x0, y, runeV, fgColor, bgColor); err != nil {
868 return err
869 }
870 }
871 if v.x1 > -1 && v.x1 < g.maxX {
872 runeToPrint := calcScrollbarRune(showScrollbar, realScrollbarStart, realScrollbarEnd, y, runeV)
873
874 if err := g.SetRune(v.x1, y, runeToPrint, fgColor, bgColor); err != nil {
875 return err
876 }
877 }
878 }
879 return nil
880}
881
882func calcScrollbarRune(
883 showScrollbar bool, scrollbarStart int, scrollbarEnd int, position int, runeV rune,

Callers 1

drawMethod · 0.95

Calls 3

SetRuneMethod · 0.95
calcScrollbarRuneFunction · 0.85

Tested by

no test coverage detected