/
workspace.go
77 lines (64 loc) · 1.58 KB
/
workspace.go
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
70
71
72
73
74
75
76
77
package model
import (
"path/filepath"
)
// Workspace hold all state
type Workspace struct {
Groups []Group
Clip []FileItem
Tm *TaskManager
Current int
Bookmark *Bookmark
showBookmark bool
showClipDetail bool
showTaskDetail bool
}
// NewWorkspace create workspace
func NewWorkspace(maxGroups int, wd, configDir string) *Workspace {
gs := make([]Group, maxGroups)
g, err := NewLocalGroup(wd)
if err != nil {
panic(err)
}
gs[0] = g
return &Workspace{gs, nil, NewTaskManager(), 0, NewBookmark(filepath.Join(configDir, "bookmarks")), true, false, false}
}
// CurrentGroup get the current group in use
func (w *Workspace) CurrentGroup() Group {
return w.Groups[w.Current]
}
// SwitchTo change group
func (w *Workspace) SwitchTo(idx int) Group {
if idx < 0 {
idx = 0
}
if idx >= len(w.Groups) {
idx = len(w.Groups) - 1
}
w.Current = idx
return w.CurrentGroup()
}
// IsShowBookmark if to show bookmark
func (w *Workspace) IsShowBookmark() bool {
return w.showBookmark
}
// ToggleBookmark toggle bookmark
func (w *Workspace) ToggleBookmark() {
w.showBookmark = !w.showBookmark
}
// IsShowClipDetail if to show clip detail
func (w *Workspace) IsShowClipDetail() bool {
return w.showClipDetail
}
// ShowClipDetail if to show clip detail
func (w *Workspace) ShowClipDetail(show bool) {
w.showClipDetail = show
}
// IsShowTaskDetail if to show clip detail
func (w *Workspace) IsShowTaskDetail() bool {
return w.showTaskDetail
}
// ShowTaskDetail if to show task detail
func (w *Workspace) ShowTaskDetail(show bool) {
w.showTaskDetail = show
}