-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (48 loc) · 1.37 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
package main
import (
"context"
"flag"
"fmt"
"path/filepath"
_ "github.com/codeation/impress/duo"
"github.com/codeation/impress"
"github.com/codeation/tile/eventlink"
"github.com/codeation/lineation/mapcontrol"
"github.com/codeation/lineation/mapmodel"
"github.com/codeation/lineation/mapview"
"github.com/codeation/lineation/menuevent"
"github.com/codeation/lineation/modified"
"github.com/codeation/lineation/palette"
"github.com/codeation/lineation/xmlfile"
)
func run(ctx context.Context) error {
flag.Parse()
if len(flag.Args()) != 1 {
return fmt.Errorf("filename argument is missing")
}
filename := filepath.Clean(flag.Args()[0])
pal := palette.NewPalette()
title := fmt.Sprintf("lineation %s", filename)
app := eventlink.MainApp(impress.NewApplication(pal.DefaultAppRect(), title))
defer app.Close()
pal.FontLink(app.Application())
defer pal.FontClose()
menuevent.New(app.Application())
mapRoot, err := xmlfile.Open(filename)
if err != nil {
return fmt.Errorf("xmlfile.Open: %w", err)
}
mapModel := mapmodel.New(mapRoot, filename)
mapView := mapview.New(app, mapModel, pal)
defer mapView.Destroy()
modView := modified.NewView(app, pal)
defer modView.Destroy()
mapControl := mapcontrol.New(app, mapModel, mapView, modView)
app.Run(ctx, mapControl)
return nil
}
func main() {
if err := run(context.Background()); err != nil {
fmt.Println(err)
}
}