From f95145fc4fcaadda557b18f6bd9d3b229cb3b2de Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Fri, 2 Dec 2011 01:30:26 -0500 Subject: Added SIGINT_handler to re-initialize cursor for reset on non-sane terminal emulators --- src/nyancat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nyancat.c b/src/nyancat.c index cd109de..3b07afb 100644 --- a/src/nyancat.c +++ b/src/nyancat.c @@ -853,10 +853,16 @@ char * output = " "; #define MIN_COL 10 #define MAX_COL 50 +void SIGINT_handler(int sig){ + printf("\033[?25h"); + exit(0); +} + int main(int argc, char ** argv) { printf("\033[H\033[2J"); fflush(stdout); int always_escape = 0; + signal(SIGINT, SIGINT_handler); try_again: printf("Select a mode:\n"); printf(" 1 xterm 256-color compatible mode (best)\n"); @@ -1025,6 +1031,5 @@ try_again: printf("\033[H"); usleep(90000); } - return 0; } -- cgit v1.2.3 From a51ae10140af9f408536b588516fadd4708e8b36 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Fri, 2 Dec 2011 01:52:30 -0500 Subject: Added include for signal.h --- src/nyancat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nyancat.c b/src/nyancat.c index 3b07afb..ab36280 100644 --- a/src/nyancat.c +++ b/src/nyancat.c @@ -34,6 +34,7 @@ #include #include #include +#include char * colors[256] = {NULL}; -- cgit v1.2.3