-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (51 loc) · 1.1 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"fmt"
"os"
"github.com/gdamore/tcell/v2"
)
// func HandleRender(events chan string, tScreen tcell.Screen, tb *TabBuffer) {
// for range events {
// Render(tScreen, tb)
// }
// }
func HandleRender(events chan string, screen *Screen) {
for range events {
Render(screen.tScreen, screen.tabBuffer)
}
}
func Render(tScreen tcell.Screen, tb *TabBuffer) {
tb.ClearTabArea()
x := 0
y := tb.GetUpperBound()
for _, line := range tb.GetValidLines(){
for _, char := range line.GetBufferWithoutGap() {
if char == '\n'{
tScreen.SetContent(x, y, char, nil, tcell.StyleDefault)
x = 0
y++
} else if char == '\t'{
x += 4
} else {
tScreen.SetContent(x, y, char, nil, tcell.StyleDefault)
x++
}
}
y++
x = 0
}
tScreen.Show()
}
func main() {
argv := os.Args
screen, err := NewScreen(argv)
screen.tabBuffer.WriteFileToScreen()
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
events := make(chan string)
go HandleRender(events, screen)
// go HandleRender(events, screen.tScreen, screen.tabBuffer)
HandleEvents(screen, events)
}