mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-13 20:04:25 +02:00
pull out function
This commit is contained in:
@@ -473,30 +473,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
|
|||||||
|
|
||||||
gui.watchFilesForChanges()
|
gui.watchFilesForChanges()
|
||||||
|
|
||||||
onRunCommand := func() func(entry oscommands.CmdLogEntry) {
|
onRunCommand := gui.GetOnRunCommand()
|
||||||
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))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
oSCommand.SetOnRunCommand(onRunCommand)
|
oSCommand.SetOnRunCommand(onRunCommand)
|
||||||
gui.OnRunCommand = onRunCommand
|
gui.OnRunCommand = onRunCommand
|
||||||
@@ -504,6 +481,32 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
|
|||||||
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()
|
||||||
|
Reference in New Issue
Block a user