forked from liamg/darktile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell.go
64 lines (50 loc) · 877 Bytes
/
cell.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
package buffer
import (
"image"
)
type Cell struct {
r rune
attr CellAttributes
image *image.RGBA
}
type CellAttributes struct {
FgColour [3]float32
BgColour [3]float32
Bold bool
Dim bool
Underline bool
Blink bool
Reverse bool
Hidden bool
}
func (cell *Cell) Image() *image.RGBA {
return cell.image
}
func (cell *Cell) SetImage(img *image.RGBA) {
cell.image = img
}
func (cell *Cell) Attr() CellAttributes {
return cell.attr
}
func (cell *Cell) Rune() rune {
return cell.r
}
func (cell *Cell) Fg() [3]float32 {
return cell.attr.FgColour
}
func (cell *Cell) Bg() [3]float32 {
return cell.attr.BgColour
}
func (cell *Cell) erase() {
cell.setRune(0)
}
func (cell *Cell) setRune(r rune) {
cell.r = r
}
func NewBackgroundCell(colour [3]float32) Cell {
return Cell{
attr: CellAttributes{
BgColour: colour,
},
}
}