1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-03 00:57:52 +02:00

render commit graph

This commit is contained in:
Jesse Duffield
2021-11-02 16:39:15 +11:00
parent 2fc1498517
commit 802cfb1a04
53 changed files with 543 additions and 284 deletions

View File

@ -879,11 +879,18 @@ func (v *View) draw() error {
if v.Autoscroll && visibleViewLinesHeight > maxY {
v.oy = visibleViewLinesHeight - maxY
}
if len(v.viewLines) == 0 {
return nil
}
start := v.oy
if start > len(v.viewLines)-1 {
start = len(v.viewLines) - 1
}
y := 0
for i, vline := range v.viewLines {
if i < v.oy {
continue
}
for _, vline := range v.viewLines[start:] {
if y >= maxY {
break
}
@ -1112,14 +1119,6 @@ func (v *View) SetHighlight(y int, on bool) error {
return nil
}
func lineWidth(line []cell) (n int) {
for i := range line {
n += runewidth.RuneWidth(line[i].chr)
}
return
}
func lineWrap(line []cell, columns int) [][]cell {
if columns == 0 {
return [][]cell{line}
@ -1227,3 +1226,16 @@ func (v *View) ClearTextArea() {
_ = v.SetOrigin(0, 0)
_ = v.SetCursor(0, 0)
}
// only call this function if you don't care where v.wx and v.wy end up
func (v *View) OverwriteLines(y int, content string) {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
// break by newline, then for each line, write it, then add that erase command
v.wx = 0
v.wy = y
lines := strings.Replace(content, "\n", "\x1b[K\n", -1)
v.writeString(lines)
}