mirror of
https://github.com/pevans/erc-c.git
synced 2025-01-03 00:29:38 +00:00
Allow us to signal that we should exit
This commit is contained in:
parent
72c4111458
commit
92ee67c8d8
@ -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 *);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user