diff --git a/.node-version b/.node-version index 279c9de7e..d29e02ea4 100644 --- a/.node-version +++ b/.node-version @@ -1 +1,2 @@ v12.10.0 +v12.10.0 diff --git a/README.md b/README.md index 3745d451f..e8f400ed4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ The following core Node.js modules (v8.7.0+) have been implemented: | [stream](https://nodejs.org/api/stream.html) | :heavy_check_mark: | | [string-decoder](https://nodejs.org/api/string_decoder.html) | :heavy_check_mark: | | [timers](https://nodejs.org/api/timers.html) | :heavy_check_mark: | -| [tty](https://nodejs.org/api/tty.html) | | +| [tty](https://nodejs.org/api/tty.html) | :heavy_check_mark: | | [url](https://nodejs.org/api/url.html) | :heavy_check_mark: | | [util](https://nodejs.org/api/util.html) | :heavy_check_mark: | | [vm](https://nodejs.org/api/vm.html) | | diff --git a/app/current/src/main/scala/io/scalajs/nodejs/tty/ReadStream.scala b/app/current/src/main/scala/io/scalajs/nodejs/tty/ReadStream.scala index 0a59510e1..dc37e8b23 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/tty/ReadStream.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/tty/ReadStream.scala @@ -1,8 +1,7 @@ package io.scalajs.nodejs.tty -import io.scalajs.RawOptions import io.scalajs.nodejs.FileDescriptor -import io.scalajs.nodejs.net.Socket +import io.scalajs.nodejs.net import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -15,7 +14,7 @@ import scala.scalajs.js.annotation.JSImport */ @js.native @JSImport("tty", "ReadStream") -class ReadStream(fd: FileDescriptor, options: RawOptions = js.native) extends Socket { +class ReadStream(fd: FileDescriptor) extends net.Socket { ///////////////////////////////////////////////////////////////////////////////// // Properties @@ -25,7 +24,7 @@ class ReadStream(fd: FileDescriptor, options: RawOptions = js.native) extends So * A boolean that is true if the TTY is currently configured to operate as a raw device. Defaults to false. * @since 0.7.7 */ - var isRaw: Boolean = js.native + def isRaw: Boolean = js.native /** * Indicates whether the stream is a TTY diff --git a/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala b/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala index d3b95c69a..3e108d780 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala @@ -1,7 +1,8 @@ package io.scalajs.nodejs.tty +import com.thoughtworks.enableIf import io.scalajs.nodejs.FileDescriptor -import io.scalajs.nodejs.net.Socket +import io.scalajs.nodejs.net import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -15,11 +16,7 @@ import scala.scalajs.js.annotation.JSImport */ @js.native @JSImport("tty", "WriteStream") -class WriteStream(fd: FileDescriptor) extends Socket { - - ///////////////////////////////////////////////////////////////////////////////// - // Properties - ///////////////////////////////////////////////////////////////////////////////// +class WriteStream(fd: FileDescriptor) extends net.Socket { /** * A number specifying the number of columns the TTY currently has. This property is updated whenever @@ -29,6 +26,31 @@ class WriteStream(fd: FileDescriptor) extends Socket { */ def columns: Int = js.native + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs12) + def clearLine(dir: Int, callback: js.Function): Boolean = js.native + // TODO: Return value should be boolean when dropping Node.js v10 + def clearLine(dir: Int): Unit = js.native + + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs12) + def clearScreenDown(callback: js.Function): Boolean = js.native + // TODO: Return value should be boolean when dropping Node.js v10 + def clearScreenDown(): Unit = js.native + + // TODO: Return value should be boolean when dropping Node.js v10 + def cursorTo(x: Int): Unit = js.native + // TODO: Return value should be boolean when dropping Node.js v10 + def cursorTo(x: Int, y: Int): Unit = js.native + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs12) + def cursorTo(x: Int, y: Int, callback: js.Function): Boolean = js.native + + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs10) + def getColorDepth(env: io.scalajs.nodejs.process.Environment = js.native): Int = js.native + + def getWindowSize(): js.Tuple2[Int, Int] = js.native + + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs12) + def hasColors(count: Int = js.native, env: io.scalajs.nodejs.process.Environment = js.native): Boolean = js.native + /** * Indicates whether the stream is a TTY */ @@ -42,4 +64,9 @@ class WriteStream(fd: FileDescriptor) extends Socket { */ def rows: Int = js.native + // TODO: Return value should be boolean when dropping Node.js v10 + def moveCursor(dx: Int, dy: Int): Unit = js.native + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs12) + def moveCursor(dx: Int, dy: Int, callback: js.Function): Boolean = js.native + }