From 563d30f9f2a7f56fea6e2916bd40bedeceb8115c Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sat, 26 Apr 2025 17:27:56 +0200 Subject: [PATCH] add (colored) textwindow --- device/textstream.cc | 9 +++++++-- main.cc | 44 ++++++++++++++++++-------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/device/textstream.cc b/device/textstream.cc index 0a210d3..a384780 100644 --- a/device/textstream.cc +++ b/device/textstream.cc @@ -1,4 +1,5 @@ #include "textstream.h" +#include "../arch/lapic.h" TextStream::TextStream(unsigned from_col, unsigned to_col, @@ -9,10 +10,14 @@ TextStream::TextStream(unsigned from_col, to_col, from_row, to_row, - use_cursor){} + use_cursor){ + CGA::Color fg = static_cast((LAPIC::getID() + 1 )); + this->reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, fg, false)); + } void TextStream::flush() { - print(buffer,pos); + CGA::Color fg = static_cast((LAPIC::getID() + 1 )); + print(buffer,pos,CGA::Attribute(CGA::LIGHT_GREEN, fg, false)); pos = 0; } diff --git a/main.cc b/main.cc index eaa21ce..45dee7c 100644 --- a/main.cc +++ b/main.cc @@ -7,6 +7,8 @@ #include "arch/serial.h" #include "device/serialstream.h" +TextStream kout = TextStream(0, 80, 0, 12, true); + // Main function // (the bootstrap processor starts here)} extern "C" int main() { @@ -25,19 +27,19 @@ extern "C" int main() { //TextWindow tw_global = TextWindow(0, 80, 0, 25, true); //tw_global.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::BLUE, false)); - // test SerialStream - SerialStream ss = SerialStream(); - ss.print("test", 4); - ss.setAttribute(SerialStream::UNDERSCORE); - ss.print("test", 4); - ss.setAttribute(SerialStream::RESET); - ss.setForeground(SerialStream::MAGENTA); - ss.print("test", 4); - ss.setBackground(SerialStream::CYAN); - ss.print("test", 4); - ss.setPos(10, 10); - ss.print("test\n", 5); - ss.setBackground(SerialStream::BLACK); + //// test SerialStream + //SerialStream ss = SerialStream(); + //ss.print("test", 4); + //ss.setAttribute(SerialStream::UNDERSCORE); + //ss.print("test", 4); + //ss.setAttribute(SerialStream::RESET); + //ss.setForeground(SerialStream::MAGENTA); + //ss.print("test", 4); + //ss.setBackground(SerialStream::CYAN); + //ss.print("test", 4); + //ss.setPos(10, 10); + //ss.print("test\n", 5); + //ss.setBackground(SerialStream::BLACK); kout << "Test -> " << endl; kout << "bool: " << true << " -> true" << endl; @@ -70,21 +72,11 @@ extern "C" int main_ap() { << static_cast(LAPIC::getID()) << " in main_ap()" << endl; - TextWindow kout = TextWindow(0, 80, 0, 12, true); - kout.reset(); - kout.setPos(0,0); - kout.print("Corem ipsum dolor sit amit", 26); - kout.setPos(0,-1); - kout.print("test", 4, CGA::Attribute(CGA::BLACK, CGA::BLUE)); - int x,y; - kout.getPos(x,y); - kout.setPos(x+1,y); - kout.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::BLUE, false)); - TextWindow dout0 = TextWindow(0,20,13,19, false); - dout0.reset(); - dout0.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::RED, false)); + //TextWindow dout0 = TextWindow(0,20,13,19, false); + //dout0.reset(); + //dout0.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::RED, false)); ////test Serial