2019-02-02 04:39:34 +00:00
|
|
|
package console
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2019-05-28 01:44:06 +00:00
|
|
|
"os"
|
2019-02-02 04:39:34 +00:00
|
|
|
"time"
|
2019-09-10 00:46:30 +00:00
|
|
|
|
|
|
|
ui "github.com/gizak/termui/v3"
|
2019-02-02 04:39:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2019-02-24 04:42:52 +00:00
|
|
|
MaxRenderInterval = 1000 * time.Millisecond
|
|
|
|
MinRenderInterval = 100 * time.Millisecond
|
2019-04-26 05:11:40 +00:00
|
|
|
ColumnsCount = 80
|
|
|
|
RowsCount = 40
|
2019-02-24 04:42:52 +00:00
|
|
|
AppTitle = "sampler"
|
2019-08-18 17:11:30 +00:00
|
|
|
AppVersion = "1.0.3"
|
2019-02-02 04:39:34 +00:00
|
|
|
)
|
|
|
|
|
2019-03-08 04:04:46 +00:00
|
|
|
const (
|
2019-03-16 04:35:00 +00:00
|
|
|
BellCharacter = "\a"
|
2019-03-08 04:04:46 +00:00
|
|
|
)
|
|
|
|
|
2019-03-16 04:35:00 +00:00
|
|
|
type AsciiFont string
|
2019-02-02 04:39:34 +00:00
|
|
|
|
2019-03-10 04:41:23 +00:00
|
|
|
const (
|
2019-04-25 00:48:16 +00:00
|
|
|
AsciiFont2D AsciiFont = "2d"
|
|
|
|
AsciiFont3D AsciiFont = "3d"
|
2019-03-10 04:41:23 +00:00
|
|
|
)
|
|
|
|
|
2019-03-16 04:35:00 +00:00
|
|
|
func Init() {
|
2019-02-02 04:39:34 +00:00
|
|
|
|
2019-02-24 04:42:52 +00:00
|
|
|
fmt.Printf("\033]0;%s\007", AppTitle)
|
2019-02-02 04:39:34 +00:00
|
|
|
|
|
|
|
if err := ui.Init(); err != nil {
|
2019-05-28 01:44:06 +00:00
|
|
|
log.Fatalf("Failed to initialize ui: %v", err)
|
2019-02-02 04:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-10 00:46:30 +00:00
|
|
|
// Close function calls Close from termui package,
|
|
|
|
// which closes termbox-go
|
2019-03-16 04:35:00 +00:00
|
|
|
func Close() {
|
2019-02-02 04:39:34 +00:00
|
|
|
ui.Close()
|
|
|
|
}
|
2019-05-28 01:44:06 +00:00
|
|
|
|
2019-09-10 00:46:30 +00:00
|
|
|
// Exit function exits the program successfully
|
2019-05-28 01:44:06 +00:00
|
|
|
func Exit(message string) {
|
|
|
|
if len(message) > 0 {
|
|
|
|
println(message)
|
|
|
|
}
|
|
|
|
os.Exit(0)
|
|
|
|
}
|