-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttuy.go
72 lines (60 loc) · 1.22 KB
/
ttuy.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
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (c) 2023 Brandon Jordan
*/
package ttuy
import (
"fmt"
"github.com/olekukonko/ts"
)
const CSI = "\033["
var rows int
var cols int
const (
upArrow = "\u2191"
downArrow = "\u2193"
leftArrow = "\u2190"
rightArrow = "\u2192"
bullet = "\u2022"
upper = "\u203E"
lower = "_"
line = "|"
)
var dimensions map[int]int
type Row struct {
Columns []string
}
func terminalCols() {
size, _ := ts.GetSize()
cols = size.Col()
}
func terminalRows() {
size, _ := ts.GetSize()
rows = size.Row()
}
// Bell triggers the system bell which makes the machine make an alarm noise.
func Bell() {
fmt.Print("\a")
}
func checkEven(rows *[]Row) {
var evenColumns = len(combined[0].Columns)
for i, row := range *rows {
var rowColumns = len(row.Columns)
if rowColumns != evenColumns {
panic(fmt.Errorf("uneven columns! Row %d has %d columns when the rest have %d", i, rowColumns, evenColumns))
}
}
}
func calcDimensions(rows *[]Row) {
dimensions = make(map[int]int)
for _, row := range *rows {
for c, column := range row.Columns {
if length, ok := dimensions[c]; ok {
if len(column) > length {
dimensions[c] = len(column)
}
} else {
dimensions[c] = len(column)
}
}
}
}