p-ranav / indicators

Activity Indicators for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

font color unchanged

xzhangxian1008 opened this issue · comments

Kill the programme with Ctrl+C while it is running. The terminal can't change back to the original font color in Xshell.

bug

Although indicators does not directly handle the SIGINT signal, you can handle this like so:

static inline void signal_handler(int signal) {
  indicators::show_console_cursor(true);
  std::cout << termcolor::reset;
  exit(signal);
}

int main() {
  // Register signal handler
  std::signal(SIGTERM, signal_handler);
  std::signal(SIGSEGV, signal_handler);
  std::signal(SIGINT, signal_handler);

This will call the signal handler when you CTRL+C and reset the terminal changes made by the library