-
-
Notifications
You must be signed in to change notification settings - Fork 596
/
Copy pathconsole.go
53 lines (42 loc) · 814 Bytes
/
console.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
package console
import (
"fmt"
"log"
"os"
"time"
ui "github.com/gizak/termui/v3"
)
const (
MaxRenderInterval = 1000 * time.Millisecond
MinRenderInterval = 100 * time.Millisecond
ColumnsCount = 80
RowsCount = 40
AppTitle = "sampler"
AppVersion = "1.1.0"
)
const (
BellCharacter = "\a"
)
type AsciiFont string
const (
AsciiFont2D AsciiFont = "2d"
AsciiFont3D AsciiFont = "3d"
)
func Init() {
fmt.Printf("\033]0;%s\007", AppTitle)
if err := ui.Init(); err != nil {
log.Fatalf("Failed to initialize ui: %v", err)
}
}
// Close function calls Close from termui package,
// which closes termbox-go
func Close() {
ui.Close()
}
// Exit function exits the program successfully
func Exit(message string) {
if len(message) > 0 {
println(message)
}
os.Exit(0)
}