-
Notifications
You must be signed in to change notification settings - Fork 25
/
conductor.go
67 lines (59 loc) · 1.03 KB
/
conductor.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
package main
/*
import (
"errors"
"image"
"strings"
"github.com/as/ui/col"
"github.com/as/ui/tag"
)
var (
ErrPlacement = errors.New("placement error")
ErrUnknown = errors.New("unknown placement request")
)
type evp struct {
dst, src Plane
root Plane
}
var (
evpI = make(chan evp)
evpO = make(chan error)
)
func conduct() {
for {
select {
case evp := <-evpI:
select{
case evpO <- place(evp):
}
}
}
}
func place(e evp) error {
switch t := e.src.(type) {
case *tag.Tag:
g, _ := e.root.(*Grid)
c, _ := e.dst.(*col.Col)
if c == nil {
return ErrPlacement
}
if g != nil && strings.HasSuffix(t.FileName(), "+Errors") && len(g.List) > 1 {
c0 := g.List[len(g.List)-1].(*Col)
if c0 != nil {
c = c0
}
}
dDY := c.Area().Dy()
if c.Len() > 0 {
last := c.List[len(c.List)-1]
if c.Area().Dy() > last.Bounds().Dy()*3 {
logf("should roll up windows--area too small")
}
dDY = last.Bounds().Dy() / 2
}
col.Attach(c, t, image.Pt(dDY, dDY))
return nil
}
return ErrUnknown
}
*/