author | Radek Brich <radek.brich@devl.cz> |
Sat, 05 Jan 2013 16:47:30 +0100 | |
changeset 49 | 1611c462c3e3 |
parent 48 | 1f00e90fd72a |
child 50 | c5b8b9d2da95 |
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 "sdlterm.h" |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
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
|
3 |
#include <exception> |
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
|
4 |
#include <algorithm> |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
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
|
7 |
SDL_Surface *GlyphCache::lookup_glyph(Uint16 ch) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
8 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
9 |
auto iter = _glyph_map.find(ch); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
10 |
if (iter == _glyph_map.end()) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
11 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
12 |
return NULL; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
13 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
14 |
return iter->second; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
15 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
16 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
17 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
18 |
void GlyphCache::put_glyph(Uint16 ch, SDL_Surface *srf) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
19 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
20 |
_glyph_map[ch] = srf; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
21 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
22 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
23 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
24 |
void GlyphCache::flush() |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
25 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
26 |
for (auto iter = _glyph_map.begin(); iter != _glyph_map.end(); iter++) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
27 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
28 |
SDL_FreeSurface(iter->second); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
29 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
30 |
_glyph_map.clear(); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
31 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
32 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
33 |
|
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
GlyphRenderer::GlyphRenderer() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
: _font_regular(NULL), _font_bold(NULL) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
if (TTF_Init() == -1) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
printf("TTF_Init: %s\n", TTF_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
throw std::exception(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
43 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
44 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
45 |
GlyphRenderer::~GlyphRenderer() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
46 |
{ |
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
|
47 |
_cache.flush(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
48 |
close_font(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
49 |
TTF_Quit(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
50 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
51 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
52 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
53 |
void GlyphRenderer::open_font(const char *fname_regular, const char *fname_bold, int ptsize) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
54 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
55 |
close_font(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
56 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
57 |
// open regular font |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
58 |
_font_regular = TTF_OpenFont(fname_regular, ptsize); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
59 |
if (!_font_regular) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
60 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
61 |
printf("TTF_OpenFont: %s\n", TTF_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
62 |
throw std::exception(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
63 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
64 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
65 |
// open bold font |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
66 |
_font_bold = TTF_OpenFont(fname_bold, ptsize); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
67 |
if (!_font_bold) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
68 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
69 |
printf("TTF_OpenFont: %s\n", TTF_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
70 |
throw std::exception(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
71 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
72 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
73 |
// update metrics for regular font |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
74 |
int advance; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
75 |
if (TTF_GlyphMetrics(_font_regular, 'M', NULL, NULL, NULL, NULL, &advance) == -1) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
76 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
77 |
printf("TTF_GlyphMetrics: %s\n", TTF_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
78 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
79 |
_cell_width = advance; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
80 |
_cell_height = TTF_FontHeight(_font_regular); |
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 |
// read metrics for bold font |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
83 |
if (TTF_GlyphMetrics(_font_bold, 'M', NULL, NULL, NULL, NULL, &advance) == -1) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
84 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
85 |
printf("TTF_GlyphMetrics: %s\n", TTF_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
86 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
87 |
if (advance > _cell_width) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
88 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
89 |
_cell_width = advance; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
90 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
91 |
int height = TTF_FontHeight(_font_bold); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
92 |
if (height > _cell_height) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
93 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
94 |
_cell_height = height; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
95 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
96 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
97 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
98 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
99 |
void GlyphRenderer::close_font() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
100 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
101 |
if (_font_regular) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
102 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
103 |
TTF_CloseFont(_font_regular); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
104 |
_font_regular = NULL; |
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 |
if (_font_bold) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
107 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
108 |
TTF_CloseFont(_font_bold); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
109 |
_font_bold = NULL; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
110 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
111 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
112 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
113 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
114 |
SDL_Surface *GlyphRenderer::render_glyph(Uint16 ch) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
115 |
{ |
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
|
116 |
SDL_Surface *cell_surface; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
117 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
118 |
// try cache |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
119 |
cell_surface = _cache.lookup_glyph(ch); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
120 |
if (cell_surface) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
121 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
122 |
return cell_surface; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
123 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
124 |
|
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
125 |
TTF_Font *font = _font_regular; |
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
|
126 |
SDL_Color color={0xff,0xff,0xff}, bgcolor={0,0,0}; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
127 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
128 |
// create surface for whole cell and fill it with bg color |
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
|
129 |
cell_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
130 |
_cell_width, _cell_height, 32, 0, 0, 0, 0); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
131 |
SDL_Rect dst_rect; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
132 |
dst_rect.x = 0; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
133 |
dst_rect.y = 0; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
134 |
dst_rect.w = _cell_width; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
135 |
dst_rect.h = _cell_height; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
136 |
Uint32 bgcolor_mapped = SDL_MapRGB(cell_surface->format, bgcolor.r, bgcolor.g, bgcolor.b); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
137 |
SDL_FillRect(cell_surface, &dst_rect, bgcolor_mapped); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
138 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
139 |
// render glyph, blit it onto cell surface |
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
|
140 |
if (ch) |
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
|
141 |
{ |
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
|
142 |
SDL_Surface *glyph_surface = TTF_RenderGlyph_Shaded(font, ch, color, bgcolor); |
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
|
143 |
int minx, maxy; |
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
|
144 |
TTF_GlyphMetrics(font, ch, &minx, NULL, NULL, &maxy, NULL); |
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
|
145 |
dst_rect.x = minx; |
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
|
146 |
dst_rect.y = TTF_FontAscent(font) - maxy; |
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
|
147 |
SDL_BlitSurface(glyph_surface, NULL, cell_surface, &dst_rect); |
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
|
148 |
SDL_FreeSurface(glyph_surface); |
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
|
149 |
} |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
150 |
|
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
|
151 |
// convert to display format |
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
|
152 |
SDL_Surface *tmp_surface = cell_surface; |
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
|
153 |
cell_surface = SDL_DisplayFormat(tmp_surface); |
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
|
154 |
SDL_FreeSurface(tmp_surface); |
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
|
155 |
|
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
|
156 |
// put to cache |
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 |
_cache.put_glyph(ch, cell_surface); |
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
|
158 |
|
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
159 |
return cell_surface; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
160 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
161 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
162 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
163 |
void TerminalScreen::select_font(const char *fname_regular, const char *fname_bold, int ptsize) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
164 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
165 |
_render.open_font(fname_regular, fname_bold, ptsize); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
166 |
_reset_cells(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
167 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
168 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
169 |
void TerminalScreen::resize(int pxwidth, int pxheight) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
170 |
{ |
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
|
171 |
_screen_surface = SDL_SetVideoMode(pxwidth, pxheight, 0, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
172 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
173 |
if (_screen_surface == NULL) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
174 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
175 |
fprintf(stderr, "Unable to set video: %s\n", SDL_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
176 |
throw std::exception(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
177 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
178 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
179 |
SDL_WM_SetCaption("terminal", NULL); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
180 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
181 |
_pixel_width = pxwidth; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
182 |
_pixel_height = pxheight; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
183 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
184 |
_reset_cells(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
185 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
186 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
187 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
188 |
void TerminalScreen::erase() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
189 |
{ |
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
|
190 |
std::fill(_cells_front.begin(), _cells_front.end(), TerminalCell()); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
191 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
192 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
193 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
194 |
void TerminalScreen::putch(int x, int y, Uint16 ch, Uint16 attr) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
195 |
{ |
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
|
196 |
TerminalCell &cell = _cells_front[y * _width + x]; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
197 |
cell.ch = ch; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
198 |
cell.attr = attr; |
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 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
202 |
void TerminalScreen::commit() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
203 |
{ |
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
|
204 |
auto front_iter = _cells_front.begin(); |
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
|
205 |
auto back_iter = _cells_back.begin(); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
206 |
SDL_Surface *glyph_surface; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
207 |
SDL_Rect dst_rect; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
208 |
for (int y = 0; y < _height; y++) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
209 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
210 |
for (int x = 0; x < _width; x++) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
211 |
{ |
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
|
212 |
if (*front_iter != *back_iter) |
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
|
213 |
{ |
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
|
214 |
dst_rect.x = x * _cell_width; |
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
|
215 |
dst_rect.y = y * _cell_height; |
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
|
216 |
glyph_surface = _render.render_glyph(front_iter->ch); |
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
|
217 |
SDL_BlitSurface(glyph_surface, NULL, _screen_surface, &dst_rect); |
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
|
218 |
*back_iter = *front_iter; |
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
|
219 |
} |
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
|
220 |
front_iter++; |
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
|
221 |
back_iter++; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
222 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
223 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
224 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
225 |
SDL_UpdateRect(_screen_surface, 0, 0, 0, 0); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
226 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
227 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
228 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
229 |
void TerminalScreen::_reset_cells() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
230 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
231 |
_cell_width = _render.get_cell_width(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
232 |
_cell_height = _render.get_cell_height(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
233 |
_width = _pixel_width / _cell_width; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
234 |
_height = _pixel_height / _cell_height; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
235 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
236 |
int num_cells = _width * _height; |
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
|
237 |
_cells_front.resize(num_cells); |
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
|
238 |
_cells_back.resize(num_cells); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
239 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
240 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
241 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
242 |
Terminal::Terminal() |
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
|
243 |
: _screen(), _mousemove_last_x(-1) |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
244 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
245 |
if (SDL_Init(SDL_INIT_VIDEO) == -1) |
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 |
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
248 |
throw std::exception(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
249 |
} |
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
|
250 |
SDL_EnableUNICODE(1); |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
251 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
252 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
253 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
254 |
Terminal::~Terminal() |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
255 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
256 |
SDL_Quit(); |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
257 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
258 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
259 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
260 |
void Terminal::get_next_event(Event &event) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
261 |
{ |
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
|
262 |
static SDL_Event sdl_event; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
263 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
264 |
while (SDL_WaitEvent(&sdl_event)) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
265 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
266 |
switch (sdl_event.type) |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
267 |
{ |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
268 |
case SDL_QUIT: |
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
|
269 |
event.type = Event::QUIT; |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
270 |
return; |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
271 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
272 |
case SDL_KEYDOWN: |
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
|
273 |
{ |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
274 |
//switch(event.key.keysym.sym) |
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
|
275 |
event.type = Event::KEYPRESS; |
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
|
276 |
const char *keyname = _translate_keyname(sdl_event.key.keysym.sym); |
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
|
277 |
// return only keyname or unicode, never both |
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
|
278 |
if (keyname) |
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
|
279 |
{ |
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
|
280 |
strncpy(event.key.keyname, keyname, 10); |
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
|
281 |
event.key.unicode = 0; |
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
|
282 |
} |
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
|
283 |
else |
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
|
284 |
{ |
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
|
285 |
event.key.keyname[0] = 0; |
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
|
286 |
event.key.unicode = sdl_event.key.keysym.unicode; |
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
|
287 |
if (!event.key.unicode) |
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
|
288 |
break; // continue loop (unknown key) |
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
|
289 |
} |
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
|
290 |
return; |
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
|
291 |
} |
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
|
292 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
293 |
case SDL_MOUSEBUTTONDOWN: |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
294 |
case SDL_MOUSEBUTTONUP: |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
295 |
event.type = (sdl_event.type == SDL_MOUSEBUTTONDOWN) ? Event::MOUSEDOWN : Event::MOUSEUP; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
296 |
event.mouse.x = sdl_event.button.x / _screen.get_cell_width(); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
297 |
event.mouse.y = sdl_event.button.y / _screen.get_cell_height(); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
298 |
event.mouse.button = sdl_event.button.button; |
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
|
299 |
_mousemove_last_x = -1; |
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
|
300 |
return; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
301 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
302 |
case SDL_MOUSEMOTION: |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
303 |
event.type = Event::MOUSEMOVE; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
304 |
event.mouse.x = sdl_event.motion.x / _screen.get_cell_width(); |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
305 |
event.mouse.y = sdl_event.motion.y / _screen.get_cell_height(); |
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
|
306 |
if (_mousemove_last_x != event.mouse.x || |
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
|
307 |
_mousemove_last_y != event.mouse.y) |
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
|
308 |
{ |
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
|
309 |
_mousemove_last_x = event.mouse.x; |
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
|
310 |
_mousemove_last_y = event.mouse.y; |
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
|
311 |
return; |
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
|
312 |
} |
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
|
313 |
break; // continue loop when mouse position did not change |
47
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
314 |
|
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
315 |
default: |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
316 |
break; // continue loop |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
317 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
318 |
} |
537d7c6b48a2
Add sdlterm prototype: extension module for SDL driver.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
319 |
} |
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
|
320 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
321 |
|
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
322 |
const char *Terminal::_translate_keyname(SDLKey sym) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
323 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
324 |
switch (sym) |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
325 |
{ |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
326 |
case SDLK_BACKSPACE: return "backspace"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
327 |
case SDLK_TAB: return "tab"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
328 |
case SDLK_RETURN: return "enter"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
329 |
case SDLK_KP_ENTER: return "enter"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
330 |
case SDLK_PAUSE: return "pause"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
331 |
case SDLK_ESCAPE: return "escape"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
332 |
case SDLK_DELETE: return "delete"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
333 |
case SDLK_INSERT: return "insert"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
334 |
case SDLK_UP: return "up"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
335 |
case SDLK_DOWN: return "down"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
336 |
case SDLK_LEFT: return "left"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
337 |
case SDLK_RIGHT: return "right"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
338 |
case SDLK_HOME: return "home"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
339 |
case SDLK_END: return "end"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
340 |
case SDLK_PAGEUP: return "pageup"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
341 |
case SDLK_PAGEDOWN: return "pagedown"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
342 |
case SDLK_F1: return "f1"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
343 |
case SDLK_F2: return "f2"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
344 |
case SDLK_F3: return "f3"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
345 |
case SDLK_F4: return "f4"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
346 |
case SDLK_F5: return "f5"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
347 |
case SDLK_F6: return "f6"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
348 |
case SDLK_F7: return "f7"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
349 |
case SDLK_F8: return "f8"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
350 |
case SDLK_F9: return "f9"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
351 |
case SDLK_F10: return "f10"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
352 |
case SDLK_F11: return "f11"; |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
353 |
case SDLK_F12: return "f12"; |
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
|
354 |
default: return NULL; |
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
|
355 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
356 |
} |
1f00e90fd72a
Add SDL driver prototype. Update sdlterm: Handle keyboard, mouse events. Add glyph cache.
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
357 |