-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmode.go
45 lines (37 loc) · 771 Bytes
/
mode.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
package main
import "github.com/nsf/termbox-go"
type Mode int
const (
ModeFast Mode = iota
ModeSlow
ModeNormal
)
var modeInfo = []struct {
Name string
Desc string
Attr termbox.Attribute
}{{
Name: "fast",
Desc: "type as fast as you can, ignore mistakes",
Attr: termbox.ColorGreen | termbox.AttrBold,
}, {
Name: "slow",
Desc: "go slow, do not make any mistake",
Attr: termbox.ColorMagenta | termbox.AttrBold,
}, {
Name: "normal",
Desc: "type at normal speed, avoid mistakes",
Attr: termbox.ColorYellow | termbox.AttrBold,
}}
func (m Mode) Num() int {
return int(m)
}
func (m Mode) Name() string {
return modeInfo[m].Name
}
func (m Mode) Desc() string {
return modeInfo[m].Desc
}
func (m Mode) Attr() termbox.Attribute {
return modeInfo[m].Attr
}