-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscreen.go
53 lines (47 loc) · 835 Bytes
/
screen.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 vaxis
type screen struct {
buf [][]Cell
rows int
cols int
}
func newScreen() *screen {
std := &screen{}
return std
}
func (s *screen) size() (cols int, rows int) {
return s.cols, s.rows
}
// resize resizes the stdsurface based on a SIGWINCH
func (s *screen) resize(cols int, rows int) {
s.buf = make([][]Cell, rows)
for row := range s.buf {
s.buf[row] = make([]Cell, cols)
}
s.rows = rows
s.cols = cols
}
// Set a cell at col, row
func (s *screen) setCell(col int, row int, text Cell) {
if col < 0 || row < 0 {
return
}
if col >= s.cols {
return
}
if row >= s.rows {
return
}
s.buf[row][col] = text
}
func (s *screen) setStyle(col int, row int, style Style) {
if col < 0 || row < 0 {
return
}
if col >= s.cols {
return
}
if row >= s.rows {
return
}
s.buf[row][col].Style = style
}