-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (41 loc) · 881 Bytes
/
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
package main
import (
"edit/editor"
"fmt"
"os"
)
func main() {
var config editor.EditorConfiguration
// for now i can only pass the filepath as an argument
for i := 1; i < len(os.Args); i++ {
arg := os.Args[i]
switch arg {
default:
config.OpenedFile = arg
}
}
editor, err := editor.New(config)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
err = editor.Load()
if err != nil {
editor.Close()
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer editor.Close()
for editor.ShouldNotQuit() {
ev := editor.PollEvent()
err = editor.HandleEvent(ev)
if err != nil {
editor.Quit()
}
editor.Render()
}
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}