-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.go
78 lines (68 loc) · 1.79 KB
/
grid.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
78
package main
import (
"image"
"github.com/as/edit"
"github.com/as/frame"
"github.com/as/text"
"github.com/as/ui"
"github.com/as/ui/col"
"github.com/as/ui/tag"
"github.com/as/ui/win"
)
type Grid struct {
col.Table2
}
var (
GridLabel = "Newcol Killall Exit guru^(callees callers callstack definition describe freevars implements peers pointsto referrers what whicherrs)"
)
func NewGrid(dev ui.Dev, conf *tag.Config, files ...string) *Grid {
g := &Grid{col.NewTable2(dev, conf)}
g.Tag.Win.InsertString(GridLabel, 0)
return g
}
func (g *Grid) Move(sp image.Point) {
g.Table2.Move(sp)
}
func (g *Grid) Resize(size image.Point) {
g.ForceSize(size)
g.Tag.Resize(image.Pt(size.X, g.Config.TagHeight()))
col.Fill(g)
}
// Install places the given edit script in between
// calls to the target windows SetOrigin method. This
// is an experiment to test out highlighting with
// structural regular expressions.
//
// The current implementation will change and it
// has unfavorable performance characteristics (i.e., compiling
// the script every time), however, this isn't usually noticable
// unless the command is long
//
// Conventionally, the command should be in the form
// ,x,string,h
// Any other use is undefined and untested for now
func (g *Grid) Install(t *tag.Tag, srcprog string) {
w, _ := t.Body.(*win.Win)
if w == nil {
return
}
var green = frame.Palette{
Back: frame.Green,
Text: frame.A.Text,
}
prog, err := edit.Compile(srcprog)
if err != nil {
g.aerr(err.Error())
return
}
w.FuncInstall(func(w *win.Win) {
fr := w.Frame
buf := text.BufferFrom(w.Bytes()[w.Origin() : w.Origin()+fr.Len()])
ed, _ := text.Open(buf)
prog.Run(ed)
for _, dot := range prog.Emit.Dot {
w.Frame.Recolor(fr.PointOf(dot.Q0), dot.Q0, dot.Q1, green)
}
//prog.Emit = &edit.Emitted{}
})
}