1

add attribute support, fg/bg in progress

This commit is contained in:
churl
2022-04-28 00:40:01 +02:00
parent 3322218708
commit 2861c07c1a
5 changed files with 74 additions and 24 deletions

View File

@ -117,7 +117,6 @@ void CGA::print(char* string, int n, unsigned char attrib) {
this->setpos(cursor_x, cursor_y);
// TODO: automatic line breaking, automatic scrolling
// TODO: printing doesn't work after first newline character
}
/*****************************************************************************
@ -173,4 +172,8 @@ void CGA::clear() {
unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
/* Hier muess Code eingefuegt werden */
return blink << 7 // B0000000
| (bg & 0x7) << 4 // 0HHH0000
| (fg & 0xF); // 0000VVVV
}

View File

@ -24,6 +24,17 @@
* verwendet werden, um eine Ausgabe zu erzwingen. *
*****************************************************************************/
void CGA_Stream::flush() {
print(buffer, pos);
print(buffer, pos, attribute(this->color_bg, this->color_fg, this->blink));
pos = 0;
}
// NOTE: I added this
// TODO
// CGA_Stream& CGA_Stream::operator<<(const fgc& fg) {
// this->color_fg = fg.fg;
// return *this;
// }
// CGA_Stream& CGA_Stream::operator<<(const bgc& bg) {
// this->color_bg = bg.bg;
// return *this;
// }

View File

@ -18,16 +18,44 @@
#include "devices/CGA.h"
#include "lib/OutStream.h"
class CGA_Stream : public OutStream, public CGA {
// NOTE: I added this
class fgc {
public:
fgc() : fg(CGA::LIGHT_GREY) {};
fgc(CGA::color fg) : fg(fg) {};
CGA::color fg;
};
class bgc {
public:
bgc() : bg(CGA::BLACK) {};
bgc(CGA::color bg) : bg(bg) {};
CGA::color bg;
};
class CGA_Stream : public OutStream, public CGA {
private:
CGA_Stream(CGA_Stream& copy); // Verhindere Kopieren
public:
CGA_Stream() : OutStream(), CGA() { flush(); }
CGA::color color_fg;
CGA::color color_bg;
bool blink;
CGA_Stream() : OutStream(), CGA() {
color_fg = CGA::LIGHT_GREY;
color_bg = CGA::BLACK;
blink = false;
flush();
}
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
void flush() override;
// NOTE: I added this
// TODO: Problem: Implementing this here breaks the << chaining
// CGA_Stream& operator<<(const fgc&);
// CGA_Stream& operator<<(const bgc&);
};
#endif