From da742e282dc25bfa71596c54c8d459a36c7ae13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ki=C3=ABd=20Llaentenn?= Date: Thu, 17 Sep 2020 11:58:22 +0000 Subject: [PATCH] main: handle q, ctrl+d; add exit point --- main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 20e4702..3d72db1 100644 --- a/main.c +++ b/main.c @@ -91,19 +91,25 @@ main ( int argc, char *argv[] ) if (e.type == TB_EVENT_KEY) { + switch (e.ch) { + case 'q': + goto cleanup; + default: + break; + } + switch (e.key) { - case 0x03: - cleanup(&buf); - exit(0); + case TB_KEY_CTRL_C: + case TB_KEY_CTRL_D: + goto cleanup; default: break; } } } - // perform cleanup +cleanup: cleanup(&buf); - return 0; }