diff --git a/term_unix.go b/term_unix.go index 251a04f..7ee5e0d 100644 --- a/term_unix.go +++ b/term_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !js && !wasip1 && !windows package term diff --git a/term_unsupported.go b/term_unsupported.go new file mode 100644 index 0000000..539064a --- /dev/null +++ b/term_unsupported.go @@ -0,0 +1,56 @@ +//go:build js || wasip1 + +package term + +import ( + "fmt" + "io" + "os" + "runtime" +) + +// terminalState holds the platform-specific state / console mode for the terminal. +type terminalState struct{} + +func stdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) { + return os.Stdin, os.Stdout, os.Stderr +} + +func getFdInfo(in any) (uintptr, bool) { + if file, ok := in.(*os.File); ok { + return file.Fd(), false + } + return 0, false +} + +func getWinsize(fd uintptr) (*Winsize, error) { + return nil, fmt.Errorf("terminal: GetWinsize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func setWinsize(fd uintptr, ws *Winsize) error { + return fmt.Errorf("terminal: SetWinsize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func isTerminal(fd uintptr) bool { + return false +} + +func restoreTerminal(fd uintptr, state *State) error { + return fmt.Errorf("terminal: RestoreTerminal not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func saveState(fd uintptr) (*State, error) { + return nil, fmt.Errorf("terminal: SaveState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func disableEcho(fd uintptr, state *State) error { + return fmt.Errorf("terminal: DisableEcho not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func setRawTerminal(fd uintptr) (*State, error) { + return fmt.Errorf("terminal: SetRawTerminal not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +func setRawTerminalOutput(uintptr) (*State, error) { + return fmt.Errorf("terminal: SetRawTerminalOutput not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} diff --git a/termios_nonbsd.go b/termios_nonbsd.go index 88b7b21..0a9e922 100644 --- a/termios_nonbsd.go +++ b/termios_nonbsd.go @@ -1,5 +1,4 @@ -//go:build !darwin && !freebsd && !netbsd && !openbsd && !windows -// +build !darwin,!freebsd,!netbsd,!openbsd,!windows +//go:build !darwin && !freebsd && !js && !netbsd && !openbsd && !wasip1 && !windows package term diff --git a/termios_unix.go b/termios_unix.go index a94eebb..c5c7252 100644 --- a/termios_unix.go +++ b/termios_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !js && !wasip1 && !windows package term diff --git a/termios_unsupported.go b/termios_unsupported.go new file mode 100644 index 0000000..5712224 --- /dev/null +++ b/termios_unsupported.go @@ -0,0 +1,12 @@ +//go:build js || wasip1 + +package term + +import ( + "fmt" + "runtime" +) + +func makeRaw(fd uintptr) (*State, error) { + return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +}