5 "github.com/mattn/go-isatty"
9 "github.com/gdamore/tcell"
22 if _, err := os.Stat(filename); err == nil {
24 input, err = ioutil.ReadFile(filename)
31 } else if !isatty.IsTerminal(os.Stdin.Fd()) {
32 bytes, err := ioutil.ReadAll(os.Stdin)
34 fmt.Println("Error reading stdin")
40 s, e := tcell.NewScreen()
42 fmt.Fprintf(os.Stderr, "%v\n", e)
45 if e := s.Init(); e != nil {
46 fmt.Fprintf(os.Stderr, "%v\n", e)
50 defStyle := tcell.StyleDefault.
51 Background(tcell.ColorDefault).
52 Foreground(tcell.ColorDefault)
57 v := newView(newBuffer(string(input), filename), s)
59 // Initially everything needs to be drawn
68 } else if redraw == 1 {
74 event := s.PollEvent()
76 switch e := event.(type) {
78 if e.Key() == tcell.KeyCtrlQ {
84 redraw = v.handleEvent(event)