|
|
|
|
@ -1,27 +1,37 @@
|
|
|
|
|
#include "textwindow.h"
|
|
|
|
|
#include "cga.h"
|
|
|
|
|
|
|
|
|
|
TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row,
|
|
|
|
|
unsigned to_row, bool use_cursor) {
|
|
|
|
|
(void)from_col;
|
|
|
|
|
(void)to_col;
|
|
|
|
|
(void)from_row;
|
|
|
|
|
(void)to_row;
|
|
|
|
|
(void)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) {
|
|
|
|
|
(void)rel_x;
|
|
|
|
|
(void)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 {
|
|
|
|
|
(void)rel_x;
|
|
|
|
|
(void)rel_y;
|
|
|
|
|
CGA::getCursor(rel_x, rel_y);
|
|
|
|
|
rel_x -= from_col;
|
|
|
|
|
rel_y -= from_row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextWindow::setPos(int rel_x, int rel_y) {
|
|
|
|
|
(void)rel_x;
|
|
|
|
|
(void)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 {
|
|
|
|
|
@ -30,9 +40,24 @@ void TextWindow::getPos(int& rel_x, int& rel_y) const {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
|
|
|
|
|
(void)str;
|
|
|
|
|
(void)length;
|
|
|
|
|
(void)attrib;
|
|
|
|
|
for(unsigned i=0; i<length; i++){
|
|
|
|
|
unsigned x_now, y_now;
|
|
|
|
|
getPos(x_now, y_now);
|
|
|
|
|
CGA::show(x_now, y_now, str[i], attrib);
|
|
|
|
|
if(from_col+x_now >= to_col){
|
|
|
|
|
x_now = 0;
|
|
|
|
|
if(from_row + y_now >= to_row){
|
|
|
|
|
//scrollUp()
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
y_now++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
x_now++;
|
|
|
|
|
}
|
|
|
|
|
setPos(x_now, y_now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextWindow::reset(char character, CGA::Attribute attrib) {
|
|
|
|
|
|