1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-24 15:29:32 +00:00

Allow us to signal that we should exit

This commit is contained in:
Peter Evans 2018-02-05 00:35:04 -06:00
parent 72c4111458
commit 92ee67c8d8
3 changed files with 14 additions and 0 deletions

View File

@ -44,6 +44,11 @@ typedef struct {
*/
bool dirty;
/*
* Should we exit (the next chance we get)?
*/
bool should_exit;
} vm_screen;
extern bool vm_screen_active(vm_screen *);

View File

@ -49,6 +49,7 @@ vm_event_keyboard(vm_event *ev)
ev->screen->key_pressed = false;
if (ch == SDLK_ESCAPE) {
ev->screen->should_exit = true;
}
break;

View File

@ -64,6 +64,7 @@ vm_screen_create()
screen->last_key = '\0';
screen->key_pressed = false;
screen->dirty = false;
screen->should_exit = false;
screen->window = NULL;
screen->render = NULL;
@ -170,6 +171,13 @@ bool
vm_screen_active(vm_screen *scr)
{
vm_event_poll(scr);
// If something happened in the event loop that caused the user to
// signal an exit, then returning false here will do the trick
if (scr->should_exit) {
return false;
}
return true;
}