1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

Added another resizing step

This commit is contained in:
mjarkk 2019-04-25 21:37:19 +02:00
parent 07fec6d00e
commit 6ba05c94ea
2 changed files with 49 additions and 40 deletions

View File

@ -344,23 +344,44 @@ func (gui *Gui) layout(g *gocui.Gui) error {
} }
} }
statusFilesBoundary = optionsTop - 12 if height < 21 {
filesBranchesBoundary = optionsTop - 9 statusFilesBoundary = optionsTop - 8
commitsBranchesBoundary = optionsTop - 6 filesBranchesBoundary = optionsTop - 6
commitsStashBoundary = optionsTop - 3 commitsBranchesBoundary = optionsTop - 4
commitsStashBoundary = optionsTop - 2
switch currentCyclebleView { switch currentCyclebleView {
case "stash": case "stash":
commitsStashBoundary = 11 commitsStashBoundary = 7
fallthrough fallthrough
case "commits": case "commits":
commitsBranchesBoundary = 8 commitsBranchesBoundary = 5
fallthrough fallthrough
case "branches": case "branches":
filesBranchesBoundary = 5 filesBranchesBoundary = 3
fallthrough fallthrough
case "files": case "files":
statusFilesBoundary = 2 statusFilesBoundary = 1
}
} else {
statusFilesBoundary = optionsTop - 12
filesBranchesBoundary = optionsTop - 9
commitsBranchesBoundary = optionsTop - 6
commitsStashBoundary = optionsTop - 3
switch currentCyclebleView {
case "stash":
commitsStashBoundary = 11
fallthrough
case "commits":
commitsBranchesBoundary = 8
fallthrough
case "branches":
filesBranchesBoundary = 5
fallthrough
case "files":
statusFilesBoundary = 2
}
} }
} else { } else {
statusFilesBoundary = 2 statusFilesBoundary = 2

View File

@ -173,9 +173,7 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error {
} }
func (gui *Gui) resetOrigin(v *gocui.View) error { func (gui *Gui) resetOrigin(v *gocui.View) error {
if err := v.SetCursor(0, 0); err != nil { _ = v.SetCursor(0, 0)
return err
}
return v.SetOrigin(0, 0) return v.SetOrigin(0, 0)
} }
@ -186,36 +184,26 @@ func (gui *Gui) focusPoint(cx int, cy int, lineCount int, v *gocui.View) error {
} }
ox, oy := v.Origin() ox, oy := v.Origin()
_, height := v.Size() _, height := v.Size()
ly := height - 1 ly := height - 1
if ly == -1 {
ly = 0
}
// if line is above origin, move origin and set cursor to zero // if line is above origin, move origin and set cursor to zero
// if line is below origin + height, move origin and set cursor to max // if line is below origin + height, move origin and set cursor to max
// otherwise set cursor to value - origin // otherwise set cursor to value - origin
if ly > lineCount { if ly > lineCount {
if err := v.SetCursor(cx, cy); err != nil { _ = v.SetCursor(cx, cy)
return err _ = v.SetOrigin(ox, 0)
}
if err := v.SetOrigin(ox, 0); err != nil {
return err
}
} else if cy < oy { } else if cy < oy {
if err := v.SetCursor(cx, 0); err != nil { _ = v.SetCursor(cx, 0)
return err _ = v.SetOrigin(ox, cy)
}
if err := v.SetOrigin(ox, cy); err != nil {
return err
}
} else if cy > oy+ly { } else if cy > oy+ly {
if err := v.SetCursor(cx, ly); err != nil { _ = v.SetCursor(cx, ly)
return err _ = v.SetOrigin(ox, cy-ly)
}
if err := v.SetOrigin(ox, cy-ly); err != nil {
return err
}
} else { } else {
if err := v.SetCursor(cx, cy-oy); err != nil { _ = v.SetCursor(cx, cy-oy)
return err
}
} }
return nil return nil
} }