PresentationSpace

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.

Table 5-31 PresentationSpace

METHODS

getCursorPosition()

Returns a Position instance representing the current cursor position. An unconnected session has a cursor position of 0,0.

Returns

{Position} current cursor location

setCursorPosition(position)

Moves the host cursor to the specified row and column position. For some hosts, such as VT, the host may constrain the movements of the cursor.

Parameters

{Position} Position new cursor position.

Returns

None

Throws

{RangeError} If the position is not valid on the current screen.

isCursorVisible()

Tests that the cursor is currently visible in the presentation space. The cursor is considered not visible if the session is not connected.

Returns

{Boolean} True if the cursor is visible. False if the cursor is not visible.

sendKeys(keys)

Transmits a text string or ControlKey to the host at the current cursor position in the presentation space. If the cursor is not in the desired position, then use setCursorPosition function first.

The text string can contain any number of characters and ControlKey objects.

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

{String} keys text and/or control keys to transmit

getText(start,length)

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

Parameters

{Position} start position from which to retrieve text

{Number} length the maximum number of characters to return. If the length parameter causes the last position of the presentation space to be exceeded then only those characters up to the last position will be returned.

Returns

{String) representing a linear area of the presentation space which may be empty if the session is not connected.

Throws

{RangeError} If the position or length are not valid on the current screen.

getSize()

Gets the dimensions of the screen as a Dimension object.

Returns

{Dimension} Containing the number of rows and columns. The screen size is [row:0, col:0] if the session is not connected.

getDataCells(start, length)

Returns DataCell instances where the first member 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

{Position} start the first position on the host screen in which to retrieve DataCell instances. See Position.

{Number} length of the maximum number of DataCell instance to be retrieved. If not specified, returns DataCells from the start position to the end of the screen.

Returns

{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.

Throws

{RangeError} if start or length are out of range.

getFields()

Returns a list of the fields in the presentation space. If the host type does not support fields or the current screen is not formatted then the return value will always be an empty list. See FieldList.

Returns

{FieldList} of host defined fields in the presentation space.