can exit while reading from keyboard
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
package input
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Input interface {
|
||||
Read() []Button
|
||||
Close()
|
||||
}
|
||||
|
||||
func New() Input {
|
||||
func New(ctx context.Context) Input {
|
||||
foo := randomCharFromRange('a', 'g')
|
||||
if p, ok := os.LookupEnv("INPUT_RANDOM_WEIGHT_FILE"); ok {
|
||||
foo = randomCharFromWeightFile(p)
|
||||
}
|
||||
var result Input = NewRandom(foo)
|
||||
if os.Getenv("INPUT_KEYBOARD") == "true" {
|
||||
result = NewKeyboard()
|
||||
}
|
||||
if os.Getenv("INPUT_BUFFERED") == "true" {
|
||||
result = NewBuffered(result)
|
||||
result = NewBuffered(ctx, result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user