-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakedriver.go
46 lines (39 loc) · 889 Bytes
/
fakedriver.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
package main
// FakeDriver is a ConsoleDriver that doesn't do anything.
type FakeDriver struct {
EventChan chan Event
width int
height int
CursorX int
CursorY int
Grid RuneGrid
}
func NewFakeDriver() FakeDriver {
fd := FakeDriver{
EventChan: make(chan Event),
}
fd.SetSize(80, 24)
return fd
}
func (fd *FakeDriver) SetSize(width, height int) {
fd.width = width
fd.height = height
fd.Grid = NewRuneGrid(fd.width, fd.height)
}
func (fd *FakeDriver) Init() {
}
func (fd *FakeDriver) Events() chan Event {
return fd.EventChan
}
func (fd *FakeDriver) Size() (width int, height int) {
return fd.Grid.Size()
}
func (fd *FakeDriver) Close() {}
func (fd *FakeDriver) SetCell(x, y int, r rune, fg Color, bg Color) {
fd.Grid.SetCell(x, y, r)
}
func (fd *FakeDriver) SetCursor(x, y int) {
fd.CursorX = x
fd.CursorY = y
}
func (fd *FakeDriver) AfterDraw() {}