aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-27 03:58:08 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-27 03:58:08 +0100
commit736fbaeaba9c57b2f624a42808fc524f306b1591 (patch)
tree26752dd8097c234ae956e70be92f9cb14003f795
parentd7c2fb9d4723464067d501d8e45fc7f9b0fc60fe (diff)
export rw
-rw-r--r--cmd/eval/main.go4
-rw-r--r--cmd/j1e/main.go4
-rw-r--r--console/console.go7
3 files changed, 9 insertions, 6 deletions
diff --git a/cmd/eval/main.go b/cmd/eval/main.go
index cd593a3..1e3635e 100644
--- a/cmd/eval/main.go
+++ b/cmd/eval/main.go
@@ -1,12 +1,14 @@
package main
import (
+ "os"
+
"dim13.org/j1"
"dim13.org/j1/console"
)
func main() {
- con := console.New()
+ con := console.New(os.Stdout, os.Stdin)
defer con.Stop()
vm := j1.New(con)
if err := vm.LoadFile("testdata/j1e.bin"); err != nil {
diff --git a/cmd/j1e/main.go b/cmd/j1e/main.go
index 934d416..586427e 100644
--- a/cmd/j1e/main.go
+++ b/cmd/j1e/main.go
@@ -3,12 +3,14 @@ package main
//go:generate file2go -in ../../testdata/j1e.bin
import (
+ "os"
+
"dim13.org/j1"
"dim13.org/j1/console"
)
func main() {
- con := console.New()
+ con := console.New(os.Stdout, os.Stdin)
defer con.Stop()
vm := j1.New(con)
vm.LoadBytes(J1eBin)
diff --git a/console/console.go b/console/console.go
index bbe366e..bfced03 100644
--- a/console/console.go
+++ b/console/console.go
@@ -3,7 +3,6 @@ package console
import (
"fmt"
"io"
- "os"
)
type Console struct {
@@ -11,14 +10,14 @@ type Console struct {
done chan struct{}
}
-func New() *Console {
+func New(w io.Writer, r io.Reader) *Console {
c := &Console{
ich: make(chan uint16, 1),
och: make(chan uint16, 1),
done: make(chan struct{}),
}
- go c.read(os.Stdin)
- go c.write(os.Stdout)
+ go c.write(w)
+ go c.read(r)
return c
}