add attribute support, fg/bg in progress
This commit is contained in:
@ -117,7 +117,6 @@ void CGA::print(char* string, int n, unsigned char attrib) {
|
|||||||
this->setpos(cursor_x, cursor_y);
|
this->setpos(cursor_x, cursor_y);
|
||||||
|
|
||||||
// TODO: automatic line breaking, automatic scrolling
|
// 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) {
|
unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
|
||||||
|
|
||||||
/* Hier muess Code eingefuegt werden */
|
/* Hier muess Code eingefuegt werden */
|
||||||
|
|
||||||
|
return blink << 7 // B0000000
|
||||||
|
| (bg & 0x7) << 4 // 0HHH0000
|
||||||
|
| (fg & 0xF); // 0000VVVV
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,17 @@
|
|||||||
* verwendet werden, um eine Ausgabe zu erzwingen. *
|
* verwendet werden, um eine Ausgabe zu erzwingen. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void CGA_Stream::flush() {
|
void CGA_Stream::flush() {
|
||||||
print(buffer, pos);
|
print(buffer, pos, attribute(this->color_bg, this->color_fg, this->blink));
|
||||||
pos = 0;
|
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;
|
||||||
|
// }
|
||||||
|
|||||||
@ -18,16 +18,44 @@
|
|||||||
#include "devices/CGA.h"
|
#include "devices/CGA.h"
|
||||||
#include "lib/OutStream.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:
|
private:
|
||||||
CGA_Stream(CGA_Stream& copy); // Verhindere Kopieren
|
CGA_Stream(CGA_Stream& copy); // Verhindere Kopieren
|
||||||
|
|
||||||
public:
|
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.
|
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
|
||||||
void flush() override;
|
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
|
#endif
|
||||||
|
|||||||
@ -24,18 +24,18 @@
|
|||||||
|
|
||||||
#include "lib/StringBuffer.h"
|
#include "lib/StringBuffer.h"
|
||||||
|
|
||||||
// NOTE: I added this, stream manipulator with argument
|
// NOTE: I added this
|
||||||
class OutStream;
|
// TODO: I should probably put this inside some FormatStream or sth...
|
||||||
|
|
||||||
// TODO: Should this only work for the next << ?
|
// TODO: Should this only work for the next << ?
|
||||||
class fillw {
|
class fillw {
|
||||||
public:
|
public:
|
||||||
|
fillw() : w(0) {};
|
||||||
fillw(unsigned char w) : w(w) {};
|
fillw(unsigned char w) : w(w) {};
|
||||||
unsigned char w;
|
unsigned char w;
|
||||||
};
|
};
|
||||||
|
|
||||||
class fillc {
|
class fillc {
|
||||||
public:
|
public:
|
||||||
|
fillc() : c(' ') {};
|
||||||
fillc(char c) : c(c) {};
|
fillc(char c) : c(c) {};
|
||||||
char c;
|
char c;
|
||||||
};
|
};
|
||||||
@ -58,15 +58,16 @@ public:
|
|||||||
char fill_char; // fill character for fixed width
|
char fill_char; // fill character for fixed width
|
||||||
|
|
||||||
OutStream() : StringBuffer() {
|
OutStream() : StringBuffer() {
|
||||||
base = 10; // initial Dezimalsystem
|
base = 10; // initial Dezimalsystem
|
||||||
fill_width = 0; // no fixed width
|
|
||||||
fill_used = 0;
|
fill_width = 0; // no fixed width
|
||||||
fill_char = ' '; // fill with spaces
|
fill_char = ' '; // fill with spaces
|
||||||
|
fill_used = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush() override = 0; // weiterhin undefiniert aber public
|
void flush() override = 0; // weiterhin undefiniert aber public
|
||||||
|
|
||||||
// NOTE: I added this
|
// NOTE: I added this, override put for fixed width
|
||||||
void put(char c) override;
|
void put(char c) override;
|
||||||
|
|
||||||
// OPERATOR << : Umwandlung des angegebenen Datentypes in eine
|
// OPERATOR << : Umwandlung des angegebenen Datentypes in eine
|
||||||
@ -90,9 +91,9 @@ public:
|
|||||||
// Darstellung eines Zeigers als hexadezimale ganze Zahl
|
// Darstellung eines Zeigers als hexadezimale ganze Zahl
|
||||||
OutStream& operator<<(void* ptr);
|
OutStream& operator<<(void* ptr);
|
||||||
|
|
||||||
// NOTE: I added this, set fixed output width
|
// NOTE: I added this
|
||||||
OutStream& operator<<(const fillw& w);
|
OutStream& operator<<(const fillw&);
|
||||||
OutStream& operator<<(const fillc& c);
|
OutStream& operator<<(const fillc&);
|
||||||
|
|
||||||
// Aufruf einer Manipulatorfunktion
|
// Aufruf einer Manipulatorfunktion
|
||||||
OutStream& operator<<(OutStream& (*f)(OutStream&));
|
OutStream& operator<<(OutStream& (*f)(OutStream&));
|
||||||
|
|||||||
@ -13,16 +13,23 @@
|
|||||||
void text_demo() {
|
void text_demo() {
|
||||||
|
|
||||||
/* Hier muess Code eingefuegt werden */
|
/* Hier muess Code eingefuegt werden */
|
||||||
kout << "Test der Zahlenausgabefunktion:" << endl;
|
kout << "Attribut (GREEN on WHITE, blinking): "
|
||||||
kout << endl;
|
<< (unsigned short)kout.attribute(CGA::WHITE, CGA::GREEN, true) << endl
|
||||||
kout << "| dec | hex | bin |" << endl;
|
<< "Attribut (WHITE on BLACK, no blink): "
|
||||||
kout << "+-------+-------+-------+" << endl;
|
<< (unsigned short)kout.attribute(CGA::BLACK, CGA::WHITE, false) << endl
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
kout << "Test der Zahlenausgabefunktion:" << endl
|
||||||
|
<< endl
|
||||||
|
<< "| dec | hex | bin |" << endl
|
||||||
|
<< "+-------+-------+-------+" << endl;
|
||||||
|
|
||||||
// TODO: should fillw just work for the next << ?
|
|
||||||
for (unsigned short num = 0; num < 17; ++num) {
|
for (unsigned short num = 0; num < 17; ++num) {
|
||||||
kout << fillw(0) << "| " << fillw(6) << dec << num;
|
kout << fillw(0) << "| " << fillw(6) << dec << num
|
||||||
kout << fillw(0) << "| " << fillw(6) << hex << num;
|
<< fillw(0) << "| " << fillw(6) << hex << num
|
||||||
kout << fillw(0) << "| " << fillw(6) << bin << num;
|
<< fillw(0) << "| " << fillw(6) << bin << num
|
||||||
kout << fillw(0) << "|" << endl;
|
<< fillw(0) << "|" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kout << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user