-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathedit.go
More file actions
41 lines (37 loc) · 761 Bytes
/
edit.go
File metadata and controls
41 lines (37 loc) · 761 Bytes
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
package main
import (
"image"
"github.com/as/edit"
"github.com/as/text"
)
func reload(ed text.Editor) {
if ref, ok := ed.(interface {
Size() image.Point
Resize(image.Point)
}); ok {
ref.Resize(ref.Size())
}
repaint()
}
func (g *Grid) EditRun(prog string, ed text.Editor) (ok bool) {
//TODO(as): danger, edit needs a way to ensure it will only jump to an address
if prog == "" {
return false
}
if ed == nil {
g.aerr("edit: ed == nil")
return false
}
cmd, err := edit.Compile(prog)
if err != nil {
g.aerr("edit: compile: %q: %s", prog, err)
return false
}
err = cmd.Run(ed)
if err != nil {
g.aerr("edit: run: %q: %s", prog, err)
}
// TODO(as): should this be in the function? Probably not
reload(ed)
return err == nil
}