aboutsummaryrefslogtreecommitdiff
path: root/console.go
blob: 9ca2a7078999a71ed737e5b3c6694e2baf4888b4 (plain)
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
package j1

import (
	"io"
	"os"
)

type Console struct {
	r io.Reader
	w io.Writer
}

func NewConsole() *Console {
	return &Console{
		r: os.Stdin,
		w: os.Stdout,
	}
}

func (c *Console) Read(p []byte) (int, error) {
	n, err := c.r.Read(p)
	if n > 0 && p[0] == 10 {
		p[0] = 13
	}
	return n, err
}

func (c *Console) Write(p []byte) (int, error) {
	return c.w.Write(p)
}