diff --git a/cwriter/util_wasm.go b/cwriter/util_wasm.go new file mode 100644 index 00000000..11dfb552 --- /dev/null +++ b/cwriter/util_wasm.go @@ -0,0 +1,6 @@ +//go:build wasm || js + +package cwriter + +// There is no ioctl on wasm, so we just use a dummy value. +const ioctlReadTermios = 0 diff --git a/cwriter/writer_posix.go b/cwriter/writer_posix.go index e80d757a..3b900156 100644 --- a/cwriter/writer_posix.go +++ b/cwriter/writer_posix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !windows && !js && !wasm package cwriter diff --git a/cwriter/writer_wasm.go b/cwriter/writer_wasm.go new file mode 100644 index 00000000..76bb8366 --- /dev/null +++ b/cwriter/writer_wasm.go @@ -0,0 +1,21 @@ +//go:build js || wasm + +package cwriter + +// We can not use writer in wasm, so we just use a dummy value. +type Writer struct { +} + +func (w *Writer) Flush(lines int) error { + return nil +} + +// GetSize returns the dimensions of the given terminal. +func GetSize(fd int) (width, height int, err error) { + return 0, 0, nil +} + +// IsTerminal returns whether the given file descriptor is a terminal. +func IsTerminal(fd int) bool { + return true +}