Object built-in object

Object TTYOutputStream

ttywrite stream object, for processingttyoutput

There is no way to create the class alone, only the process.stdoutinstance

1 2
// 清除屏幕上光标以右的内容 process.stdout.clearLine(1)

inheritance relationship

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<class>Stream|fd|read();write();flush();close();copyTo()] [<this>TTYOutputStream|isTTY;columns;rows|clearLine();clearScreenDown();getWindowSize()] [object] <:- [Stream] [Stream] <:- [TTYOutputStream] Stream fd read() write() flush() close() copyTo() TTYOutputStream isTTY columns rows clearLine() clearScreenDown() getWindowSize() object toString() toJSON()

Member properties

isTTY

Boolean, always true

1
readonly Boolean TTYOutputStream.isTTY;

columns

Integer, returns the number of columns of the terminal corresponding to this TTYOutputStream

1
readonly Integer TTYOutputStream.columns;

rows

Integer, returns the line number of the terminal corresponding to this TTYOutputStream

1
readonly Integer TTYOutputStream.rows;

fd

Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses

1
readonly Integer TTYOutputStream.fd;

member function

clearLine

clear line according to the direction indicated by dir

1
TTYOutputStream.clearLine(Integer dir = 0);

Call parameters:

  • dir: Integer, clear direction

dir direction:

  • -1: clean up from the cursor to the beginning of the line
  • 0: clean up the entire line
  • 1: clean up from the cursor to the end of the line

clearScreenDown

Clear the characters from the cursor to the end of the screen

1
TTYOutputStream.clearScreenDown();

getWindowSize

Returns the size of the terminal corresponding to this TTYOutputStream

1
NArray TTYOutputStream.getWindowSize();

Return result:

  • NArray, returns an array [numColumns, numRows], where numColumns and numRows represent the number of columns and rows in the corresponding terminal

read

Read data of specified size from the stream

1
Buffer TTYOutputStream.read(Integer bytes = -1) async;

Call parameters:

  • bytes: Integer, specify the amount of data to be read, the default is to read a random size data block, the size of the data read depends on the device

Return result:

  • Buffer, returns the data read from the stream, or null if there is no data to read or the connection is interrupted

write

Write the given data to the stream

1
TTYOutputStream.write(Buffer data) async;

Call parameters:

  • data:Buffer, given the data to write

flush

Write file buffer contents to physical device

1
TTYOutputStream.flush() async;

close

closes the current stream object

1
TTYOutputStream.close() async;

copyTo

Copy stream data to target stream

1 2
Long TTYOutputStream.copyTo(Stream stm, Long bytes = -1) async;

Call parameters:

  • stm:Stream, the target stream object
  • bytes: Long, number of bytes copied

Return result:

  • Long, returns the number of bytes copied

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be reimplemented according to its own characteristics

1
String TTYOutputStream.toString();

Return result:

  • String, returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns the set of readable properties defined by the object

1
Value TTYOutputStream.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable