-
Notifications
You must be signed in to change notification settings - Fork 25
/
a.go
66 lines (60 loc) · 1.41 KB
/
a.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
package main
import (
"fmt"
"strings"
"time"
"github.com/as/ui/tag"
)
func addrfmt(label string, q0, q1 int64) string {
if q0 == q1 {
return fmt.Sprintf("%s:#%d", label, q1)
}
return fmt.Sprintf("%s:#%d,#%d", label, q0, q1)
}
func (g *Grid) aerr(fm string, i ...interface{}) {
t := g.afinderr(".", "")
if t == nil || t.Window == nil {
return
}
fmt.Fprintf(t, "%s: %s\n", time.Now().Format(timefmt), fmt.Sprintf(fm, i...))
ajump(t.Window, cursorNop)
}
func (g *Grid) aout(fm string, i ...interface{}) {
t := g.afinderr(".", "")
fmt.Fprintf(t, fm+"\n", i...)
ajump(t.Window, cursorNop)
}
func (g *Grid) aguru(fm string, i ...interface{}) {
t := g.afindguru(".", "")
fmt.Fprintf(t, "%s: %s", time.Now().Format(timefmt), fmt.Sprintf(fm, i...))
ajump(t.Window, cursorNop)
}
func (g *Grid) afindguru(wd string, name string) *tag.Tag {
if !strings.HasSuffix(name, "+Guru") {
name += "+Guru"
}
t := g.FindName(name)
if t == nil {
c := g.List[len(g.List)-1].(*Col)
t = New(c, "", name).(*tag.Tag)
if t == nil {
panic("cant create tag")
}
}
return t
}
func (g *Grid) afinderr(wd string, name string) *tag.Tag {
name = strings.TrimSpace(name)
if !strings.HasSuffix(name, "+Errors") {
name += "+Errors"
}
t := g.FindName(name)
if t == nil {
c := g.List[len(g.List)-1].(*Col)
t = New(c, "", name).(*tag.Tag)
// r := t.Bounds()
// r1 := underText(t)
//moveMouse(t.Bounds().Min)
}
return t
}