From 2fb1c801a0a02b2c2b3a9220cc753f762ab2415f Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Thu, 5 Oct 2023 16:41:01 +0200 Subject: [PATCH] Add signal handler to show cursor after ^C --- src/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index dfa994a..1ca60ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,11 +14,17 @@ #include #include #include +#include #include #include #include "robinsonizer_mode.hpp" #include "engine.hpp" +void reset_term(int sig) { + std::cerr << "\nbreak\n\x1b[?25h"; // show cursor again + exit(0); +} + void print_help() { std::cout << "usage: autogram [-h|--version] "; std::cout << "[-a & numerals, const std::string& db int main(int argc, const char * argv[]) { try { + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = reset_term; + (void) sigaction(SIGINT, &sa, NULL); robinsonizer_mode mode {robinsonizer_mode::lax_autogram}; std::string lang {"en"}; std::string start;