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