-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusLine.go
51 lines (42 loc) · 1.19 KB
/
statusLine.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
package buffers
import (
"fmt"
"github.com/gdamore/tcell/v2"
"github.com/soleimanim/gotype/screen"
"github.com/soleimanim/gotype/styles"
)
const STATUS_LINE_BUFFER_ID = 2
type StatusLineBuffer struct {
window *screen.Window
screen tcell.Screen
y int
Speed float32
Accuracy float32
}
func NewStatusLineBuffer() StatusLineBuffer {
return StatusLineBuffer{}
}
func (b StatusLineBuffer) Draw() {
screenWidth, _ := b.screen.Size()
logoText := " GoType "
startX := screenWidth/2 - len(logoText)/2
screen.DrawText(b.screen, logoText, &startX, &b.y, styles.TextLogoStyle)
startX = 0
speedText := fmt.Sprintf(" Speed: %.2f ", b.Speed)
screen.DrawText(b.screen, speedText, &startX, &b.y, styles.TextHighlightStyle1)
accText := fmt.Sprintf(" Accuracy: %.2f ", b.Accuracy)
startX = screenWidth - len(accText)
screen.DrawText(b.screen, accText, &startX, &b.y, styles.TextHighlightStyle2)
}
func (b StatusLineBuffer) GetID() int {
return STATUS_LINE_BUFFER_ID
}
func (b *StatusLineBuffer) SetScreen(s tcell.Screen) {
b.screen = s
}
func (statuslinebuffer StatusLineBuffer) HandleKeyEvent(_ *tcell.EventKey) {
return
}
func (b *StatusLineBuffer) SetWindow(w *screen.Window) {
b.window = w
}