summaryrefslogtreecommitdiffstats
path: root/pkg/gui/filetree/collapsed_paths.go
blob: 02c0b430397dec2e5e57a21d8214c27837a111e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package filetree

type CollapsedPaths map[string]bool

func (cp CollapsedPaths) ExpandToPath(path string) {
	// need every directory along the way
	splitPath := split(path)
	for i := range splitPath {
		dir := join(splitPath[0 : i+1])
		cp[dir] = false
	}
}

func (cp CollapsedPaths) IsCollapsed(path string) bool {
	return cp[path]
}

func (cp CollapsedPaths) ToggleCollapsed(path string) {
	cp[path] = !cp[path]
}