func NewTerminal(c io.ReadWriter, prompt string) *Terminal {
	return &Terminal{
		Escape:       &vt100EscapeCodes,
		c:            c,
		prompt:       []rune(prompt),
		termWidth:    80,
		termHeight:   24,
		echo:         true,
		historyIndex: -1,
	}
}
NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is
a local terminal, that terminal must first have been put into raw mode.
prompt is a string that is written at the start of each input line (i.e.
"> ").
package terminal
import (
	"bytes"
	"io"
	"sync"
	"unicode/utf8"
)
type EscapeCodes struct {
	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte
	Reset []byte
}
var vt100EscapeCodes = EscapeCodes{
	Black:   []byte{keyEscape, '[', '3', '0', 'm'},
	Red:     []byte{keyEscape, '[', '3', '1', 'm'},
	Green:   []byte{keyEscape, '[', '3', '2', 'm'},
	Yellow:  []byte{keyEscape, '[', '3', '3', 'm'},
	Blue:    []byte{keyEscape, '[', '3', '4', 'm'},
	Magenta: []byte{keyEscape, '[', '3', '5', 'm'},
	Cyan:    []byte{keyEscape, '[', '3', '6', 'm'},
	White:   []byte{keyEscape, '[', '3', '7', 'm'},
	Reset: []byte{keyEscape, '[', '0', 'm'},
}
type Terminal struct {
	AutoCompleteCallback func(line string, pos int, key rune) (newLine string, newPos int, ok bool)
	Escape *EscapeCodes
	lock sync.Mutex
	c      io.ReadWriter
	prompt []rune
	line []rune
	pos int
	echo bool
	pasteActive bool
	cursorX, cursorY int
	maxLine int
	termWidth, termHeight int
	outBuf []byte
	remainder []byte
	inBuf     [256]byte
	history stRingBuffer
	historyIndex int
	historyPending string
}