Example of terminal control
This sample program demonstrates how to use the IccTerminal , IccTermId , and IccTerminalData classes.
This program, and
the expected output from it, can be found in
C++ sample programs
, as file
ICC$TRM.
#include "icceh.hpp"
#include "iccmain.hpp"
The first two lines include the header files for the Foundation
Classes and the standard
main
function that sets up the operating
environment for the application program.
void IccUserControl::run()
{
IccTerminal& term = *terminal();
term.erase();
The
run
method of
IccUserControl
class contains
the user code for this example. As a terminal is to be used, the
example
starts by creating a terminal object and clearing the associated screen.
term.sendLine( "First part of the line..." );
term.send( "... a continuation of the line." );
term.sendLine( "Start this on the next line" );
term.sendLine( 40, "Send this to column 40 of current line" );
term.send( 5, 10, "Send this to row 5, column 10" );
term.send( 6, 40, "Send this to row 6, column 40" );
This fragment shows how the
send
and
sendLine
methods
are used to send data to the terminal. All of these methods can take
IccBuf
references
(const IccBuf&) instead of string literals (const char*).
term.setNewLine();
This sends a blank line to the screen.
term.setColor( IccTerminal::red );
term.sendLine( "A Red line of text.");
term.setColor( IccTerminal::blue );
term.setHighlight( IccTerminal::reverse );
term.sendLine( "A Blue, Reverse video line of text.");
The
setColor
method is used to set the color of
the text on the screen and the
setHighlight
method to set the
highlighting.
term << "A cout sytle interface... " <<
endl;
term << "you can " << "chain input together; "
<< "use different types, eg numbers: " << (short)123 <<
" "
<< (long)4567890 << " " << (double)123456.7891234
<< endl;
term << "... and everything is buffered till you issue a flush."
<< flush;
This fragment shows how to use the iostream–like interface
endl
to
start data on the next line. To improve performance, you can buffer
data in the terminal until
flush
is issued, which sends the
data to the screen.
term.send( 24,1, "Program 'icc$trm' complete: Hit PF12
to End" );
term.waitForAID( IccTerminal::PF12 );
term.erase();
The
waitForAID
method causes the terminal to wait
until the specified key is hit, before calling the
erase
method
to clear the display.
return;
}
The end of run , which returns control to CICS®.