author | Radek Brich <radek.brich@devl.cz> |
Wed, 03 Sep 2014 19:08:21 +0200 | |
changeset 109 | 105b1affc3c2 |
parent 73 | 85a282b5e4fc |
permissions | -rw-r--r-- |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#include "SDL.h" |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
#include "SDL_ttf.h" |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
#include <map> |
58
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
5 |
#include <string> |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
#include <vector> |
58
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
7 |
#include <exception> |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
10 |
namespace Style |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
11 |
{ |
54
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
12 |
enum { |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
13 |
BOLD = 1 << 24, // bold font |
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
14 |
UNDERLINE = 1 << 25, // underline text |
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
15 |
STANDOUT = 1 << 26, // inverse bg/fg |
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
16 |
BLINK = 1 << 27, // blinking |
54
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
17 |
}; |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
18 |
}; |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
19 |
|
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
20 |
|
67
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
21 |
namespace KeyMod |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
22 |
{ |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
23 |
enum { |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
24 |
SHIFT = 1<<0, |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
25 |
ALT = 1<<1, |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
26 |
CTRL = 1<<2, |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
27 |
META = 1<<3, |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
28 |
}; |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
29 |
}; |
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
30 |
|
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
31 |
|
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
32 |
class ColorMap |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
33 |
{ |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
34 |
private: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
35 |
Uint8 _map[16][3] = { |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
36 |
{0,0,0}, // 0 - black |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
37 |
{23,23,178}, // 1 - blue |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
38 |
{23,178,23}, // 2 - green |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
39 |
{23,178,178}, // 3 - cyan |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
40 |
{178,23,23}, // 4 - red |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
41 |
{178,23,178}, // 5 - magenta |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
42 |
{178,103,23}, // 6 - brown |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
43 |
{178,178,178}, // 7 - light gray |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
44 |
{104,104,104}, // 8 - gray |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
45 |
{84,84,255}, // 9 - light blue |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
46 |
{84,255,84}, // 10 - light green |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
47 |
{84,255,255}, // 11 - light cyan |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
48 |
{255,84,84}, // 12 - light red |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
49 |
{255,84,255}, // 13 - light magenta |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
50 |
{255,255,84}, // 14 - yellow |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
51 |
{255,255,255}, // 15 - white |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
52 |
}; |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
53 |
|
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
54 |
public: |
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
55 |
void index_to_rgb(int index, SDL_Color &color) const; |
50
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
56 |
}; |
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
57 |
|
c5b8b9d2da95
DriverSDL: Implement colors.
Radek Brich <radek.brich@devl.cz>
parents:
49
diff
changeset
|
58 |
|
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
59 |
class GlyphCache |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
60 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
61 |
public: |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
62 |
// lookup glyph in cache, id is combined char and attr |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
63 |
SDL_Surface *lookup_glyph(Uint64 id); |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
64 |
void put_glyph(Uint64 id, SDL_Surface *srf); |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
65 |
void flush(); |
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
66 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
67 |
private: |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
68 |
std::map<Uint64, SDL_Surface*> _glyph_map; |
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
69 |
}; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
70 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
71 |
|
54
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
72 |
/* TTF font glyph renderer |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
73 |
* |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
74 |
* Renders uniformly sized cells with single character. |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
75 |
* Wraps SDL_ttf functions, see its documentation here: |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
76 |
* |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
77 |
* http://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
78 |
* |
86b84535726e
DriverSDL: system font lookup.
Radek Brich <radek.brich@devl.cz>
parents:
53
diff
changeset
|
79 |
*/ |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
80 |
class GlyphRenderer |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
81 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
82 |
public: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
83 |
GlyphRenderer(); |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
84 |
~GlyphRenderer(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
85 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
86 |
void open_font(const char *fname_regular, const char *fname_bold, int ptsize); |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
87 |
void close_font(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
88 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
89 |
// do not free surface returned! |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
90 |
SDL_Surface *render_cell(Uint32 ch, Uint32 attr, bool blink_state); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
91 |
|
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
92 |
int get_cell_width() const { return _cell_width; }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
93 |
int get_cell_height() const { return _cell_height; }; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
94 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
95 |
private: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
96 |
TTF_Font *_font_regular; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
97 |
TTF_Font *_font_bold; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
98 |
int _cell_width; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
99 |
int _cell_height; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
100 |
GlyphCache _cache; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
101 |
ColorMap _colormap; |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
102 |
|
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
103 |
void _render_glyph(SDL_Surface *cell_surface, TTF_Font *font, Uint32 ch, |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
104 |
SDL_Color fgcolor, SDL_Color bgcolor); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
105 |
}; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
106 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
107 |
|
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
108 |
/* One cell of terminal window |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
109 |
* |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
110 |
* Each cell contains one character, its color and attributes. |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
111 |
* Character is encoded in 32bit unicode. |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
112 |
* Other 32 bits are attributes: |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
113 |
* 0-7 (8b) - foreground color index |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
114 |
* 8-15 (8b) - background color index |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
115 |
* 16-23 (8b) - RESERVED for alpha channel |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
116 |
* 24 (1b) - bold font |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
117 |
* 25 (1b) - underline |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
118 |
* 26 (1b) - standout (swap fg/bg color) |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
119 |
* 27 (1b) - blink |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
120 |
* 28-31 (4b) - RESERVED |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
121 |
*/ |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
122 |
struct TerminalCell |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
123 |
{ |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
124 |
Uint32 ch; |
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
125 |
Uint32 attr; |
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
126 |
|
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
127 |
TerminalCell() : ch(0), attr(7) {}; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
128 |
bool operator !=(const TerminalCell &rhs) const { return ch != rhs.ch || attr != rhs.attr; }; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
129 |
}; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
130 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
131 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
132 |
class TerminalScreen |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
133 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
134 |
public: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
135 |
TerminalScreen(): |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
136 |
_screen_surface(NULL), _cells_front(0), _cells_back(0), _render(), |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
137 |
_pixel_width(0), _pixel_height(0), _width(0), _height(0), |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
138 |
_cell_width(0), _cell_height(0), _blink_state(1) {}; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
139 |
~TerminalScreen() {}; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
140 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
141 |
void select_font(const char *fname_regular, const char *fname_bold, int ptsize); |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
142 |
void resize(int pxwidth, int pxheight); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
143 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
144 |
void erase(); |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
145 |
void putch(int x, int y, Uint32 ch, Uint32 attr); |
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
146 |
void toggle_cursor(int x, int y); |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
147 |
void toggle_blink() { _blink_state = !_blink_state; _draw_blink(); }; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
148 |
void commit(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
149 |
|
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
150 |
// force full redraw on next commit() |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
151 |
void redraw(); |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
152 |
|
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
153 |
int get_width() const { return _width; }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
154 |
int get_height() const { return _height; }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
155 |
int get_cell_width() const { return _cell_width; }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
156 |
int get_cell_height() const { return _cell_height; }; |
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
157 |
|
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
158 |
private: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
159 |
SDL_Surface *_screen_surface; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
160 |
std::vector<TerminalCell> _cells_front; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
161 |
std::vector<TerminalCell> _cells_back; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
162 |
GlyphRenderer _render; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
163 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
164 |
int _pixel_width; // terminal window width in pixels |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
165 |
int _pixel_height; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
166 |
int _width; // width in characters |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
167 |
int _height; // height in characters |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
168 |
int _cell_width; // character cell width in pixels |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
169 |
int _cell_height; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
170 |
|
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
171 |
int _blink_state; // 0 - blink chars hidden, 1 - visible |
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
172 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
173 |
void _reset_cells(); |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
174 |
void _draw_blink(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
175 |
}; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
176 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
177 |
|
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
178 |
struct Event |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
179 |
{ |
73
85a282b5e4fc
Add mousehover event (only SDL).
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
180 |
enum { QUIT, RESIZE, KEYPRESS, MOUSEDOWN, MOUSEUP, MOUSEMOVE, MOUSEHOVER, MOUSEWHEEL }; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
181 |
int type; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
182 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
183 |
union |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
184 |
{ |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
185 |
struct |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
186 |
{ |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
187 |
char keyname[10]; |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
188 |
Uint32 unicode; |
67
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
189 |
int mod; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
190 |
} key; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
191 |
struct |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
192 |
{ |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
193 |
int x, y; |
71
cfd3445107b4
Report mousemove relative position change. Window: when in AnchorLayout, aligned right/bottom - fix resizing by mouse to behave as expected.
Radek Brich <radek.brich@devl.cz>
parents:
67
diff
changeset
|
194 |
int relx, rely; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
195 |
int button; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
196 |
} mouse; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
197 |
}; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
198 |
}; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
199 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
200 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
201 |
class Terminal |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
202 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
203 |
public: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
204 |
Terminal(); |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
205 |
~Terminal(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
206 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
207 |
void select_font(const char *fname_regular, const char *fname_bold, int ptsize) |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
208 |
{ _screen.select_font(fname_regular, fname_bold, ptsize); }; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
209 |
void resize(int pxwidth, int pxheight) { _screen.resize(pxwidth, pxheight); }; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
210 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
211 |
void erase() { _screen.erase(); }; |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
212 |
void putch(int x, int y, Uint32 ch) { _screen.putch(x, y, ch, _attr); }; |
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
213 |
void commit(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
214 |
|
61 | 215 |
Uint32 prepare_attr(Uint8 fg, Uint8 bg, Uint32 style) { return (Uint32)fg | (Uint32)bg << 8 | (style & 0xFF000000); }; |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
216 |
void set_attr(Uint32 value) { _attr = value; }; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
217 |
|
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
218 |
void show_cursor(int x, int y) { _cursor_x = x; _cursor_y = y; _cursor_visible = true; }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
219 |
void hide_cursor() { _cursor_visible = false; }; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
220 |
|
57
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
221 |
/* Wait for an event. |
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
222 |
* |
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
223 |
* Timeout is in miliseconds, zero means wait indefinitely. |
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
224 |
* Returns false on timeout, true on event. |
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
225 |
*/ |
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
226 |
bool wait_event(Event &event, Uint32 timeout); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
227 |
|
53
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
228 |
int get_width() const { return _screen.get_width(); }; |
c4263588b716
DriverSDL: Implement cursor, handle window resize.
Radek Brich <radek.brich@devl.cz>
parents:
52
diff
changeset
|
229 |
int get_height() const { return _screen.get_height(); }; |
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
230 |
|
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
231 |
private: |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
232 |
TerminalScreen _screen; |
52
50a1857557da
Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents:
51
diff
changeset
|
233 |
Uint32 _attr; |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
234 |
int _cursor_x; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
235 |
int _cursor_y; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
236 |
bool _cursor_visible; |
48
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
237 |
|
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
238 |
int _mousemove_last_x; |
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
239 |
int _mousemove_last_y; |
49
1611c462c3e3
Update sdlterm: Optimize commit() - use two cell buffers, redraw only dirty cells, not everything. Fix keypress event, filter mousemove.
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
240 |
|
72
6e0656600754
DriverSDL: Fix event dispatching. Add SDL events test.
Radek Brich <radek.brich@devl.cz>
parents:
71
diff
changeset
|
241 |
bool _handle_event(const SDL_Event &sdl_event, Event &event); |
51
dce7325109c1
Clean up: expand unwanted tabs.
Radek Brich <radek.brich@devl.cz>
parents:
50
diff
changeset
|
242 |
const char *_translate_keyname(SDLKey sym); |
67
71f60bf6ebb7
DriverSDL: add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
61
diff
changeset
|
243 |
int _translate_mod(SDLMod mod); |
57
911927edbdde
DriverSDL: Add support for timeouts.
Radek Brich <radek.brich@devl.cz>
parents:
54
diff
changeset
|
244 |
static Uint32 _wait_event_callback(Uint32 interval, void *param); |
60
fccca2a60492
DriverSDL: Implement blink attribute.
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
245 |
static Uint32 _blink_toggle_callback(Uint32 interval, void *param); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
246 |
}; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
247 |
|
58
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
248 |
|
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
249 |
class SDLTermError: public std::exception |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
250 |
{ |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
251 |
public: |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
252 |
SDLTermError(const std::string &a_msg) |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
253 |
: std::exception(), _msg(a_msg) {}; |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
254 |
virtual ~SDLTermError() throw() {}; |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
255 |
|
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
256 |
virtual const char *what() const throw() { return _msg.c_str(); }; |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
257 |
|
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
258 |
private: |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
259 |
std::string _msg; |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
260 |
}; |
50308ed5e4f9
sdlterm: Cleanup exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
57
diff
changeset
|
261 |