libcommonc++  0.7
Console Class Reference

A class that provides basic control of the console, such as changing text attributes, clearing the screen, and moving the cursor. More...

#include <Console.h++>

Public Types

enum  TextColor {
  ColorBlack, ColorRed, ColorGreen, ColorYellow,
  ColorBlue, ColorMagenta, ColorCyan, ColorWhite
}
 Text colors. More...
 
enum  TextStyle { StyleBold, StyleUnderline, StyleInverse }
 Text styles. More...
 

Public Member Functions

 Console ()
 Construct a new Console object. More...
 
 ~Console ()
 Destructor. More...
 
size_t read (char *text, size_t maxlen)
 Read text from the console. More...
 
void write (const char *text, size_t len=0)
 Write text to the console. More...
 
bool setEcho (bool on)
 Enable or disable the echoing of input characters on the console. More...
 
void moveCursor (uint_t row, uint_t column)
 Move the cursor to a new position. More...
 
void clear ()
 Clear the console. More...
 
void setTextForeground (TextColor color)
 Set the foreground color for subsequent text. More...
 
void setTextBackground (TextColor color)
 Set the background color for subsequent text. More...
 
void beginTextStyle (TextStyle style)
 Turn on a text style for subsequent text. More...
 
void endTextStyle (TextStyle style)
 Turn off a text style for subsequent text. More...
 
void resetTextStyle ()
 Turn off all text styles for subsequent text. More...
 
void setTitle (const String &title)
 Set the title of the console window. More...
 
bool getSize (uint_t *columns, uint_t *rows)
 Get the size of the console, in rows and columns. More...
 

Detailed Description

A class that provides basic control of the console, such as changing text attributes, clearing the screen, and moving the cursor.

Author
Mark Lindner

Member Enumeration Documentation

◆ TextColor

enum TextColor

Text colors.

Enumerator
ColorBlack 
ColorRed 
ColorGreen 
ColorYellow 
ColorBlue 
ColorMagenta 
ColorCyan 
ColorWhite 

◆ TextStyle

enum TextStyle

Text styles.

Enumerator
StyleBold 
StyleUnderline 
StyleInverse 

Constructor & Destructor Documentation

◆ Console()

Console ( )

Construct a new Console object.

◆ ~Console()

~Console ( )

Destructor.

Member Function Documentation

◆ beginTextStyle()

void beginTextStyle ( TextStyle  style)

Turn on a text style for subsequent text.

Parameters
styleThe style to turn on.

◆ clear()

void clear ( )

Clear the console.

◆ endTextStyle()

void endTextStyle ( TextStyle  style)

Turn off a text style for subsequent text.

Parameters
styleThe style to turn off.

◆ getSize()

bool getSize ( uint_t columns,
uint_t rows 
)

Get the size of the console, in rows and columns.

Parameters
columnsA pointer to the value in which to store the number of columns. May be NULL.
rowsA pointer to the value in which to store the number of rows. May be NULL.
Returns
true on success, false if the size could not be determined.

◆ moveCursor()

void moveCursor ( uint_t  row,
uint_t  column 
)

Move the cursor to a new position.

If the specified position is not valid, the cursor is not moved.

Parameters
rowThe new row.
columnThe new column.

◆ read()

size_t read ( char *  text,
size_t  maxlen 
)

Read text from the console.

Parameters
textThe array of characters to read into. The array will always be NUL-terminated on return.
maxlenThe maximum number of characters to read.
Returns
The number of characters actually read.

◆ resetTextStyle()

void resetTextStyle ( )

Turn off all text styles for subsequent text.

◆ setEcho()

bool setEcho ( bool  on)

Enable or disable the echoing of input characters on the console.

Returns
true on success, false otherwise.

◆ setTextBackground()

void setTextBackground ( TextColor  color)

Set the background color for subsequent text.

Parameters
colorThe text color.

◆ setTextForeground()

void setTextForeground ( TextColor  color)

Set the foreground color for subsequent text.

Parameters
colorThe text color.

◆ setTitle()

void setTitle ( const String title)

Set the title of the console window.

Parameters
titleThe new title.

◆ write()

void write ( const char *  text,
size_t  len = 0 
)

Write text to the console.

Parameters
textThe array of characters to write.
lenThe number of characters to write, or 0 to write all characters in the array, up to a NUL.

The documentation for this class was generated from the following files: