-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathmain.go
77 lines (63 loc) · 1.56 KB
/
main.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
package main
import (
"flag"
"fmt"
"image"
"image/color"
"log"
"os"
"runtime/pprof"
"gioui.org/app"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget/material"
)
func main() {
cpuprofile := flag.String("cpuprofile", "", "enable cpu profiling")
textSize := flag.Int("text-size", 12, "default font size")
filter := flag.String("filter", "", "filter the functions by regexp")
watch := flag.Bool("watch", false, "auto reload executable")
context := flag.Int("context", 3, "source line context")
font := flag.String("font", "", "user font")
workInProgressWASM = os.Getenv("LENSM_EXPERIMENT_WASM") != ""
flag.Parse()
exePath := flag.Arg(0)
if exePath == "" {
fmt.Fprintln(os.Stderr, "lensm <exePath>")
flag.Usage()
os.Exit(1)
}
windows := &Windows{}
theme := material.NewTheme()
theme.Shaper = text.NewShaper(text.WithCollection(LoadFonts(*font)))
theme.TextSize = unit.Sp(*textSize)
ui := NewExeUI(windows, theme)
ui.Config = FileUIConfig{
Path: exePath,
Watch: *watch,
Context: *context,
}
ui.Funcs.SetFilter(*filter)
windows.Open("lensm", image.Pt(1400, 900), ui.Run)
go func() {
profile(*cpuprofile, windows.Wait)
os.Exit(0)
}()
// This starts Gio main.
app.Main()
}
var (
secondaryBackground = color.NRGBA{R: 0xF0, G: 0xF0, B: 0xF0, A: 0xFF}
splitterColor = color.NRGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xFF}
)
func profile(cpuprofile string, fn func()) {
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
fn()
}