C++ Crashkurs
Virtual windows in text mode. More...
#include <machine/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. More... | |
void | setPos (unsigned rel_x, unsigned rel_y) |
Set the cursor position in the window. More... | |
void | setPos (int rel_x, int rel_y) |
Set the cursor position in the window. More... | |
void | getPos (unsigned &rel_x, unsigned &rel_y) const |
Get the current cursor position in the window. More... | |
void | getPos (int &rel_x, int &rel_y) const |
Get the current cursor position in the window. More... | |
void | print (const char *string, size_t length, Attribute attrib=TextMode::Attribute()) |
Display multiple characters in the window. More... | |
void | reset (char character=' ', Attribute attrib=TextMode::Attribute()) |
Delete all contents in the window and reset the cursor. More... | |
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 More... | |
unsigned | pos_x |
Software cursor column. | |
unsigned | pos_y |
Software cursor row. | |
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. More... | |
static void | getCursor (unsigned &abs_x, unsigned &abs_y) |
Retrieve the keyboard hardware cursor position on screen. More... | |
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. More... | |
static void | show (int abs_x, int abs_y, char character, Attribute attrib=Attribute()) |
Basic output of a character at a specific position on the screen. More... | |
static void | showMouse (unsigned abs_x, unsigned abs_y) |
Show the mouse cursor by switching foreground and background of the cell at cursor position. More... | |
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. | |
static unsigned | mouse_x = 0 |
Last reported column of mouse cursor. | |
static unsigned | mouse_y = 0 |
Last reported row of mouse cursor. | |
static Attribute | mouse_attrib |
(Previous) attributes of cell at mouse cursor | |
Detailed Description
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.
Constructor & Destructor Documentation
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.
- Note
- Overlapping windows are neither supported nor prevented – better just try to avoid construction windows with overlapping coordinates!
- Warning
- Don't use the hardware cursor in more than one window!
- Parameters
-
from_col Text Window starts in column from_col
, the first (leftmost) possible column is0
to_col Text Window extends to the right to column to_col
(exclusive). This column has to be strictly greater thanfrom_col
, the maximum allowed value is TextMode::COLUMNS (rightmost)from_row Text Window starts in row from_row
, the first possible (uppermost) row is0
to_row Text Window extends down to row to_row
(exclusive). This row has to be strictly greater thanfrom_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
Member Function Documentation
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.
- Parameters
-
rel_x Column in window rel_y Row in window
void TextWindow::setPos | ( | int | rel_x, |
int | 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. Negative coordinates are interpreted relative to the right and bottom border of the window.
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.
- Parameters
-
rel_x Column in window rel_y Row in window
void TextWindow::getPos | ( | int & | rel_x, |
int & | 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.
- Parameters
-
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.
- Parameters
-
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.
- Parameters
-
character Fill character attrib Attribute for fill character
Member Data Documentation
|
protected |
use hardware cursor
otherwise the position is stored in local variables
The documentation for this class was generated from the following files:
- machine/textwindow.h
- machine/textwindow.cc