kill TODO
Signed-off-by: mqliang <mqliang.zju@gmail.com>
This commit is contained in:
parent
442d9a021a
commit
a58bc8d2fe
1 changed files with 9 additions and 8 deletions
|
@ -14,6 +14,10 @@ import (
|
||||||
"github.com/Azure/go-ansiterm/winterm"
|
"github.com/Azure/go-ansiterm/winterm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
escapeSequence = ansiterm.KEY_ESC_CSI
|
||||||
|
)
|
||||||
|
|
||||||
// ansiReader wraps a standard input file (e.g., os.Stdin) providing ANSI sequence translation.
|
// ansiReader wraps a standard input file (e.g., os.Stdin) providing ANSI sequence translation.
|
||||||
type ansiReader struct {
|
type ansiReader struct {
|
||||||
file *os.File
|
file *os.File
|
||||||
|
@ -21,18 +25,15 @@ type ansiReader struct {
|
||||||
buffer []byte
|
buffer []byte
|
||||||
cbBuffer int
|
cbBuffer int
|
||||||
command []byte
|
command []byte
|
||||||
// TODO(azlinux): Remove this and hard-code the string -- it is not going to change
|
|
||||||
escapeSequence []byte
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAnsiReader(nFile int) *ansiReader {
|
func newAnsiReader(nFile int) *ansiReader {
|
||||||
file, fd := winterm.GetStdFile(nFile)
|
file, fd := winterm.GetStdFile(nFile)
|
||||||
return &ansiReader{
|
return &ansiReader{
|
||||||
file: file,
|
file: file,
|
||||||
fd: fd,
|
fd: fd,
|
||||||
command: make([]byte, 0, ansiterm.ANSI_MAX_CMD_LENGTH),
|
command: make([]byte, 0, ansiterm.ANSI_MAX_CMD_LENGTH),
|
||||||
escapeSequence: []byte(ansiterm.KEY_ESC_CSI),
|
buffer: make([]byte, 0),
|
||||||
buffer: make([]byte, 0),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ func (ar *ansiReader) Read(p []byte) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
keyBytes := translateKeyEvents(events, ar.escapeSequence)
|
keyBytes := translateKeyEvents(events, []byte(escapeSequence))
|
||||||
|
|
||||||
// Save excess bytes and right-size keyBytes
|
// Save excess bytes and right-size keyBytes
|
||||||
if len(keyBytes) > len(p) {
|
if len(keyBytes) > len(p) {
|
||||||
|
|
Loading…
Reference in a new issue