start implementing textwindow

main
Eggert Jung 6 months ago
parent 7cbe5f11e0
commit a84d23af31

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

@ -20,6 +20,15 @@ class TextWindow {
TextWindow(const TextWindow&) = delete; TextWindow(const TextWindow&) = delete;
TextWindow& operator=(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: public:
/*! \brief Constructor of a text window /*! \brief Constructor of a text window
* *

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

Loading…
Cancel
Save