From f03e33928b093c12db236b4a909a6f8dfde9461e Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sun, 20 Apr 2025 21:49:08 +0200 Subject: [PATCH] all todos for textwindow should be done --- arch/textwindow.cc | 12 ++++++++++-- arch/textwindow.h | 9 --------- main.cc | 5 +++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/textwindow.cc b/arch/textwindow.cc index 0f20235..8a27c43 100644 --- a/arch/textwindow.cc +++ b/arch/textwindow.cc @@ -20,9 +20,15 @@ void TextWindow::setPos(unsigned rel_x, unsigned 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) { @@ -35,8 +41,10 @@ void TextWindow::setPos(int rel_x, int rel_y) { } void TextWindow::getPos(int& rel_x, int& rel_y) const { - (void)rel_x; - (void)rel_y; + unsigned x, y; + getPos(x,y); + rel_x = x; + rel_y = y; } void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) { diff --git a/arch/textwindow.h b/arch/textwindow.h index 231c037..c7eb786 100644 --- a/arch/textwindow.h +++ b/arch/textwindow.h @@ -55,7 +55,6 @@ class TextWindow { * software cursor/variable (`false`) should be used to * store the current position * - * \todo(11) Implement constructor */ TextWindow(unsigned from_col, unsigned to_col, unsigned from_row, unsigned to_row, bool use_cursor = false); @@ -71,8 +70,6 @@ class TextWindow { * * \param rel_x Column in window * \param rel_y Row in window - * \todo(11) Implement method, use \ref CGA::setCursor() for the hardware - * cursor */ void setPos(unsigned rel_x, unsigned rel_y); @@ -87,8 +84,6 @@ class TextWindow { * Negative coordinates are interpreted relative to the right and bottom * border of the window. * - * \todo(11) Implement this method (it can either use or replace - * \ref setPos(unsigned, unsigned)) */ void setPos(int rel_x, int rel_y); @@ -100,8 +95,6 @@ class TextWindow { * * \param rel_x Column in window * \param rel_y Row in window - * \todo(11) Implement Method, use \ref CGA::getCursor() for the hardware - * cursor */ void getPos(unsigned& rel_x, unsigned& rel_y) const; @@ -128,7 +121,6 @@ class TextWindow { * \param string Text to be printed * \param length Length of text * \param attrib Attribute for text - * \todo(11) Implement Method */ void print(const char* string, size_t length, CGA::Attribute attrib = CGA::Attribute()); // NOLINT @@ -137,7 +129,6 @@ class TextWindow { * * \param character Fill character * \param attrib Attribute for fill character - * \todo(11) Implement Method */ void reset(char character = ' ', CGA::Attribute attrib = CGA::Attribute()); }; diff --git a/main.cc b/main.cc index ae51681..fe0bcef 100644 --- a/main.cc +++ b/main.cc @@ -27,6 +27,11 @@ extern "C" int main() { tw.reset(); tw.setPos(0,0); tw.print("lorem ipsum dolor sit amit", 26); + tw.setPos(0,-1); + tw.print("test", 4, CGA::Attribute(CGA::BLACK, CGA::BLUE)); + int x,y; + tw.getPos(x,y); + tw.setPos(x+1,y); /* Start application processors * To avoid unexpected behaviour, make sure that interrupts are not