--- a/sdlterm/src/sdlterm.h Sat Jan 05 16:47:30 2013 +0100
+++ b/sdlterm/src/sdlterm.h Sat Jan 05 18:44:56 2013 +0100
@@ -5,6 +5,42 @@
#include <vector>
+enum class Style: Uint16
+{
+ BOLD = 1 << 0, // bold font
+ UNDERLINE = 1 << 1, // underline text
+ STANDOUT = 1 << 2, // inverse bg/fg
+ BLINK = 1 << 3, // blinking
+};
+
+
+class ColorMap
+{
+private:
+ Uint8 _map[16][3] = {
+ {0,0,0}, // 0 - black
+ {23,23,178}, // 1 - blue
+ {23,178,23}, // 2 - green
+ {23,178,178}, // 3 - cyan
+ {178,23,23}, // 4 - red
+ {178,23,178}, // 5 - magenta
+ {178,103,23}, // 6 - brown
+ {178,178,178}, // 7 - light gray
+ {104,104,104}, // 8 - gray
+ {84,84,255}, // 9 - light blue
+ {84,255,84}, // 10 - light green
+ {84,255,255}, // 11 - light cyan
+ {255,84,84}, // 12 - light red
+ {255,84,255}, // 13 - light magenta
+ {255,255,84}, // 14 - yellow
+ {255,255,255}, // 15 - white
+ };
+
+public:
+ void index_to_rgb(int index, SDL_Color &color);
+};
+
+
class GlyphCache
{
public:
@@ -27,7 +63,7 @@
void close_font();
// do not free surface returned!
- SDL_Surface *render_glyph(Uint16 ch);
+ SDL_Surface *render_cell(Uint16 ch, Uint16 attr);
int get_cell_width() { return _cell_width; };
int get_cell_height() { return _cell_height; };
@@ -38,6 +74,7 @@
int _cell_width;
int _cell_height;
GlyphCache _cache;
+ ColorMap _colormap;
};
@@ -52,7 +89,9 @@
class TerminalScreen
{
public:
- TerminalScreen(): _screen_surface(NULL), _render() {};
+ TerminalScreen():
+ _screen_surface(NULL), _cells_front(0), _cells_back(0), _render(),
+ _pixel_width(0), _pixel_height(0) {};
~TerminalScreen() {};
void select_font(const char *fname_regular, const char *fname_bold, int ptsize);
@@ -119,7 +158,7 @@
void putch(int x, int y, Uint16 ch) { _screen.putch(x, y, ch, _attr); };
void commit() { _screen.commit(); };
- Uint16 prepare_attr(Uint8 fg, Uint8 bg, Uint8 style) { return fg | bg << 8 | style << 16; };
+ Uint16 prepare_attr(Uint8 fg, Uint8 bg, Uint8 style) { return fg | bg << 4 | style << 8; };
void set_attr(Uint16 value) { _attr = value; };
void set_cursor(int x, int y) { _cursor_x = x; _cursor_y = y; };