summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/gui.go47
1 files changed, 25 insertions, 22 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 153c663f8..f6c273859 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -473,35 +473,38 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
gui.watchFilesForChanges()
- onRunCommand := func() func(entry oscommands.CmdLogEntry) {
- currentSpan := ""
+ onRunCommand := gui.GetOnRunCommand()
- return func(entry oscommands.CmdLogEntry) {
- if gui.Views.Extras == nil {
- return
- }
+ oSCommand.SetOnRunCommand(onRunCommand)
+ gui.OnRunCommand = onRunCommand
- gui.Views.Extras.Autoscroll = true
+ return gui, nil
+}
- if entry.GetSpan() != currentSpan {
- fmt.Fprintln(gui.Views.Extras, utils.ColoredString(entry.GetSpan(), color.FgYellow))
- currentSpan = entry.GetSpan()
- }
+func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
+ // closing over this so that nobody else can modify it
+ currentSpan := ""
- 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))
+ return func(entry oscommands.CmdLogEntry) {
+ if gui.Views.Extras == nil {
+ return
}
- }()
- oSCommand.SetOnRunCommand(onRunCommand)
- gui.OnRunCommand = onRunCommand
+ gui.Views.Extras.Autoscroll = true
- return gui, nil
+ 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