#include "textwindow.h" #include "cga.h" TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row, unsigned to_row, bool use_cursor) { this->from_col = from_col; this->to_col = to_col; this->from_row = from_row; this->to_row = to_row; this->use_cursor = use_cursor; } void TextWindow::setPos(unsigned rel_x, unsigned rel_y) { if(use_cursor){ CGA::setCursor(from_col + rel_x, from_row + rel_y); }else{ pos_x = from_col + rel_x; pos_y = from_row + rel_y; } } void TextWindow::getPos(unsigned& rel_x, unsigned& rel_y) const { if(use_cursor){ CGA::getCursor(rel_x, rel_y); rel_x -= from_col; rel_y -= from_row; } else { rel_x = pos_x - from_col; rel_y = pos_y - from_row; } } void TextWindow::setPos(int rel_x, int rel_y) { if(rel_x < 0) rel_x = to_col - from_col + rel_x; if(rel_y < 0) rel_y = to_row - from_row + rel_y; setPos((unsigned) rel_x, (unsigned) rel_y); } void TextWindow::getPos(int& rel_x, int& rel_y) const { unsigned x, y; getPos(x,y); rel_x = x; rel_y = y; } void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) { for(unsigned i=0; i= to_row-1){ //TODO scrollUp() } else{ y_now++; } setPos(x_now, y_now); return; } CGA::show(x_now, y_now, str[i], attrib); if(from_col+x_now >= to_col-1){ x_now = 0; if(from_row + y_now >= to_row-1){ //TODO scrollUp() } else{ y_now++; } } else { x_now++; } setPos(x_now, y_now); } } void TextWindow::reset(char character, CGA::Attribute attrib) { for(unsigned i=from_row; i