-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
55 lines (44 loc) · 953 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
51
52
53
54
55
package main
import (
"fmt"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/encoding"
)
func initScreen() error {
var err error
screen, err = tcell.NewScreen()
if err != nil {
return err
}
if err = screen.Init(); err != nil {
return err
}
encoding.Register()
tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
screen.SetStyle(tcell.StyleDefault)
screen.Clear()
screenWidth, screenHeight = screen.Size()
screen.Resize(0, 0, screenWidth, screenHeight)
return nil
}
func initEvent() {
go func() {
for {
if screen == nil {
break
}
Events <- screen.PollEvent()
}
}()
}
func initBuffer(path string) (*Buffer, error) {
buf := new(Buffer)
if err := buf.fileManage(path); err != nil {
return nil, err
}
line_len = len(fmt.Sprintf("%d", buf.getLine())) + 1
buf.Cursor = NewLocation(line_len, 0)
buf.HighlightBegine = NewLocation(-1, -1)
buf.HighlightEnd = NewLocation(-1, -1)
return buf, nil
}