dont do raw.New, instead add raw.Raw.Refresh explicit

master
bel 2023-03-25 10:17:36 -06:00
parent de261ae400
commit 2cae3c6d28
6 changed files with 14 additions and 1 deletions

View File

@ -22,6 +22,8 @@ func TestPlaintext(t *testing.T) {
type constSrc string
func (c constSrc) Refresh() {}
func (c constSrc) Close() {}
func (c constSrc) Read() []byte {

View File

@ -13,8 +13,9 @@ type Input interface {
}
func New(ctx context.Context) Input {
src := raw.New(ctx)
return wrap.New(ctx, func() button.Parser {
src := raw.New(ctx)
src.Refresh()
return button.New(ctx, src)
})
}

View File

@ -31,6 +31,9 @@ func NewKeyboard() Keyboard {
return Keyboard{}
}
func (kb Keyboard) Refresh() {
}
func (kb Keyboard) Close() {
switch runtime.GOOS {
case "linux":

View File

@ -22,6 +22,9 @@ func NewRandom(generator func() byte) *Random {
return &Random{generator: generator}
}
func (r *Random) Refresh() {
}
func (r *Random) Close() {
}

View File

@ -9,6 +9,7 @@ import (
type Raw interface {
Read() []byte
Close()
Refresh()
}
func New(ctx context.Context) Raw {

View File

@ -55,6 +55,9 @@ func (udp UDP) Read() []byte {
}
}
func (udp UDP) Refresh() {
}
func (udp UDP) Close() {
udp.conn.Close()
}