PresentationSpace

PresentationSpace

Represents the terminal display. Use the PresentationSpace object to interact with the terminal screen. Setting and getting the cursor position, sending keys, and reading text are some of the interactions available.

Mixes in EventEmitter for event listening.

Members

EventOrigin

Properties:
Name Type Description
EventOrigin.HOST String

Denotes a host-originated event.

EventOrign.USER String

Denotesa user-originated event.

SearchDirection

Properties:
Name Type Description
SearchDirection.FORWARD String

Denotes a forward direction

SearchDirection.BACKWARD String

Denots a backward direction

Methods

getFields() → {FieldList}

Returns a list of the fields in the presentation space. This doesn't return any fields from the back buffer. If the host type does not support fields or the current screen is unformatted then the return will always be an empty list.

Returns:
  • list of host defined fields in the presentation space
Type
FieldList

getDataCells(startopt, lengthopt) → {Array.<DataCell>}

Returns a list of DataCell instances where the first member of the list will be for the position specified by the start parameter. The maximum number of DataCell instances in the list is specified by the length parameter.

Parameters:
Name Type Attributes Description
start Position <optional>

the first position on the host screen in which to retrieve DataCell instances

length Number <optional>

the maximum number of DataCell instances to be retrieved. If not specified, returns DataCells from the start position to the end of the screen.

Throws:
  • if start or length are out of range
Type
RangeError
Returns:
  • Array of DataCell instances which may be empty if the session is not connected. If position is not specified, returns all DataCells. If length is not specified, returns DataCells from the start position to the end of the screen.
Type
Array.<DataCell>

getText(startopt, lengthopt) → {String}

Returns a string representing a linear area of the presentation space. No new line characters will be inserted if row boundaries are encountered.

Parameters:
Name Type Attributes Description
start Position <optional>

start position from which to retrieve text

length Number <optional>

the maximum number of characters to return

Throws:
  • if position or length are out of range
Type
RangeError
Returns:
  • a string representing a linear area of the presentation space which may be empty if the session is not connected
Type
String

getSize() → {Dimension}

Gets the screen dimensions in a Dimension object.

Returns:
  • a Dimensioncontaining the number of rows and columns. The screen size is {rows: 0, cols: 0} if the session is not connected.
Type
Dimension

isCursorVisible() → {Boolean}

Tests if the cursor is currently visible in the presentation space. A cursor is always considered not visible if the session is not connected.

Returns:
  • true if the cursor is visible; false otherwise
Type
Boolean

getCursorPosition() → {Position}

Returns a Position instance representing the current cursor position. Position instance with a negative number for row or column represent a cursor located in the back buffer. An unconnected session will have a cursor position of 0,0.

Returns:
  • the current cursor location.
Type
Position

setCursorPosition(position)

Moves the host cursor to the specified row and column position. For some emulations (notably VT), the host may constrain the movements of the cursor.

Parameters:
Name Type Description
position Position

the new cursor position.

sendKeys(keys)

Transmits a text string or ControlKeys to the host at the current cursor position in the presentation space. If the cursor is not in the desired position, then use the setCursorPosition function first. The text string can contain any number of characters and ControlKeys. For example: "myname" + ControlKey.TAB + "mypass" + ControlKey.ENTER will transmit a user ID, tab to the next field, transmit a password, and then transmit the Enter key. If you need to transmit a square bracket, double the brackets ([[ or ]]).

Parameters:
Name Type Description
keys String

text and/or ControlKeys to transmit

Events

Event.CONTENT_CHANGED

Fired when the PresentationSpace changes.

Parameters:
Name Type Description
event Object
Properties
Name Type Description
source PresentationSpace

The PresentationSpace that fired the event.

origin PresentationSpace#EventOrigin

Indicates if the event was host-originated or user-originated.

position Position

The location of the PresentationSpace change.

cells Array.<DataCell>

The individual DataCells that changed.

Event.CURSOR_CHANGED

Fired when the cursor position changes.

Parameters:
Name Type Description
event Object
Properties
Name Type Description
source PresentationSpace

The PresentationSpace that fired the event.

origin PresentationSpace#EventOrigin

Indicates if the event was host-originated or user-originated.

visible Boolean

Indicates if the cursor is visible.

position Position

The new cursor location.

Event.METRICS_CHANGED

Fired when the PresentationSpace dimensions change.

Parameters:
Name Type Description
event Object
Properties
Name Type Description
source PresentationSpace

The PresentationSpace that fired the event.

origin PresentationSpace#EventOrigin

Indicates if the event was host-originated or user-originated.

dimension Dimension

The new dimensions.

Event.ERROR

Fired when a PresentationSpace error occurs.

Parameters:
Name Type Description
event Object
Properties
Name Type Description
source PresentationSpace

The PresentationSpace that fired the event.

origin PresentationSpace#EventOrigin

Indicates if the event was host-originated or user-originated.

error Error

The error.