StuBS
|
Virtual windows in text mode. More...
#include <textwindow.h>
Public Member Functions | |
TextWindow (unsigned from_col, unsigned to_col, unsigned from_row, unsigned to_row, bool use_cursor=false) | |
Constructor of a text window. | |
void | setPos (unsigned rel_x, unsigned rel_y) |
Set the cursor position in the window. | |
void | getPos (unsigned &rel_x, unsigned &rel_y) const |
Get the current cursor position in the window. | |
void | print (const char *string, size_t length, Attribute attrib=TextMode::Attribute()) |
Display multiple characters in the window. | |
void | reset (char character=' ', Attribute attrib=TextMode::Attribute()) |
Delete all contents in the window and reset the cursor. | |
Protected Attributes | |
unsigned | from_col |
Start column position (inclusive) of window. | |
unsigned | to_col |
End column position (exclusive) of window. | |
unsigned | from_row |
Start row position (inclusive) of window. | |
unsigned | to_row |
End row position (exclusive) of window. | |
bool | use_cursor |
use hardware cursor | |
unsigned | pos_x |
Software cursor column. | |
unsigned | pos_y |
Software cursor row. | |
Private Member Functions | |
void | scrollUp () const |
Scroll the contents of a window a line up. | |
Additional Inherited Members | |
Public Types inherited from TextMode | |
enum | Color { BLACK , BLUE , GREEN , CYAN , RED , MAGENTA , BROWN , LIGHT_GREY , DARK_GREY , LIGHT_BLUE , LIGHT_GREEN , LIGHT_CYAN , LIGHT_RED , LIGHT_MAGENTA , YELLOW , WHITE } |
CGA color palette. More... | |
Static Public Member Functions inherited from TextMode | |
static void | setCursor (unsigned abs_x, unsigned abs_y) |
Set the keyboard hardware cursor to absolute screen position. | |
static void | getCursor (unsigned &abs_x, unsigned &abs_y) |
Retrieve the keyboard hardware cursor position on screen. | |
static void | show (unsigned abs_x, unsigned abs_y, char character, Attribute attrib=Attribute()) |
Basic output of a character at a specific position on the screen. | |
Static Public Attributes inherited from TextMode | |
static const unsigned | ROWS = 25 |
Visible rows in text mode. | |
static const unsigned | COLUMNS = 80 |
Visible columns in text mode. | |
Protected Member Functions inherited from TextMode | |
TextMode () | |
Default constructor. | |
Static Protected Attributes inherited from TextMode | |
static Cell *const | TEXT_BUFFER_BASE = reinterpret_cast<TextMode::Cell *>(0xb8000) |
Base address for linear text buffer in video memory. | |
Virtual windows in text mode.
Outputs text on a part of the screen in text mode, a window defined in its position and size (with its own cursor).
This allows to separate the output of the application from the debug output on the screen without having to synchronize.
TextWindow::TextWindow | ( | unsigned | from_col, |
unsigned | to_col, | ||
unsigned | from_row, | ||
unsigned | to_row, | ||
bool | use_cursor = false ) |
Constructor of a text window.
Creates a virtual, rectangular text window on the screen. The coordinates to construct the window are absolute positions in the TextMode screen.
from_col | Text Window starts in column from_col , the first (leftmost) possible column is 0 |
to_col | Text Window extends to the right to column to_col (exclusive). This column has to be strictly greater than from_col , the maximum allowed value is TextMode::COLUMNS (rightmost) |
from_row | Text Window starts in row from_row , the first possible (uppermost) row is 0 |
to_row | Text Window extends down to row to_row (exclusive). This row has to be strictly greater than from_row , the maximum allowed value is TextMode::ROWS (bottom-most) |
use_cursor | Specifies whether the hardware cursor (true ) or a software cursor/variable (false ) should be used to store the current position |
void TextWindow::getPos | ( | unsigned & | rel_x, |
unsigned & | rel_y ) const |
Get the current cursor position in the window.
Depending on the constructor parameter use_cursor
either the hardware cursor (and only the hardware cursor!) is used or the position is retrieved from the internally stored object.
rel_x | Column in window |
rel_y | Row in window |
void TextWindow::print | ( | const char * | string, |
size_t | length, | ||
Attribute | attrib = TextMode::Attribute() ) |
Display multiple characters in the window.
Output a character string, starting at the current cursor position. Since the string does not need to contain a \0
termination (unlike the common C string), a length parameter is required to specify the number of characters in the string. When the output is complete, the cursor is positioned after the last printed character. The same attributes (colors) are used for the entire text.
If there is not enough space left at the end of the line, the output continues on the following line. As soon as the last window line is filled, the entire window area is moved up one line: The first line disappears, the bottom line is cleared.
A line break also occurs whenever the character \n
appears in the text.
string | Text to be printed |
length | Length of text |
attrib | Attribute for text |
void TextWindow::reset | ( | char | character = ' ', |
Attribute | attrib = TextMode::Attribute() ) |
Delete all contents in the window and reset the cursor.
character | Fill character |
attrib | Attribute for fill character |
|
private |
Scroll the contents of a window a line up.
Moves the screen content up one line. The new line at the bottom of the screen is filled with blanks.
void TextWindow::setPos | ( | unsigned | rel_x, |
unsigned | rel_y ) |
Set the cursor position in the window.
Depending on the constructor parameter use_cursor
either the hardware cursor (and only the hardware cursor!) is used or the position is stored internally in the object.
The coordinates are relative to the upper left starting position of the window.
rel_x | Column in window |
rel_y | Row in window |
|
protected |
use hardware cursor
otherwise the position is stored in local variables