|
1 | 1 | package main
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "context" |
4 | 5 | "flag"
|
5 | 6 | "fmt"
|
| 7 | + "path/filepath" |
6 | 8 |
|
7 | 9 | _ "github.com/codeation/impress/duo"
|
8 | 10 |
|
9 |
| - "github.com/codeation/lineation/application" |
10 |
| - "github.com/codeation/lineation/mindmap" |
| 11 | + "github.com/codeation/impress" |
| 12 | + "github.com/codeation/tile/eventlink" |
| 13 | + |
| 14 | + "github.com/codeation/lineation/mapcontrol" |
| 15 | + "github.com/codeation/lineation/mapmodel" |
| 16 | + "github.com/codeation/lineation/mapview" |
| 17 | + "github.com/codeation/lineation/menuevent" |
| 18 | + "github.com/codeation/lineation/palette" |
| 19 | + "github.com/codeation/lineation/xmlfile" |
11 | 20 | )
|
12 | 21 |
|
13 |
| -func run() error { |
| 22 | +func run(ctx context.Context) error { |
14 | 23 | flag.Parse()
|
15 | 24 | if len(flag.Args()) != 1 {
|
16 | 25 | return fmt.Errorf("filename argument is missing")
|
17 | 26 | }
|
| 27 | + filename := filepath.Clean(flag.Args()[0]) |
| 28 | + |
| 29 | + pal := palette.NewPalette() |
| 30 | + a := impress.NewApplication(pal.DefaultAppRect(), fmt.Sprintf("lineation %s", filename)) |
| 31 | + app := eventlink.MainApp(a) |
| 32 | + defer app.Close() |
| 33 | + menuevent.New(app.Application) |
18 | 34 |
|
19 |
| - mm, err := mindmap.Open(flag.Args()[0]) |
| 35 | + mapRoot, err := xmlfile.Open(filename) |
20 | 36 | if err != nil {
|
21 |
| - return fmt.Errorf("NewMindMap: %w", err) |
| 37 | + return fmt.Errorf("xmlfile.Open: %w", err) |
22 | 38 | }
|
| 39 | + mapModel := mapmodel.New(mapRoot, filename) |
| 40 | + mapView := mapview.New(app, mapModel, pal) |
| 41 | + defer mapView.Destroy() |
| 42 | + |
| 43 | + mapControl := mapcontrol.New(app, mapModel, mapView) |
| 44 | + app.Run(ctx, mapControl) |
23 | 45 |
|
24 |
| - app := application.NewApplication(mm) |
25 |
| - defer app.Close() |
26 |
| - app.Run() |
27 | 46 | return nil
|
28 | 47 | }
|
29 | 48 |
|
30 | 49 | func main() {
|
31 |
| - if err := run(); err != nil { |
| 50 | + if err := run(context.Background()); err != nil { |
32 | 51 | fmt.Println(err)
|
33 | 52 | }
|
34 | 53 | }
|
0 commit comments