aboutsummaryrefslogtreecommitdiff
path: root/poe.go
blob: e7fff733b642864454f0cdba131769ec11a4b055 (plain)
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
package main

import (
	"flag"
	"fmt"
	"os"
	"runtime"

	"github.com/prodhe/poe/editor"
	"github.com/prodhe/poe/ui"
)

func main() {
	flag.Parse()

	e := editor.New()

	e.LoadBuffers(flag.Args())

	ui := ui.NewTcell()
	//ui := ui.NewCli()
	ui.Init(e)

	// close ui and show stack trace on panic
	defer func() {
		ui.Close()

		if err := recover(); err != nil {
			buf := make([]byte, 1<<16)
			n := runtime.Stack(buf, true)
			fmt.Println("poe error:", err)
			fmt.Printf("%s", buf[:n+1])
			os.Exit(1)
		}
	}()

	// This will loop and listen on chosen UI.
	ui.Listen()
}