blob: af6718c60047832a2f1e30ecd7b576b7ff2c7c26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package gui
import "os/exec"
type viewUpdateOpts struct {
title string
task func() error
}
type refreshMainOpts struct {
main *viewUpdateOpts
secondary *viewUpdateOpts
}
// constants for updateTask's kind field
const (
RENDER_STRING = iota
RUN_FUNCTION
RUN_COMMAND
)
type updateTask struct {
kind int
str string
f func(chan struct{}) error
cmd *exec.Cmd
}
func (gui *Gui) createRenderStringTask(str string) {
}
func (gui *Gui) refreshMain(opts refreshMainOpts) error {
mainView := gui.getMainView()
secondaryView := gui.getSecondaryView()
if opts.main != nil {
mainView.Title = opts.main.title
if err := opts.main.task(); err != nil {
gui.Log.Error(err)
return nil
}
}
gui.splitMainPanel(opts.secondary != nil)
if opts.secondary != nil {
secondaryView.Title = opts.secondary.title
if err := opts.secondary.task(); err != nil {
gui.Log.Error(err)
return nil
}
}
return nil
}
func (gui *Gui) splitMainPanel(splitMainPanel bool) {
gui.State.SplitMainPanel = splitMainPanel
// no need to set view on bottom when splitMainPanel is false: it will have zero size anyway thanks to our view arrangement code.
if splitMainPanel {
_, _ = gui.g.SetViewOnTop("secondary")
}
}
func (gui *Gui) isMainPanelSplit() bool {
return gui.State.SplitMainPanel
}
|