1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-26 09:00:57 +02:00

help panel size from getConfirmationPanelDimensions

This commit is contained in:
Dawid Dziurla 2018-08-30 13:39:11 +02:00
parent 8a01d11202
commit 653d590157
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B

View File

@ -11,11 +11,14 @@ var keys []Binding
func (gui *Gui) handleHelpPress(g *gocui.Gui, v *gocui.View) error {
lineNumber := gui.getItemPosition(v)
err := gui.handleHelpClose(g, v)
if err != nil {
return err
if len(keys) > lineNumber {
err := gui.handleHelpClose(g, v)
if err != nil {
return err
}
return keys[lineNumber].Handler(g, v)
}
return keys[lineNumber].Handler(g, v)
return nil
}
func (gui *Gui) handleHelpSelect(g *gocui.Gui, v *gocui.View) error {
@ -49,15 +52,6 @@ func (gui *Gui) handleHelp(g *gocui.Gui, v *gocui.View) error {
keys = keys[:0]
content := ""
bindings := gui.getKeybindings()
maxX, maxY := g.Size()
x := maxX * 3 / 4
y := 5
helpView, _ := g.SetView("help", maxX-x, y, x, maxY-y, 0)
helpView.Title = strings.Title(gui.Tr.SLocalize("help"))
if err := gui.renderHelpOptions(g); err != nil {
return err
}
for _, binding := range bindings {
if binding.ViewName == v.Name() && binding.Description != "" && binding.KeyReadable != "" {
@ -66,6 +60,15 @@ func (gui *Gui) handleHelp(g *gocui.Gui, v *gocui.View) error {
}
}
// y1-1 so there will not be an extra space at the end of panel
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
helpView, _ := g.SetView("help", x0, y0, x1, y1-1, 0)
helpView.Title = strings.Title(gui.Tr.SLocalize("help"))
if err := gui.renderHelpOptions(g); err != nil {
return err
}
// for testing
/*content += "first\n"
content += "second\n"