util_plan9.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package terminal provides support functions for dealing with terminals, as
  5. // commonly found on UNIX systems.
  6. //
  7. // Putting a terminal into raw mode is the most common requirement:
  8. //
  9. // oldState, err := terminal.MakeRaw(0)
  10. // if err != nil {
  11. // panic(err)
  12. // }
  13. // defer terminal.Restore(0, oldState)
  14. package terminal
  15. import (
  16. "fmt"
  17. "runtime"
  18. )
  19. type State struct{}
  20. // IsTerminal returns true if the given file descriptor is a terminal.
  21. func IsTerminal(fd int) bool {
  22. return false
  23. }
  24. // MakeRaw put the terminal connected to the given file descriptor into raw
  25. // mode and returns the previous state of the terminal so that it can be
  26. // restored.
  27. func MakeRaw(fd int) (*State, error) {
  28. return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
  29. }
  30. // GetState returns the current state of a terminal which may be useful to
  31. // restore the terminal after a signal.
  32. func GetState(fd int) (*State, error) {
  33. return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
  34. }
  35. // Restore restores the terminal connected to the given file descriptor to a
  36. // previous state.
  37. func Restore(fd int, state *State) error {
  38. return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
  39. }
  40. // GetSize returns the dimensions of the given terminal.
  41. func GetSize(fd int) (width, height int, err error) {
  42. return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
  43. }
  44. // ReadPassword reads a line of input from a terminal without local echo. This
  45. // is commonly used for inputting passwords and other sensitive data. The slice
  46. // returned does not include the \n.
  47. func ReadPassword(fd int) ([]byte, error) {
  48. return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
  49. }