diff options
Diffstat (limited to 'libgo/go/exp/terminal')
-rw-r--r-- | libgo/go/exp/terminal/shell.go | 11 | ||||
-rw-r--r-- | libgo/go/exp/terminal/shell_test.go | 14 | ||||
-rw-r--r-- | libgo/go/exp/terminal/terminal.go | 9 |
3 files changed, 16 insertions, 18 deletions
diff --git a/libgo/go/exp/terminal/shell.go b/libgo/go/exp/terminal/shell.go index e3f584774e3..5c5916755d6 100644 --- a/libgo/go/exp/terminal/shell.go +++ b/libgo/go/exp/terminal/shell.go @@ -4,10 +4,7 @@ package terminal -import ( - "os" - "io" -) +import "io" // Shell contains the state for running a VT100 terminal that is capable of // reading lines of input. @@ -306,12 +303,12 @@ func (ss *Shell) writeLine(line []byte) { } } -func (ss *Shell) Write(buf []byte) (n int, err os.Error) { +func (ss *Shell) Write(buf []byte) (n int, err error) { return ss.c.Write(buf) } // ReadLine returns a line of input from the terminal. -func (ss *Shell) ReadLine() (line string, err os.Error) { +func (ss *Shell) ReadLine() (line string, err error) { ss.writeLine([]byte(ss.prompt)) ss.c.Write(ss.outBuf) ss.outBuf = ss.outBuf[:0] @@ -337,7 +334,7 @@ func (ss *Shell) ReadLine() (line string, err os.Error) { break } if key == keyCtrlD { - return "", os.EOF + return "", io.EOF } line, lineOk = ss.handleKey(key) } diff --git a/libgo/go/exp/terminal/shell_test.go b/libgo/go/exp/terminal/shell_test.go index 2bbe4a4f8f9..8a76a85d5dc 100644 --- a/libgo/go/exp/terminal/shell_test.go +++ b/libgo/go/exp/terminal/shell_test.go @@ -5,8 +5,8 @@ package terminal import ( + "io" "testing" - "os" ) type MockTerminal struct { @@ -15,7 +15,7 @@ type MockTerminal struct { received []byte } -func (c *MockTerminal) Read(data []byte) (n int, err os.Error) { +func (c *MockTerminal) Read(data []byte) (n int, err error) { n = len(data) if n == 0 { return @@ -24,7 +24,7 @@ func (c *MockTerminal) Read(data []byte) (n int, err os.Error) { n = len(c.toSend) } if n == 0 { - return 0, os.EOF + return 0, io.EOF } if c.bytesPerRead > 0 && n > c.bytesPerRead { n = c.bytesPerRead @@ -34,7 +34,7 @@ func (c *MockTerminal) Read(data []byte) (n int, err os.Error) { return } -func (c *MockTerminal) Write(data []byte) (n int, err os.Error) { +func (c *MockTerminal) Write(data []byte) (n int, err error) { c.received = append(c.received, data...) return len(data), nil } @@ -46,7 +46,7 @@ func TestClose(t *testing.T) { if line != "" { t.Errorf("Expected empty line but got: %s", line) } - if err != os.EOF { + if err != io.EOF { t.Errorf("Error should have been EOF but got: %s", err) } } @@ -54,12 +54,12 @@ func TestClose(t *testing.T) { var keyPressTests = []struct { in string line string - err os.Error + err error }{ { "", "", - os.EOF, + io.EOF, }, { "\r", diff --git a/libgo/go/exp/terminal/terminal.go b/libgo/go/exp/terminal/terminal.go index 05a8990b041..5732543ffc2 100644 --- a/libgo/go/exp/terminal/terminal.go +++ b/libgo/go/exp/terminal/terminal.go @@ -15,6 +15,7 @@ package terminal import ( + "io" "os" "syscall" ) @@ -34,7 +35,7 @@ func IsTerminal(fd int) bool { // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. -func MakeRaw(fd int) (*State, os.Error) { +func MakeRaw(fd int) (*State, error) { var oldState State if e := syscall.Tcgetattr(fd, &oldState.termios); e != 0 { return nil, os.Errno(e) @@ -52,7 +53,7 @@ func MakeRaw(fd int) (*State, os.Error) { // Restore restores the terminal connected to the given file descriptor to a // previous state. -func Restore(fd int, state *State) os.Error { +func Restore(fd int, state *State) error { e := syscall.Tcsetattr(fd, syscall.TCSANOW, &state.termios) return os.Errno(e) } @@ -60,7 +61,7 @@ func Restore(fd int, state *State) os.Error { // ReadPassword reads a line of input from a terminal without local echo. This // is commonly used for inputting passwords and other sensitive data. The slice // returned does not include the \n. -func ReadPassword(fd int) ([]byte, os.Error) { +func ReadPassword(fd int) ([]byte, error) { var oldState syscall.Termios if e := syscall.Tcgetattr(fd, &oldState); e != 0 { return nil, os.Errno(e) @@ -85,7 +86,7 @@ func ReadPassword(fd int) ([]byte, os.Error) { } if n == 0 { if len(ret) == 0 { - return nil, os.EOF + return nil, io.EOF } break } |