equal
deleted
inserted
replaced
1 #include "sdlterm.h" |
|
2 |
|
3 |
|
4 class Application |
|
5 { |
|
6 public: |
|
7 Terminal term; |
|
8 bool done; |
|
9 |
|
10 Application() : term(), done(false) {}; |
|
11 |
|
12 void init(); |
|
13 void wait_and_process_event(); |
|
14 }; |
|
15 |
|
16 |
|
17 void Application::init() |
|
18 { |
|
19 term.resize(800, 600); |
|
20 term.select_font("font/DejaVuSansMono.ttf", "font/DejaVuSansMono-Bold.ttf", 12); |
|
21 term.erase(); |
|
22 |
|
23 char hello[] = "Hello World!"; |
|
24 for (int bg = 0; bg < 16; bg++) |
|
25 { |
|
26 for (int fg = 0; fg < 16; fg++) |
|
27 { |
|
28 for (char *c = hello; *c; c++) |
|
29 { |
|
30 term.set_attr( term.prepare_attr(fg, bg, 1) ); |
|
31 term.putch(5 + 6 * bg + (c - hello), 5 + fg, *c); |
|
32 } |
|
33 } |
|
34 } |
|
35 term.commit(); |
|
36 } |
|
37 |
|
38 |
|
39 void Application::wait_and_process_event() |
|
40 { |
|
41 Event event; |
|
42 term.wait_event(event, 0); |
|
43 |
|
44 switch (event.type) |
|
45 { |
|
46 case Event::QUIT: |
|
47 done = true; |
|
48 break; |
|
49 |
|
50 default: |
|
51 break; |
|
52 } |
|
53 } |
|
54 |
|
55 |
|
56 int main(int argc, char *argv[]) |
|
57 { |
|
58 Application app; |
|
59 app.init(); |
|
60 |
|
61 while (!app.done) |
|
62 { |
|
63 app.wait_and_process_event(); |
|
64 } |
|
65 |
|
66 return 0; |
|
67 } |
|
68 |
|