class PTerminal: public PScrollable

This class is an interactor that emulates a serial terminal.

Inheritance:


Public

[more] Construction
[more] Overrides from class PInteractor
[more] New functions for class

Protected Fields

[more]RowList rowData
List of Row objects that constitute the terminal screen and the scroll back buffer
[more]PINDEX maxSavedRows
Maximum number of lines to save in the scroll back buffer.
[more]PDIMENSION cellWidth
Width of a cell in the terminal screen in pixels.
[more]PDIMENSION cellHeight
Height of a cell in the terminal screen in pixels.
[more]PINDEX rows
Number of rows in the terminal screen.
[more]PINDEX columns
Number of columns in the terminal screen.
[more]PINDEX columnsVisible
Number of columns visible in the terminal screen.
[more]PINDEX rowsVisible
Number of rows visible in the terminal screen.
[more]PINDEX scrollTop
Position of the top of the scroll region.
[more]PINDEX scrollBottom
Position of the bottom of the scroll region.
[more]PINDEX cursorRow
Row of the current cursor position.
[more]PINDEX cursorColumn
Column of the current cursor position.
[more]Attribute attribute
Current attribute for new characters in terminal.
[more]BOOL variableRowColumns
The variable row/columns flag for the terminal.
[more]BOOL blockCursor
The block cursor flag for the terminal.
[more]BOOL wrapEOL
The wrap at end of line flag for the terminal.
[more]BOOL lineFeedOnReturn
The output line feed on return flag for the terminal.
[more]BOOL returnOnLineFeed
The output return on line feed flag for the terminal.
[more]BOOL localEcho
The local echo flag for the terminal.
[more]ostream* keyboard
The stream to which data received by the terminals emulation of the keyboard is sent
[more]PINDEX updateColumn
Column for start of delayed screen output text.
[more]PINDEX anchor
Starting position and current position for mouse selection of text in the terminal window
[more]BOOL columnModeSelection
Indicate that the selection is in columns, not whole lines.

Protected

[more] Overrides from class PInteractor
[more] New functions for class


Inherited from PScrollable:

Public Fields

oPRect scrollRange

Public Methods

ovirtual PRect GetDrawingBounds( CoordinateSystem coords ) const
ovoid SetScrollRange( const PRect & rect )
oPRect GetScrollRange() const
ovoid SetScaleFactor( PORDINATE x, PORDINATE y )
oPPoint GetScaleFactor() const
oPPoint GetOrigin() const
ovoid ScrollTo( PORDINATE x, PORDINATE y )
ovoid ScrollBy( PORDINATE dx, PORDINATE dy )
ovirtual void OnScroll( const PPoint & delta )

Public

System callback functions.

Protected Fields

oPPoint scaleFactor
oPPoint origin

Protected

Member variables


Inherited from PInteractor:

Public Classes

oenum PositionOrigin
oenum CoordinateSystem
oenum AutoAdjustType

Public Fields

oPCursor cursor

Public Methods

ovirtual Comparison Compare( const PObject & obj ) const
oPInteractor* GetParent() const
oBOOL IsChild( PInteractor * parent ) const
oPINDEX GetNumChildren()
oPInteractor& operator[]( PINDEX index )
ovirtual void UpdateCommandSources()
ovirtual void SetFont( const PFont & newFont, BOOL toChildren = TRUE )
oconst PRealFont& GetFont()
oPDIMENSION ToPixelsDX( PDIMENSION x ) const
oPDIMENSION ToPixelsDY( PDIMENSION y ) const
oPORDINATE ToPixelsX( PORDINATE x ) const
oPORDINATE ToPixelsY( PORDINATE y ) const
oPDim ToPixels( const PDim & dim ) const
oPPoint ToPixels( const PPoint & pt ) const
oPRect ToPixels( const PRect & r ) const
oPDIMENSION FromPixelsDX( PDIMENSION x ) const
oPDIMENSION FromPixelsDY( PDIMENSION y ) const
oPORDINATE FromPixelsX( PORDINATE x ) const
oPORDINATE FromPixelsY( PORDINATE y ) const
oPDim FromPixels( const PDim & dim ) const
oPPoint FromPixels( const PPoint & pt ) const
oPRect FromPixels( const PRect & r ) const
ovoid SetPosition( PORDINATE x, PORDINATE y, PositionOrigin xOrigin = TopLeftParent, PositionOrigin yOrigin = TopLeftParent )
oPPoint GetPosition( CoordinateSystem coords ) const
oPPoint ToScreen( PORDINATE x, PORDINATE y, CoordinateSystem coords ) const
oPPoint FromScreen( PORDINATE x, PORDINATE y, CoordinateSystem coords ) const
ovoid SetDimensions( PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
oPDim GetDimensions( CoordinateSystem coords ) const
oPRect GetStructureBounds( CoordinateSystem coords ) const
ovoid AutoAdjustBounds( PRect & bounds, AutoAdjustType type = AdjustBounds )
oBOOL ContainsPoint( const PPoint & pt, CoordinateSystem coords ) const
oPInteractor* FindInteractor( const PPoint & pt, CoordinateSystem coords ) const
ovirtual void Enable( BOOL enabled = TRUE )
ovoid Disable()
oBOOL IsEnabled() const
ovirtual void ShowAll()
ovirtual void Show( BOOL visible = TRUE )
ovoid Hide()
oBOOL IsVisible() const
ovirtual void BringToTop()
ovirtual BOOL IsOnTop() const
ovoid Invalidate( PORDINATE x, PORDINATE y, PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
ovoid Validate( PORDINATE x, PORDINATE y, PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
ovoid Update()
ovoid GrabMouse()
ovoid ReleaseMouse()
oBOOL HasMouse() const
ovoid GrabFocus()
oBOOL HasFocus() const
ovirtual void SetCursor( const PCursor & newCursor )
oPCursor GetCursor() const
ovoid SetCursorToParent( BOOL useParent = TRUE )
ovoid SetAllCursors( const PCursor & newCursor )
ovoid RestoreAllCursors()
ovoid SetWaitCursor()
ovoid SetCursorPos( PORDINATE x, PORDINATE y, CoordinateSystem coords )
oPPoint GetCursorPos( CoordinateSystem coords ) const
ovirtual void ShowCursor( BOOL show = TRUE )
ovoid HideCursor()
ovoid SetCaret( const PCaret & newCaret )
oPCaret GetCaret() const
ovoid SetCaretPos( PORDINATE x, PORDINATE y, CoordinateSystem coords )
oPPoint GetCaretPos( CoordinateSystem coords ) const
ovirtual void ShowCaret(BOOL show = TRUE)
ovoid HideCaret()
ovirtual void SetForegroundColour( const PColour & newColour )
oconst PColour& GetForegroundColour() const
ovirtual void SetBackgroundColour( const PColour & newColour )
oconst PColour& GetBackgroundColour() const
oPDim GetBorderSize() const
oconst PColour& GetBorderColour() const
oPCanvas* StartMouseTrack( BOOL wantsCanvas = FALSE )
ovirtual void OnMouseMove( PKeyCode button, const PPoint & where )
ovirtual void OnMouseDown( PKeyCode button, const PPoint & where, BOOL doubleClick )
ovirtual void OnMouseUp( PKeyCode button, const PPoint & where )
ovirtual BOOL OnKeyDown( PKeyCode key, unsigned repeat )
ovirtual void OnKeyUp( PKeyCode key )
ovirtual void OnKeyInput( const PString & str )
ovirtual void OnGainFocus()
ovirtual void OnLostFocus()
ovirtual void OnStartInput()
ovirtual BOOL OnEndInput()
ovirtual void OnRedraw( PCanvas & canvas )
ovirtual void OnControlNotify( PControl & control, int option )
ovirtual void OnSelectHelp()
ovirtual PBalloon* OnBalloonHelp()
ovirtual void OnMouseTrack( PCanvas * canvas, const PPoint & where, BOOL lastTrack )
ovirtual void _SetPosition( PORDINATE x, PORDINATE y, PositionOrigin xOrigin, PositionOrigin yOrigin )

Public

Overrides from class PObject

Protected Fields

oPApplication* owner
oPInteractor* parent
oPInteractorList children
oPRealFont font
oPCursor savedCursor
oPCaret caret
oPPoint caretPosition
oint caretVisible
oPColour foregroundColour
oPColour backgroundColour
oPInteractor* mouseTrackInteractor
oPInteractorCanvas* mouseTrackCanvas

Protected Methods

ovirtual void _SetDimensions( PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
ovirtual void _Invalidate( PORDINATE x, PORDINATE y, PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
ovirtual void _Validate( PORDINATE x, PORDINATE y, PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
ovirtual void _SetCursorPos( PORDINATE x, PORDINATE y, CoordinateSystem coords )
ovirtual void _SetCaretPos( PORDINATE x, PORDINATE y, CoordinateSystem coords )
ovirtual void SetFocusInteractor( PInteractor * interactor )
ovirtual PInteractor* GetFocusInteractor() const
ovirtual void UpdateMyCommandSources()

Protected

o Flag to indicate that the parent interactor layouts cursor should be used with this interactor.


Documentation

This class is an interactor that emulates a serial terminal. This is an abstract class that has specific terminal emulators descended from it eg the \ref{PAnsiTerminal} class.

A descendent class should implement the \ref{Write()} function or \ref{ProcessCharacter()} function to output characters to the terminal lines implemented by PTerminal. The descendent may also wish to implement the \ref{PInteractor::OnKeyDown()} and \ref{Reset()} functions for any special keys supported by the terminal or initialisation required when the terminal is reset.

o Construction

o PTerminal( PScroller * parent, ostream * kbd = NULL )
Create a terminal interactor, contained within a scroller window. This always creates a Reset() terminal.
Parameters:
parent - \ref{PScroller} class that the terminal class interactor must be placed in. The PScroller contains the scroll bars etc and communicates with the \ref{PScrollable} to do scrolling functions.
kbd - Stream to send all keyboard input and other output, eg cursor position generated by the PTerminal.

o Overrides from class PInteractor

ovirtual void SetFont( const PFont & newFont, BOOL toChildren = TRUE )
Set the font to be used by default by this interactor. A canvas created on this interactor will initially have this font selected.

This also determines the coordinate system to be used for laying out child interactors via the \ref{SetPosition()} and \ref{SetDimensions()} functions. The coordinates used are 1/4 average font width and 1/8 the font height.

If the toChildren parameter is TRUE then the font is propagated down to all child interactors and grandchild interactors etc.

Parameters:
newFont - New font specification fo rthe interactor.
toChildren - Flag to recursively change all child interactors.

o New functions for class

ovirtual void Reset()
Reset the terminal. This clears the terminal virtual screen, wipes the scoll back buffer, resets internal terminal options (eg wrap at end of line) to default states and clears any modes the terminal is in.

ovirtual void Write( const char * buf, PINDEX len )
Write characters to the terminal. This must be defined by the descendent class of the PTerminal. It should do all interpretation of the input data stream for the terminal protocol. This usually involves a state machine of some description.
Parameters:
buf - Pointer to the buffer of characters to place onto the terminal.
len - Length of the buffer of characters.

ovoid Write( const PString & str )
Write a string to the terminal. This executes the Write() function that takes a buffer pointer and length.
Parameters:
str - String to write to the terminal.

ovirtual BOOL HasSelection() const
Determine if there is a selection active in the terminal.

Returns:
TRUE if there is a selection active, FALSE if no selection has been made.

ovirtual PString GetSelection() const
Get the lines of text that was selected in the terminal window.

Returns:
A string containing the lines of text in the selected region. The line separators are always \n.

ovirtual void SetSelection( PINDEX startRow, PINDEX startColumn, PINDEX finishRow, PINDEX finishColumn )
Set the selected lines in the terminal window.
Parameters:
startRow - Starting row of the selected block
startColumn - Starting column of the selected block
finishRow - Finishing row of the selected block
finishColumn - Finishing column of the selected block

ovoid SetKeyboardStream( ostream * out )
Set the output stream to receive all keyboard input or protocol responses from terminal emulation.
Parameters:
out - Stream to output keyboard data entered into the terminal emulator.

oPString GetRow(PINDEX idx) const
Get the text in the specified row. The trailing blanks are trimmed but leading blanks are included.

Returns:
String for the terminal row text.

oPINDEX GetTotalRows() const
Get the maximum number of rows that are saved "scroll back" buffer of the terminal.

Returns:
Max number of rows in the buffer.

oPINDEX GetMaxSavedRows() const
Get the maximum number of rows that are saved "scroll back" buffer of the terminal.

Returns:
Max number of rows in the buffer.

ovoid SetMaxSavedRows( PINDEX newRows )
Set the number of rows in the terminal. This will resize the interactor to fit the specified number of rows.
Parameters:
newRows - New number of rows

oPINDEX GetRows() const
Get the number of rows in terminal.

Returns:
Number of rows visible in the window

oPINDEX GetColumns() const
Get the number of columns in terminal.

Returns:
Number of columns visible in the window

ovoid SetColumns( PINDEX newColumns )
Set the number of columns in the terminal. This will resize the interactor to fit the specified number of rows.
Parameters:
newColumns - New number of columns

oBOOL GetVariableRowColumns() const
Get the variable row/columns flag for the terminal. This flag controls if the rows/columns of the terminal emulator are fixed or change whenever the size of the interactor changes.

Returns:
Current value of the flag.

ovoid SetVariableRowColumns( BOOL b )
Set the variable row/columns flag for the terminal. This flag controls if the rows/columns of the terminal emulator are fixed or change whenever the size of the interactor changes.
Parameters:
b - New value of the flag

oBOOL GetBlockCursor() const
Get the block cursor flag for the terminal. This flag controls if the cursor (caret) of the terminal emulator is a full block or a single horizontal line.

Returns:
Current value of the flag.

ovoid SetBlockCursor( BOOL b )
Set the block cursor flag for the terminal. This flag controls if the cursor (caret) of the terminal emulator is a full block or a single horizontal line.
Parameters:
b - New value of the flag

oBOOL GetWrapEOL() const
Get the wrap at end of line flag for the terminal. This flag controls if the terminal emulator wraps around if text is output when the cursor is at the end of the line.

Returns:
Current value of the flag.

ovoid SetWrapEOL( BOOL b )
Set the wrap at end of line flag for the terminal. This flag controls if the terminal emulator wraps around if text is output when the cursor is at the end of the line.
Parameters:
b - New value of the flag

oBOOL GetLineFeedOnReturn() const
Get the output line feed on return flag for the terminal. This flag controls if the terminal emulator does a line feed every time a carriage return is received.

Returns:
Current value of the flag.

ovoid SetLineFeedOnReturn( BOOL b )
Set the output return on line feed flag for the terminal. This flag controls if the terminal emulator does a line feed every time a carriage return is received.
Parameters:
b - New value of the flag

oBOOL GetReturnOnLineFeed() const
Get the output return on line feed flag for the terminal. This flag controls if the terminal emulator does a carriage return every time a line feed is received.

Returns:
Current value of the flag.

ovoid SetReturnOnLineFeed( BOOL b )
Set the output return on line feed flag for the terminal. This flag controls if the terminal emulator does a carriage return every time a line feed is received.
Parameters:
b - New value of the flag

oBOOL GetLocalEcho() const
Get the local echo flag for the terminal. This flag controls if the terminal emulator displays every character typed within it into its own input stream.

Returns:
Current value of the flag.

ovoid SetLocalEcho( BOOL b )
Set the local echo flag for the terminal. This flag controls if the terminal emulator displays every character typed within it into its own input stream.
Parameters:
b - New value of the flag

o Overrides from class PInteractor

ovirtual void _SetDimensions( PDIMENSION width, PDIMENSION height, CoordinateSystem coords )
Set the dimensions of the interactor. The new size is specified in layout coordinates. The user may override this function if checks for maximum or minimum size are required. Note that this sets the dimension of the interior of the interactor, excluding any external decoration (eg title bars).
Parameters:
width - New width of interactor
height - New height of interactor
coords - Coordinate system to use.

ovirtual void OnMouseDown( PKeyCode button, const PPoint & where, BOOL doubleClick )
The system calls this whenever a mouse button is depressed in the interactors drawable area (ie not in title bars etc).
Parameters:
button - Key code that specifies which mouse button and which modifiers (shift, control etc) were active at the time.
where - The position of the mouse pointer provided in pixels with its origin at the top left of the interactor.
doubleClick - Is TRUE if the mouse down is the second click of a double click.

ovirtual void OnMouseTrack( PCanvas * canvas, const PPoint & where, BOOL lastTrack )
This function is called whenever a drag track is in progress. This is begun with a call to the \ref{StartMouseTrack()} function, which is typically called from within the \ref{OnMouseDown()} function.

The lastTrack parameter can be used to for special action at the end of the track operation.

The mouse pointer is automatically grabbed (via \ref{GrabMouse()}) and released (via \ref{ReleaseMouse()}). The canvas provided is also automatically created and deleted.

Parameters:
canvas - The canvas available while the drag operation is tracking.
where - The position of the mouse pointer provided in pixels with its origin at the top left of the interactor.
lastTrack - This is TRUE if the position is the last track of the drag operation.

ovirtual void OnKeyInput( const PString & str )
The system calls this whenever a keyboard key was pressed and this interactor had the focus. The string is the translated ANSI representation of the key combination.
Parameters:
str - Translated key code.

ovirtual void OnRedraw( PCanvas & canvas )
The system calls this whenever it requires that the interactors drawable area needs to be updated and redrawn.
Parameters:
canvas - Canvas for drawing into the interactor

o New functions for class

oRowList rowData
List of Row objects that constitute the terminal screen and the scroll back buffer

oPINDEX maxSavedRows
Maximum number of lines to save in the scroll back buffer.

oPDIMENSION cellWidth
Width of a cell in the terminal screen in pixels.

oPDIMENSION cellHeight
Height of a cell in the terminal screen in pixels.

oPINDEX rows
Number of rows in the terminal screen.

oPINDEX columns
Number of columns in the terminal screen.

oPINDEX columnsVisible
Number of columns visible in the terminal screen.

oPINDEX rowsVisible
Number of rows visible in the terminal screen.

oPINDEX scrollTop
Position of the top of the scroll region.

oPINDEX scrollBottom
Position of the bottom of the scroll region.

oPINDEX cursorRow
Row of the current cursor position.

oPINDEX cursorColumn
Column of the current cursor position.

oAttribute attribute
Current attribute for new characters in terminal.

oBOOL variableRowColumns
The variable row/columns flag for the terminal. This flag controls if the rows/columns of the terminal emulator are fixed or change whenever the size of the interactor changes.

oBOOL blockCursor
The block cursor flag for the terminal. This flag controls if the cursor (caret) of the terminal emulator is a full block or a single horizontal line.

oBOOL wrapEOL
The wrap at end of line flag for the terminal. This flag controls if the terminal emulator wraps around if text is output when the cursor is at the end of the line.

oBOOL lineFeedOnReturn
The output line feed on return flag for the terminal. This flag controls if the terminal emulator does a line feed every time a carriage return is received.

oBOOL returnOnLineFeed
The output return on line feed flag for the terminal. This flag controls if the terminal emulator does a carriage return every time a line feed is received.

oBOOL localEcho
The local echo flag for the terminal. This flag controls if the terminal emulator displays every character typed within it into its own input stream.

oostream* keyboard
The stream to which data received by the terminals emulation of the keyboard is sent

oPINDEX updateColumn
Column for start of delayed screen output text. Characters may be output into internal structures but not displayed in the interactor until later. This algorithm is designed to improve performance by avoiding outputing each individual character through the display canvas.

oPINDEX anchor
Starting position and current position for mouse selection of text in the terminal window

oBOOL columnModeSelection
Indicate that the selection is in columns, not whole lines.


Direct child classes:
PAnsiTerminal

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.