forked from ktr0731/go-fuzzyfinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcell.go
53 lines (42 loc) · 1.06 KB
/
tcell.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 fuzzyfinder
import (
"github.com/nsf/termbox-go"
)
// terminal is an abstraction for mocking termbox-go.
type terminal interface {
init() error
size() (width int, height int)
clear(termbox.Attribute, termbox.Attribute) error
setCell(x, y int, ch rune, fg, bg termbox.Attribute)
setCursor(x, y int)
pollEvent() termbox.Event
flush() error
close()
}
// termImpl is the implementation for termbox-go.
type termImpl struct{}
func (t *termImpl) init() error {
return termbox.Init()
}
func (t *termImpl) size() (width int, height int) {
return termbox.Size()
}
func (t *termImpl) clear(fg termbox.Attribute, bg termbox.Attribute) error {
termbox.Clear(fg, bg)
return nil
}
func (t *termImpl) setCell(x int, y int, ch rune, fg termbox.Attribute, bg termbox.Attribute) {
termbox.SetCell(x, y, ch, fg, bg)
}
func (t *termImpl) setCursor(x int, y int) {
termbox.SetCursor(x, y)
}
func (t *termImpl) pollEvent() termbox.Event {
return termbox.PollEvent()
}
func (t *termImpl) flush() error {
return termbox.Flush()
}
func (t *termImpl) close() {
termbox.Close()
}