sdlterm/demo.cc
changeset 47 537d7c6b48a2
child 48 1f00e90fd72a
equal deleted inserted replaced
46:2b43a7f38c34 47:537d7c6b48a2
       
     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 	term.putch(5, 5, 'W');
       
    23 	term.commit();
       
    24 }
       
    25 
       
    26 
       
    27 void Application::wait_and_process_event()
       
    28 {
       
    29 	Event event;
       
    30 	term.get_next_event(event);
       
    31 
       
    32 	switch (event.type)
       
    33 	{
       
    34 		case EventType::quit:
       
    35 			done = true;
       
    36 			break;
       
    37 
       
    38 		default:
       
    39 			break;
       
    40 	}
       
    41 }
       
    42 
       
    43 
       
    44 int main(int argc, char *argv[])
       
    45 {
       
    46 	Application app;
       
    47 	app.init();
       
    48 
       
    49     while (!app.done)
       
    50     {
       
    51     	app.wait_and_process_event();
       
    52     }
       
    53 
       
    54     return 0;
       
    55 }
       
    56