fallbackinput.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // +build !windows,!linux,!darwin,!openbsd,!freebsd,!netbsd
  2. package liner
  3. import (
  4. "bufio"
  5. "errors"
  6. "os"
  7. )
  8. // State represents an open terminal
  9. type State struct {
  10. commonState
  11. }
  12. // Prompt displays p, and then waits for user input. Prompt does not support
  13. // line editing on this operating system.
  14. func (s *State) Prompt(p string) (string, error) {
  15. return s.promptUnsupported(p)
  16. }
  17. // PasswordPrompt is not supported in this OS.
  18. func (s *State) PasswordPrompt(p string) (string, error) {
  19. return "", errors.New("liner: function not supported in this terminal")
  20. }
  21. // NewLiner initializes a new *State
  22. //
  23. // Note that this operating system uses a fallback mode without line
  24. // editing. Patches welcome.
  25. func NewLiner() *State {
  26. var s State
  27. s.r = bufio.NewReader(os.Stdin)
  28. return &s
  29. }
  30. // Close returns the terminal to its previous mode
  31. func (s *State) Close() error {
  32. return nil
  33. }
  34. // TerminalSupported returns false because line editing is not
  35. // supported on this platform.
  36. func TerminalSupported() bool {
  37. return false
  38. }
  39. type noopMode struct{}
  40. func (n noopMode) ApplyMode() error {
  41. return nil
  42. }
  43. // TerminalMode returns a noop InputModeSetter on this platform.
  44. func TerminalMode() (ModeApplier, error) {
  45. return noopMode{}, nil
  46. }
  47. const cursorColumn = true