Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion term_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows
//go:build !js && !wasip1 && !windows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we bump Go to 1.19 we can change this to:

Suggested change
//go:build !js && !wasip1 && !windows
//go:build unix


package term

Expand Down
56 changes: 56 additions & 0 deletions term_unsupported.go
Original file line number Diff line number Diff line change
@@ -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)
}
Comment on lines +50 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing *State value in return:

Suggested change
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)
}
func setRawTerminal(fd uintptr) (*State, error) {
return nil, fmt.Errorf("terminal: SetRawTerminal not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
}
func setRawTerminalOutput(uintptr) (*State, error) {
return nil, fmt.Errorf("terminal: SetRawTerminalOutput not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have a GHA build with GOOS=js and GOOS=wasm to make sure the module is buildable

3 changes: 1 addition & 2 deletions termios_nonbsd.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion termios_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows
//go:build !js && !wasip1 && !windows

package term

Expand Down
12 changes: 12 additions & 0 deletions termios_unsupported.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading