1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-18 05:17:55 +02:00

make command log size configurable

This commit is contained in:
Jesse Duffield 2021-04-11 22:03:55 +10:00
parent e4f0a470e9
commit 06a8eb115c
5 changed files with 45 additions and 29 deletions

View File

@ -41,7 +41,8 @@ gui:
skipUnstageLineWarning: false skipUnstageLineWarning: false
skipStashWarning: true skipStashWarning: true
showFileTree: false # for rendering changes files in a tree format showFileTree: false # for rendering changes files in a tree format
showCommandLog: showCommandLog: true
commandLogSize: 1
git: git:
paging: paging:
colorArg: always colorArg: always

View File

@ -37,6 +37,7 @@ type GuiConfig struct {
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
ShowFileTree bool `yaml:"showFileTree"` ShowFileTree bool `yaml:"showFileTree"`
ShowCommandLog bool `yaml:"showCommandLog"` ShowCommandLog bool `yaml:"showCommandLog"`
CommandLogSize int `yaml:"commandLogSize"`
} }
type ThemeConfig struct { type ThemeConfig struct {
@ -297,6 +298,9 @@ func GetDefaultConfig() *UserConfig {
}, },
CommitLength: CommitLengthConfig{Show: true}, CommitLength: CommitLengthConfig{Show: true},
SkipNoStagedFilesWarning: false, SkipNoStagedFilesWarning: false,
ShowCommandLog: true,
ShowFileTree: false,
CommandLogSize: 8,
}, },
Git: GitConfig{ Git: GitConfig{
Paging: PagingConfig{ Paging: PagingConfig{

View File

@ -150,7 +150,8 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
extrasWindowSize := 0 extrasWindowSize := 0
if gui.ShowExtrasWindow { if gui.ShowExtrasWindow {
extrasWindowSize = 10 frameSize := 2
extrasWindowSize = gui.Config.GetUserConfig().Gui.CommandLogSize + frameSize
if gui.currentStaticContext().GetKey() == COMMAND_LOG_CONTEXT_KEY { if gui.currentStaticContext().GetKey() == COMMAND_LOG_CONTEXT_KEY {
extrasWindowSize = 40 extrasWindowSize = 40
} }

View File

@ -0,0 +1,37 @@
package gui
import (
"fmt"
"strings"
"github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
// closing over this so that nobody else can modify it
currentSpan := ""
return func(entry oscommands.CmdLogEntry) {
if gui.Views.Extras == nil {
return
}
gui.Views.Extras.Autoscroll = true
if entry.GetSpan() != currentSpan {
fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(entry.GetSpan(), color.FgYellow))
currentSpan = entry.GetSpan()
}
clrAttr := theme.DefaultTextColor
if !entry.GetCommandLine() {
clrAttr = color.FgMagenta
}
gui.CmdLog = append(gui.CmdLog, entry.GetCmdStr())
indentedCmdStr := " " + strings.Replace(entry.GetCmdStr(), "\n", "\n ", -1)
fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(indentedCmdStr, clrAttr))
}
}

View File

@ -474,39 +474,12 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
gui.watchFilesForChanges() gui.watchFilesForChanges()
onRunCommand := gui.GetOnRunCommand() onRunCommand := gui.GetOnRunCommand()
oSCommand.SetOnRunCommand(onRunCommand) oSCommand.SetOnRunCommand(onRunCommand)
gui.OnRunCommand = onRunCommand gui.OnRunCommand = onRunCommand
return gui, nil return gui, nil
} }
func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
// closing over this so that nobody else can modify it
currentSpan := ""
return func(entry oscommands.CmdLogEntry) {
if gui.Views.Extras == nil {
return
}
gui.Views.Extras.Autoscroll = true
if entry.GetSpan() != currentSpan {
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(entry.GetSpan(), color.FgYellow))
currentSpan = entry.GetSpan()
}
clrAttr := theme.DefaultTextColor
if !entry.GetCommandLine() {
clrAttr = color.FgMagenta
}
gui.CmdLog = append(gui.CmdLog, entry.GetCmdStr())
indentedCmdStr := " " + strings.Replace(entry.GetCmdStr(), "\n", "\n ", -1)
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(indentedCmdStr, clrAttr))
}
}
// Run setup the gui with keybindings and start the mainloop // Run setup the gui with keybindings and start the mainloop
func (gui *Gui) Run() error { func (gui *Gui) Run() error {
recordEvents := recordingEvents() recordEvents := recordingEvents()