start implementing textwindow

main
Eggert Jung 6 months ago
parent 7cbe5f11e0
commit a84d23af31

@ -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) {

@ -20,6 +20,15 @@ class TextWindow {
TextWindow(const TextWindow&) = delete;
TextWindow& operator=(const TextWindow&) = delete;
unsigned from_col;
unsigned to_col;
unsigned from_row;
unsigned to_row;
bool use_cursor;
unsigned pos_x;
unsigned pos_y;
public:
/*! \brief Constructor of a text window
*

@ -3,6 +3,7 @@
#include "debug/output.h"
#include "arch/cga.h"
#include "arch/textwindow.h"
// Main function
// (the bootstrap processor starts here)}
@ -10,14 +11,18 @@ extern "C" int main() {
unsigned int numCPUs = Core::count();
DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl;
//test cga implemantation
CGA::setCursor(1, 2);
unsigned x,y;
CGA::getCursor(x, y);
CGA::setCursor(x+1, y+1);
for(uint8_t i = 0; i < 10; i++)
CGA::show(i, i, i+0x30, CGA::Attribute());
////test cga implemantation
//CGA::setCursor(1, 2);
//unsigned x,y;
//CGA::getCursor(x, y);
//CGA::setCursor(x+1, y+1);
//for(uint8_t i = 0; i < 10; i++)
// CGA::show(i, i, i+0x30, CGA::Attribute());
//test textwindow implemantation
TextWindow tw = TextWindow(0, 10, 0, 10, true);
tw.setPos(0,0);
tw.print("test123", 7);
/* Start application processors
* To avoid unexpected behaviour, make sure that interrupts are not

Loading…
Cancel
Save