-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.go
50 lines (41 loc) · 796 Bytes
/
init.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 (
"os"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/encoding"
)
func initScreen() {
var err error
screen, err = tcell.NewScreen()
fatalError(err)
err = screen.Init()
fatalError(err)
encoding.Register()
tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
screen.SetStyle(tcell.StyleDefault)
screen.Clear()
editorWidth, editorHeight = screen.Size()
}
func initTermEvents() {
go func() {
for {
if screen == nil {
break
}
termEvents <- screen.PollEvent()
}
}()
}
func initBuffers() {
for _, arg := range os.Args[1:] {
openBufferFromFile(arg)
}
if len(buffers) == 0 {
openBufferNamed("*scratch*")
}
}
func initViews() {
view := NewView(buffers[0])
rootViewTree = &ViewTree{Leaf: view}
currentViewTree = rootViewTree
}